def test_save_adapt(self): self.clas.save(WIMS_URL, "myself", "toto") u = User("ap'ostrophe", "test", "test", "pass", "*****@*****.**") u.save(self.clas) self.assertEqual("apostrophe", u.quser) self.assertTrue(User.check(self.clas, "apostrophe")) self.assertFalse(User.check(self.clas, "ap'ostrophe"))
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_save_exceptions(self): with self.assertRaises(NotSavedError): self.user.save() with self.assertRaises(NotSavedError): self.user.save(self.clas) self.clas.save(WIMS_URL, "myself", "toto") u = User("ap'ostrophe", "test", "test", "pass", "*****@*****.**") with self.assertRaises(InvalidIdentifier): u.save(self.clas, adapt=False) self.assertFalse(User.check(self.clas, "apostrophe")) self.assertFalse(User.check(self.clas, "ap'ostrophe"))
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")
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