Exemplo n.º 1
0
Arquivo: test.py Projeto: VincentM/xon
    def testboolean(self):
        '''boolean dump and load'''
        obj = {'bool': True}
        xml = '<bool>true</bool>'
        self.assertEqual(obj, xon.loads(xml, convertvalues=True))
        self.assertEqual(xml, xon.dumps(obj, convertvalues=True))

        obj = {'bool': False}
        xml = '<bool>false</bool>'
        self.assertEqual(obj, xon.loads(xml, convertvalues=True))
        self.assertEqual(xml, xon.dumps(obj, convertvalues=True))
Exemplo n.º 2
0
Arquivo: test.py Projeto: joohoi/xon
    def testboolean(self):
        """boolean dump and load"""
        obj = {"bool": True}
        xml = "<bool>true</bool>"
        self.assertEqual(obj, xon.loads(xml, convertvalues=True))
        self.assertEqual(xml, xon.dumps(obj, convertvalues=True))

        obj = {"bool": False}
        xml = "<bool>false</bool>"
        self.assertEqual(obj, xon.loads(xml, convertvalues=True))
        self.assertEqual(xml, xon.dumps(obj, convertvalues=True))
Exemplo n.º 3
0
Arquivo: test.py Projeto: joohoi/xon
    def testboolean(self):
        '''boolean dump and load'''
        obj = {'bool': True}
        xml = '<bool>true</bool>'
        self.assertEqual(obj, xon.loads(xml, convertvalues=True))
        self.assertEqual(xml, xon.dumps(obj, convertvalues=True))

        obj = {'bool': False}
        xml = '<bool>false</bool>'
        self.assertEqual(obj, xon.loads(xml, convertvalues=True))
        self.assertEqual(xml, xon.dumps(obj, convertvalues=True))
Exemplo n.º 4
0
Arquivo: test.py Projeto: joohoi/xon
 def testwrap(self):
     '''wrap an arbitrary object in a parent tag'''
     obj = {'one': 'two', 'three': ['four', 'five']}
     xml = ('<wrapper><one>two</one>'
            '<three>four</three><three>five</three></wrapper>')
     self.assertEqual(obj, xon.loads(xml, unwrap=True))
     self.assertEqual(xml, xon.dumps(obj, wrap='wrapper'))
Exemplo n.º 5
0
Arquivo: test.py Projeto: VincentM/xon
 def testwrap(self):
     '''wrap an arbitrary object in a parent tag'''
     obj = {'one': 'two', 'three': ['four', 'five']}
     xml = ('<wrapper><three>four</three><three>five</three>'
            '<one>two</one></wrapper>')
     self.assertEqual(obj, xon.loads(xml, unwrap=True))
     self.assertEqual(xml, xon.dumps(obj, wrap='wrapper'))
Exemplo n.º 6
0
 def method_call(self, method_calls):
     api_dict = {
         'api': {
             'authentication': {
                 'api_key': self.api_key,
                 'shared_secret': self.api_secret,
             },
         'data': method_calls,
         },
     }
     request_xml = xon.dumps(api_dict)
     self.last_request = request_xml
     params = urllib.urlencode({'data': request_xml,})
     headers = {"Content-type": "application/x-www-form-urlencoded",
             "Accept": "text/plain"}
     url = 'https://echo.bluehornet.com/api/xmlrpc/index.php'
     request = urllib2.Request(url, params, headers)
     response = urllib2.urlopen(request)
     response_xml = response.read()
     return xon.loads(response_xml)
Exemplo n.º 7
0
 def method_call(self, method_calls):
     api_dict = {
         'api': {
             'authentication': {
                 'api_key': self.api_key,
                 'shared_secret': self.api_secret,
             },
             'data': method_calls,
         },
     }
     request_xml = xon.dumps(api_dict)
     self.last_request = request_xml
     params = urllib.urlencode({
         'data': request_xml,
     })
     headers = {
         "Content-type": "application/x-www-form-urlencoded",
         "Accept": "text/plain"
     }
     url = 'https://echo.bluehornet.com/api/xmlrpc/index.php'
     request = urllib2.Request(url, params, headers)
     response = urllib2.urlopen(request)
     response_xml = response.read()
     return xon.loads(response_xml)
Exemplo n.º 8
0
Arquivo: test.py Projeto: joohoi/xon
 def testfloat(self):
     '''float dump and load'''
     obj = {'float': 123.456}
     xml = '<float>123.456</float>'
     self.assertEqual(obj, xon.loads(xml, convertvalues=True))
     self.assertEqual(xml, xon.dumps(obj, convertvalues=True))
Exemplo n.º 9
0
Arquivo: test.py Projeto: joohoi/xon
 def testfloat(self):
     """float dump and load"""
     obj = {"float": 123.456}
     xml = "<float>123.456</float>"
     self.assertEqual(obj, xon.loads(xml, convertvalues=True))
     self.assertEqual(xml, xon.dumps(obj, convertvalues=True))
Exemplo n.º 10
0
Arquivo: test.py Projeto: joohoi/xon
 def testint(self):
     """integer dump and load"""
     obj = {"int": 10}
     xml = "<int>10</int>"
     self.assertEqual(obj, xon.loads(xml, convertvalues=True))
     self.assertEqual(xml, xon.dumps(obj, convertvalues=True))
Exemplo n.º 11
0
Arquivo: test.py Projeto: joohoi/xon
 def testroundtrip(self):
     """roundtrip objects to XON and back"""
     for obj, xml in self.dumps:
         self.assertEqual(obj, xon.loads(xon.dumps(obj)))
Exemplo n.º 12
0
Arquivo: test.py Projeto: joohoi/xon
 def testdumps(self):
     """dumping of objects to XON strings"""
     for obj, xml in self.dumps:
         self.assertEqual(xon.dumps(obj), xml)
Exemplo n.º 13
0
Arquivo: test.py Projeto: joohoi/xon
 def testunicode(self):
     '''unicode string dump and load'''
     obj = {'unicode': u'a string\u2014in Unicode'}
     xml = '<unicode>a string&#8212;in Unicode</unicode>'
     self.assertEqual(obj, xon.loads(xml))
     self.assertEqual(xml, xon.dumps(obj))
Exemplo n.º 14
0
Arquivo: test.py Projeto: VincentM/xon
 def testfloat(self):
     '''float dump and load'''
     obj = {'float': 123.456}
     xml = '<float>123.456</float>'
     self.assertEqual(obj, xon.loads(xml, convertvalues=True))
     self.assertEqual(xml, xon.dumps(obj, convertvalues=True))
Exemplo n.º 15
0
Arquivo: test.py Projeto: joohoi/xon
 def testunicode(self):
     """unicode string dump and load"""
     obj = {"unicode": u"a string\u2014in Unicode"}
     xml = "<unicode>a string&#8212;in Unicode</unicode>"
     self.assertEqual(obj, xon.loads(xml))
     self.assertEqual(xml, xon.dumps(obj))
Exemplo n.º 16
0
Arquivo: test.py Projeto: joohoi/xon
 def testint(self):
     '''integer dump and load'''
     obj = {'int': 10}
     xml = '<int>10</int>'
     self.assertEqual(obj, xon.loads(xml, convertvalues=True))
     self.assertEqual(xml, xon.dumps(obj, convertvalues=True))
Exemplo n.º 17
0
Arquivo: test.py Projeto: joohoi/xon
 def testroundtrip(self):
     '''roundtrip objects to XON and back'''
     for obj, xml in self.dumps:
         self.assertEqual(obj, xon.loads(xon.dumps(obj)))
Exemplo n.º 18
0
Arquivo: test.py Projeto: joohoi/xon
 def testdumps(self):
     '''dumping of objects to XON strings'''
     for obj, xml in self.dumps:
         self.assertEqual(xon.dumps(obj), xml)
Exemplo n.º 19
0
Arquivo: test.py Projeto: VincentM/xon
 def testunicode(self):
     '''unicode string dump and load'''
     obj = {'unicode': u'a string\u2014in Unicode'}
     xml = '<unicode>a string&#8212;in Unicode</unicode>'
     self.assertEqual(obj, xon.loads(xml))
     self.assertEqual(xml, xon.dumps(obj))
Exemplo n.º 20
0
Arquivo: test.py Projeto: joohoi/xon
 def testwrap(self):
     """wrap an arbitrary object in a parent tag"""
     obj = {"one": "two", "three": ["four", "five"]}
     xml = "<wrapper><one>two</one>" "<three>four</three><three>five</three></wrapper>"
     self.assertEqual(obj, xon.loads(xml, unwrap=True))
     self.assertEqual(xml, xon.dumps(obj, wrap="wrapper"))
Exemplo n.º 21
0
Arquivo: test.py Projeto: VincentM/xon
 def testint(self):
     '''integer dump and load'''
     obj = {'int': 10}
     xml = '<int>10</int>'
     self.assertEqual(obj, xon.loads(xml, convertvalues=True))
     self.assertEqual(xml, xon.dumps(obj, convertvalues=True))