Example #1
0
 def test_request(self):
     app = connections.Application('test', '1.0', 'default', 'abc123')
     auth = connections.Auth('company', 'username', 'p@ssw0rd')
     time = [commands.Time().time()]
     self.assertIsInstance(
         connections.Request(app, auth, time).request(),
         ET.Element
     )
Example #2
0
 def test_str(self):
     app = connections.Application('test', '1.0', 'default', 'abc123')
     auth = connections.Auth('company', 'username', 'p@ssw0rd')
     time = [commands.Time().time()]
     self.assertEqual(
         str(connections.Request(app, auth, time)),
         '<Request client=test company=company username=username>'
     )
Example #3
0
 def test_tostring_nodata(self):
     app = connections.Application('test', '1.0', 'default', 'abc123')
     auth = connections.Auth('company', 'username', 'p@ssw0rd')
     self.assertEqual(
         connections.Request(app, auth, None).tostring(),
         (
             b'<?xml version="1.0" encoding="utf-8"?>'
             b'<request API_ver="1.0" client="test" client_ver="1.0" '
             b'key="abc123" namespace="default"><Auth><Login>'
             b'<company>company</company><user>username</user>'
             b'<password>p@ssw0rd</password></Login></Auth></request>'
         )
     )
Example #4
0
 def test_prettify(self):
     self.assertEqual(
         connections.Auth('company', 'username', 'p@ssw0rd').prettify(),
         (
             b'<?xml version="1.0" encoding="utf-8"?>\n'
             b'<Auth>\n'
             b'  <Login>\n'
             b'    <company>company</company>\n'
             b'    <user>username</user>\n'
             b'    <password>p@ssw0rd</password>\n'
             b'  </Login>\n'
             b'</Auth>\n'
          )
     )
Example #5
0
 def test_prettify(self):
     app = connections.Application('test', '1.0', 'default', 'abc123')
     auth = connections.Auth('company', 'username', 'p@ssw0rd')
     time = [commands.Time().time()]
     self.assertEqual(
         connections.Request(app, auth, time).prettify(),
         (
             b'<?xml version="1.0" encoding="utf-8"?>\n'
             b'<request API_ver="1.0" client="test" client_ver="1.0" key="abc123" namespace="default">\n'
             b'  <Auth>\n'
             b'    <Login>\n'
             b'      <company>company</company>\n'
             b'      <user>username</user>\n'
             b'      <password>p@ssw0rd</password>\n'
             b'    </Login>\n'
             b'  </Auth>\n'
             b'  <Time/>\n'
             b'</request>\n'
         )
     )
Example #6
0
 def test_tostring(self):
     self.assertEqual(
         connections.Auth('company', 'username', 'p@ssw0rd').tostring(),
         b'<Auth><Login><company>company</company><user>username</user><password>p@ssw0rd</password></Login></Auth>'
     )
Example #7
0
 def test_auth(self):
     self.assertIsInstance(
         connections.Auth('company', 'username', 'p@ssw0rd').auth(),
         ET.Element
     )
Example #8
0
 def test_str(self):
     self.assertEqual(
         str(connections.Auth('company', 'username', 'p@ssw0rd')),
         '<Auth company=company username=username>'
     )