Commit f9598f0f authored by Loic Baron's avatar Loic Baron
Browse files

test model user split save and delete tests

parent 3a52ee27
......@@ -14,6 +14,8 @@ TPcP2p4sEoMvOLCb8vPW1tKDFfM/RIuZjcn89irYjQ=="
class TestUser(unittest.TestCase):
created_user = None
def setUp(self):
u = User()
self.assertIsInstance(u, User)
......@@ -43,19 +45,23 @@ class TestUser(unittest.TestCase):
self.assertEqual(u.hrn, 'onelab.upmc.lbaron')
self.assertEqual(u.shortname, 'lbaron')
def test_4_save_and_delete(self):
def test_4_save(self):
u = User()
u.hrn = 'onelab.upmc.apitest.lbaron'
u.email = 'apitest@gmail.com'
u.hrn = 'onelab.upmc.lbaron'
u.email = 'apitest@onelab.eu'
u.keys = [PKEY]
# test save
res = u.save()
usrdata, errors = res['data'][0], res['errors']
self.assertEqual(res['errors'], [])
self.assertEqual(usrdata['hrn'], 'onelab.upmc.apitest.lbaron')
self.assertEqual(usrdata['email'], 'apitest@gmail.com')
self.assertEqual(usrdata['hrn'], 'onelab.upmc.lbaron')
self.assertEqual(usrdata['email'], 'apitest@onelab.eu')
self.assertEqual(usrdata['keys'], [PKEY])
self.assertIsNotNone(usrdata['certificate'])
self.__class__.created_user = User(usrdata)
def test_5_delete(self):
u = self.created_user
# test delete
res = u.delete()
self.assertEqual(res, {'errors': [], 'data': []})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment