def test_invalid_user_password(self): company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'}) user = datatypes.Datatype('User', { 'nickname': 'admin', 'email': '*****@*****.**' }) with self.assertRaises(Exception): commands.CreateAccount(company, user).create()
def test_create(self): company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'}) user = datatypes.Datatype('User', { 'nickname': 'admin', 'password': '******', 'email': '*****@*****.**' }) self.assertIsInstance( commands.CreateAccount(company, user).create(), ET.Element)
def test_str(self): company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'}) user = datatypes.Datatype('User', { 'nickname': 'admin', 'password': '******', 'email': '*****@*****.**' }) self.assertEqual(str(commands.CreateAccount(company, user)), '<CreateAccount nickname=Acme Inc>')
def test_tostring(self): company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'}) user = datatypes.Datatype('User', { 'nickname': 'admin', 'password': '******', 'email': '*****@*****.**' }) self.assertEqual( commands.CreateAccount(company, user).tostring(), (b'<CreateAccount><Company><nickname>Acme Inc</nickname></Company>' b'<User><nickname>admin</nickname><password>p@ssw0rd</password>' b'<addr><Address><email>[email protected]</email></Address></addr>' b'</User></CreateAccount>'))
def test_prettify(self): company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'}) user = datatypes.Datatype('User', { 'nickname': 'admin', 'password': '******', 'email': '*****@*****.**' }) self.assertEqual( commands.CreateAccount(company, user).prettify(), (b'<?xml version="1.0" encoding="utf-8"?>\n' b'<CreateAccount>\n' b' <Company>\n' b' <nickname>Acme Inc</nickname>\n' b' </Company>\n' b' <User>\n' b' <nickname>admin</nickname>\n' b' <password>p@ssw0rd</password>\n' b' <addr>\n' b' <Address>\n' b' <email>[email protected]</email>\n' b' </Address>\n' b' </addr>\n' b' </User>\n' b'</CreateAccount>\n'))