Exemplo n.º 1
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()
Exemplo n.º 2
0
    def test_save_without_qclass(self):
        c = Class("myclass", "A class", "an institution", "*****@*****.**",
                  "password", self.user)

        with self.assertRaises(NotSavedError):
            c.save()

        c.save(WIMS_URL, "myself", "toto")
        self.assertIsNotNone(c.qclass)
        c.delete()
Exemplo n.º 3
0
    def test_delete(self):
        c = Class("myclass",
                  "A class",
                  "an institution",
                  "*****@*****.**",
                  "password",
                  self.user,
                  qclass=999999)

        with self.assertRaises(NotSavedError):
            c.delete()

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

        Class.get(WIMS_URL, "myself", "toto", c.qclass, c.rclass)  #  Ok
        c.delete()
        with self.assertRaises(AdmRawError):
            Class.get(WIMS_URL, "myself", "toto", c.qclass,
                      c.rclass)  # Should raise the exception
Exemplo n.º 4
0
    def test_eq(self):
        c1 = Class("rclass", "A class", "an institution", "*****@*****.**",
                   "password", self.user)
        c2 = Class("rclass", "A class", "an institution", "*****@*****.**",
                   "password", self.user)
        c3 = Class("rclass", "A class", "an institution", "*****@*****.**",
                   "password", self.user)

        with self.assertRaises(NotSavedError):
            c1 == c3

        c1.save(WIMS_URL, "myself", "toto")
        c2.save(WIMS_URL, "myself", "toto")
        c3.save(WIMS_URL, "myself", "toto")

        self.assertEqual(
            c1, Class.get(WIMS_URL, "myself", "toto", c1.qclass, c1.rclass))
        self.assertNotEqual(
            c2, Class.get(WIMS_URL, "myself", "toto", c1.qclass, c1.rclass))
        self.assertNotEqual(c2, 1)

        c1.delete()
        c2.delete()
        c3.delete()
Exemplo n.º 5
0
    def test_list(self):
        c1 = Class("rclass", "A class", "an institution", "*****@*****.**",
                   "password", self.user)
        c2 = Class("rclass", "A class", "an institution", "*****@*****.**",
                   "password", self.user)
        c3 = Class("rclass", "A class", "an institution", "*****@*****.**",
                   "password", self.user)

        c1.save(WIMS_URL, "myself", "toto")
        c2.save(WIMS_URL, "myself", "toto")
        c3.save(WIMS_URL, "myself", "toto")

        self.assertListEqual(
            sorted([c1, c2, c3], key=lambda i: i.qclass),
            sorted(Class.list(WIMS_URL, "myself", "toto", "rclass"),
                   key=lambda i: i.qclass))

        self.assertListEqual([],
                             Class.list(WIMS_URL, "myself", "toto",
                                        "unknown_rclass"))

        c1.delete()
        c2.delete()
        c3.delete()