예제 #1
0
    def test_delitem(self):
        c = Class("myclass",
                  "A class",
                  "an institution",
                  "*****@*****.**",
                  "password",
                  self.user,
                  qclass=999999)
        u = User("quser", "last", "first", "pass", "*****@*****.**")
        u2 = User("quser2", "last", "first", "pass", "*****@*****.**")

        with self.assertRaises(NotSavedError):
            c.delitem(u)
        with self.assertRaises(InvalidItemTypeError):
            c.delitem(int)

        c.save(WIMS_URL, "myself", "toto")
        c.additem(u)
        c.additem(u2)

        self.assertTrue(c.checkitem("quser", User))
        c.delitem(u)
        self.assertFalse(c.checkitem("quser", User))

        self.assertTrue(c.checkitem("quser2", User))
        c.delitem("quser2", User)
        self.assertFalse(c.checkitem("quser2", User))
예제 #2
0
    def test_checkitem(self):
        c = Class("myclass",
                  "A class",
                  "an institution",
                  "*****@*****.**",
                  "password",
                  self.user,
                  qclass=999999)
        unknown = User("unknown", "last", "first", "pass", "*****@*****.**")

        with self.assertRaises(NotSavedError):
            c.checkitem("supervisor", User)
        with self.assertRaises(InvalidItemTypeError):
            c.checkitem(1)

        c.save(WIMS_URL, "myself", "toto")
        self.assertTrue(c.checkitem("supervisor", User))
        self.assertTrue(c.checkitem(self.user))
        self.assertFalse(c.checkitem("Unknown", User))
        self.assertFalse(c.checkitem(unknown))