Exemplo n.º 1
0
    def runTest(self):
        # Convert KVForm to dict
        d = kvform.kvToDict(self.kvform)

        # make sure it parses to expected dict
        self.failUnlessEqual(self.dict, d)

        # Check to make sure we got the expected number of warnings
        self.checkWarnings(self.expected_warnings)

        # Convert back to KVForm and round-trip back to dict to make
        # sure that *** dict -> kv -> dict is identity. ***
        kv = kvform.dictToKV(d)
        d2 = kvform.kvToDict(kv)
        self.failUnlessEqual(d, d2)
Exemplo n.º 2
0
    def runTest(self):
        # Convert KVForm to dict
        d = kvform.kvToDict(self.kvform)

        # make sure it parses to expected dict
        self.failUnlessEqual(self.dict, d)

        # Check to make sure we got the expected number of warnings
        self.checkWarnings(self.expected_warnings)

        # Convert back to KVForm and round-trip back to dict to make
        # sure that *** dict -> kv -> dict is identity. ***
        kv = kvform.dictToKV(d)
        d2 = kvform.kvToDict(kv)
        self.failUnlessEqual(d, d2)
Exemplo n.º 3
0
    def runTest(self):
        for kv_data, result, expected_warnings in kvdict_cases:
            # Convert KVForm to dict
            with LogCapture() as logbook:
                d = kvform.kvToDict(kv_data)

            # make sure it parses to expected dict
            self.assertEqual(d, result)

            # Check to make sure we got the expected number of warnings
            self.assertEqual(len(logbook.records), expected_warnings)

            # Convert back to KVForm and round-trip back to dict to make
            # sure that *** dict -> kv -> dict is identity. ***
            kv = kvform.dictToKV(d)
            d2 = kvform.kvToDict(kv)
            self.assertEqual(d, d2)
Exemplo n.º 4
0
    def runTest(self):
        for kv_data, result, expected_warnings in kvdict_cases:
            # Convert KVForm to dict
            with LogCapture() as logbook:
                d = kvform.kvToDict(kv_data)

            # make sure it parses to expected dict
            self.assertEqual(d, result)

            # Check to make sure we got the expected number of warnings
            self.assertEqual(len(logbook.records), expected_warnings)

            # Convert back to KVForm and round-trip back to dict to make
            # sure that *** dict -> kv -> dict is identity. ***
            kv = kvform.dictToKV(d)
            d2 = kvform.kvToDict(kv)
            self.assertEqual(d, d2)
Exemplo n.º 5
0
    def _makeKVPost(self, args, server_url):
        mode = args['openid.mode']
        body = urllib.urlencode(args)

        resp = fetchers.fetch(server_url, body=body)
        if resp is None:
            fmt = 'openid.mode=%s: failed to fetch URL: %s'
            oidutil.log(fmt % (mode, server_url))
            return None

        response = kvform.kvToDict(resp.body)
        if resp.status == 400:
            server_error = response.get('error', '<no message from server>')
            fmt = 'openid.mode=%s: error returned from server %s: %s'
            oidutil.log(fmt % (mode, server_url, server_error))
            return None
        elif resp.status != 200:
            fmt = 'openid.mode=%s: bad status code from server %s: %s'
            oidutil.log(fmt % (mode, server_url, resp.status))
            return None

        return response
Exemplo n.º 6
0
 def fromKVForm(cls, kvform_string):
     """Create a Message from a KVForm string"""
     return cls.fromOpenIDArgs(kvform.kvToDict(kvform_string))
Exemplo n.º 7
0
 def fromKVForm(cls, kvform_string):
     """Create a Message from a KVForm string"""
     return cls.fromOpenIDArgs(kvform.kvToDict(kvform_string))