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 )
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>' )
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>' ) )
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' ) )
def test_prettify(self): self.assertEqual(commands.Time().prettify(), (b'<?xml version="1.0" encoding="utf-8"?>\n' b'<Time/>\n'))
def test_tostring(self): self.assertEqual(commands.Time().tostring(), b'<Time />')
def test_time(self): self.assertIsInstance(commands.Time().time(), ET.Element)
def test_str(self): self.assertEqual(str(commands.Time()), '<Time>')
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()