Ejemplo n.º 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
     )
Ejemplo n.º 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>'
     )
Ejemplo n.º 3
0
 def test_tostring_remoteauth(self):
     app = connections.Application('test', '1.0', 'default', 'abc123')
     remoteauth = connections.RemoteAuth('company', 'username', 'p@ssw0rd')
     time = [commands.Time().time()]
     self.assertEqual(
         connections.Request(app, remoteauth, time).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"><RemoteAuth><Login>'
             b'<company>company</company><user>username</user>'
             b'<password>p@ssw0rd</password></Login></RemoteAuth>'
             b'<Time /></request>'
         )
     )
Ejemplo n.º 4
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'
         )
     )
Ejemplo n.º 5
0
 def test_prettify(self):
     self.assertEqual(commands.Time().prettify(),
                      (b'<?xml version="1.0" encoding="utf-8"?>\n'
                       b'<Time/>\n'))
Ejemplo n.º 6
0
 def test_tostring(self):
     self.assertEqual(commands.Time().tostring(), b'<Time />')
Ejemplo n.º 7
0
 def test_time(self):
     self.assertIsInstance(commands.Time().time(), ET.Element)
Ejemplo n.º 8
0
 def test_str(self):
     self.assertEqual(str(commands.Time()), '<Time>')
Ejemplo n.º 9
0
 def test_tostring_noauth(self):
     app = connections.Application('test', '1.0', 'default', 'abc123')
     user = datatypes.Datatype('User', {'id': '1234'})
     time = [commands.Time().time()]
     with self.assertRaises(Exception):
         connections.Request(app, user, time).request()