def test_get_exception(self): with self.assertRaises(NotSavedError): User.get(self.clas, "supervisor") self.clas.save(WIMS_URL, "myself", "toto") with self.assertRaises(AdmRawError) as cm: User.get(self.clas, "unknown") self.assertIn("WIMS' server responded with an ERROR:", str(cm.exception))
def test_delete(self): self.clas.save(WIMS_URL, "myself", "toto") u = User("Test", "test", "test", "pass", "*****@*****.**") with self.assertRaises(NotSavedError): u.delete() u.save(self.clas) User.get(self.clas, u.quser) # Ok u.delete() with self.assertRaises(AdmRawError): User.get(self.clas, u.quser) # Should raise the exception
def test_init_and_properties(self): c = Class.get(WIMS_URL, "myself", "toto", 9001, "myclass") u = User.get(c, "supervisor") self.assertIn("firstname", u.infos) u = User("supervisor", "last", "first", "pass", "*****@*****.**") self.assertEqual(u.fullname, "First Last") with self.assertRaises(NotSavedError): u.infos
def test_remove(self): self.clas.save(WIMS_URL, "myself", "toto") c = Class("myclass", "A class", "an institution", "*****@*****.**", "password", self.user, qclass=999999) u = User("Test", "test", "test", "pass", "*****@*****.**") with self.assertRaises(NotSavedError): u.remove(c, u) u.save(self.clas) User.get(self.clas, u.quser) # Ok User.remove(self.clas, u) with self.assertRaises(AdmRawError): User.get(self.clas, u.quser) # Should raise the exception
def test_save_and_refresh(self): self.clas.save(WIMS_URL, "myself", "toto") u = User("Test", "test", "test", "pass", "*****@*****.**") with self.assertRaises(NotSavedError): u.refresh() u.save(self.clas) u2 = User.get(self.clas, u.quser) self.assertEqual(u2.firstname, "test") u.firstname = "modified" u.save() self.assertEqual(u.firstname, "modified") self.assertEqual(u2.firstname, "test") u2.refresh() self.assertEqual(u2.firstname, "modified")