Ejemplo n.º 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))
Ejemplo n.º 2
0
    def test_listitem(self):
        c = Class("rclass",
                  "A class",
                  "an institution",
                  "*****@*****.**",
                  "password",
                  self.user,
                  qclass=999999)

        with self.assertRaises(NotSavedError):
            c.listitem(Sheet)
        with self.assertRaises(InvalidItemTypeError):
            c.listitem(int)

        s1 = Sheet("First", "First one")
        s2 = Sheet("Second", "Second one")
        s3 = Sheet("Third", "Third one")

        c.save(WIMS_URL, "myself", "toto")

        self.assertListEqual([], c.listitem(Sheet))

        c.additem(s1)
        c.additem(s2)
        c.additem(s3)

        self.assertListEqual(sorted([s1, s2, s3], key=lambda i: i.qsheet),
                             sorted(c.listitem(Sheet), key=lambda i: i.qsheet))

        c.delete()
Ejemplo n.º 3
0
    def test_additem(self):
        c = Class("myclass",
                  "A class",
                  "an institution",
                  "*****@*****.**",
                  "password",
                  self.user,
                  qclass=999999)
        u = User("quser", "last", "first", "pass", "*****@*****.**")

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

        c.save(WIMS_URL, "myself", "toto")
        c.additem(u)
        self.assertEqual(u._class.qclass, c.qclass)
        self.assertEqual(u.wclass, True)

        u2 = c.getitem("quser", User)
        self.assertEqual(u2.firstname, u.firstname)