Example #1
0
File: test.py Project: 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))
Example #2
0
File: test.py Project: 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))
Example #3
0
File: test.py Project: 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))
Example #4
0
File: test.py Project: 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'))
Example #5
0
File: test.py Project: 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'))
Example #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)
Example #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)
Example #8
0
File: test.py Project: 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))
Example #9
0
File: test.py Project: 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))
Example #10
0
File: test.py Project: 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))
Example #11
0
File: test.py Project: 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)))
Example #12
0
File: test.py Project: joohoi/xon
 def testdumps(self):
     """dumping of objects to XON strings"""
     for obj, xml in self.dumps:
         self.assertEqual(xon.dumps(obj), xml)
Example #13
0
File: test.py Project: 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))
Example #14
0
File: test.py Project: 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))
Example #15
0
File: test.py Project: 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))
Example #16
0
File: test.py Project: 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))
Example #17
0
File: test.py Project: 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)))
Example #18
0
File: test.py Project: joohoi/xon
 def testdumps(self):
     '''dumping of objects to XON strings'''
     for obj, xml in self.dumps:
         self.assertEqual(xon.dumps(obj), xml)
Example #19
0
File: test.py Project: 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))
Example #20
0
File: test.py Project: 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"))
Example #21
0
File: test.py Project: 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))