Logo Search packages:      
Sourcecode: ubuntuone-couch version File versions  Download package

def ubuntuone::tests::test_couch::QueryTestCase::test_request_all_dbs_with_extra_headers (   self )
Test a full request to _all_dbs with extra headers passed.

Definition at line 225 of file test_couch.py.

                                                     :
        """Test a full request to _all_dbs with extra headers passed."""
        fake_result = [
            u'u/abc/def/1337/dc_trash', u'u/abc/def/1337/lernid',
            u'u/abc/def/1337/test_suite_db']
        fake_json = json.dumps(fake_result)
        mock_get_oauth_credentials = self.mocker.replace(
            'ubuntuone.couch.auth.get_oauth_credentials')
        mock_get_oauth_credentials()
        self.mocker.result({
            u'token': TOKEN_KEY,
            u'token_secret': TOKEN_SECRET,
            u'consumer_key': CONSUMER_KEY,
            u'consumer_secret': CONSUMER_SECRET})
        mock_get_user_info = self.mocker.replace(
            'ubuntuone.couch.get_user_info')
        mock_get_user_info(
            'https://one.ubuntu.com/api/account/', consumer_key=CONSUMER_KEY,
            consumer_secret=CONSUMER_SECRET, access_token=TOKEN_KEY,
            token_secret=TOKEN_SECRET)
        self.mocker.result((
            1337, "https://couchdb.one.ubuntu.com/u/abc/def/1337"))
        Http = self.mocker.replace("httplib2.Http")  # pylint: disable=C0103
        http = Http()

        def _check_headers(param):
            """Confirm that extra headers really are passed."""
            return (param.get("X-Men") == "unite") and \
                (param.get("X-tasy") == "bad for you")
        http.request(
            'https://couchdb.one.ubuntu.com/_all_dbs?user_id=1337',
            method='GET', headers=MATCH(_check_headers), body=None)
        self.mocker.result(({'status': '200'}, fake_json))
        self.mocker.replay()
        result = request('_all_dbs',
            extra_headers=['X-Men: unite', 'X-tasy: bad for you'])
        self.assertEquals(fake_result, result)


Generated by  Doxygen 1.6.0   Back to index