Ejemplo n.º 1
0
 def test_5_get_item_lists(self):
     for method in self.methods:
         factory = ItemListFactory(method, self.basedir)
         self.prepare(factory)
         factory.create_item_list("http://localhost:3000/item_lists/1", "first item list", "shared")
         factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-010")
         factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-011")
         factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-012")
         factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-013")
         factory.create_item_list("http://localhost:3000/item_lists/2", "second item list", "own")
         factory.add_to_item_list("http://localhost:3000/item_lists/2", "http://localhost:3000/catalog/cooee/items/1-013")
         factory.add_to_item_list("http://localhost:3000/item_lists/2", "http://localhost:3000/catalog/cooee/items/1-014")
         factory.add_to_item_list("http://localhost:3000/item_lists/2", "http://localhost:3000/catalog/cooee/items/1-015")
         
         itemlists = factory.get_item_lists()
         listitemlists = []
         for status in ["shared", "own"]:
             listitemlists.extend(itemlists[status])
         hit = len(listitemlists)
         compare = 2
         self.assertEqual(hit, compare, "expected %s item lists" % str(compare))
         
         hit = [itemlist["item_list_url"] for itemlist in listitemlists]
         compare = "http://localhost:3000/item_lists/1"
         self.assertIn(compare, hit, "expected '%s' to be in the list" % compare)
         
         compare = "http://localhost:3000/item_lists/3"
         self.assertNotIn(compare, hit, "expected '%s' not to be in the list" % compare)
Ejemplo n.º 2
0
    def test_8_clear_item_list(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)
            factory.create_item_list("http://localhost:3000/item_lists/1",
                                     "first item list", "shared")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-010")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-011")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-012")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-013")

            items = factory.get_item_list(
                "http://localhost:3000/item_lists/1")["items"]
            hit = len(items)
            compare = 4
            self.assertEqual(
                hit, compare,
                "Expected the size of the list to be %s" % str(compare))

            factory.clear_item_list("http://localhost:3000/item_lists/1")
            items = factory.get_item_list(
                "http://localhost:3000/item_lists/1")["items"]
            hit = len(items)
            compare = 0
            self.assertEqual(
                hit, compare,
                "Expected the size of the list to be %s" % str(compare))
Ejemplo n.º 3
0
    def test_6_change_item_list_shared(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)

            factory.create_item_list("http://localhost:3000/item_lists/1",
                                     "first item list", "shared")
            hit = factory.get_item_list(
                "http://localhost:3000/item_lists/1")["shared"]
            compare = "shared"
            self.assertEqual(
                hit, compare,
                "Expected shared status of the item list to be %s" % compare)

            factory.unshare_item_list("http://localhost:3000/item_lists/1")
            hit = factory.get_item_list(
                "http://localhost:3000/item_lists/1")["shared"]
            compare = "own"
            self.assertEqual(
                hit, compare,
                "Expected shared status of the item list to be %s" % compare)

            factory.share_item_list("http://localhost:3000/item_lists/1")
            hit = factory.get_item_list(
                "http://localhost:3000/item_lists/1")["shared"]
            compare = "shared"
            self.assertEqual(
                hit, compare,
                "Expected shared status of the item list to be %s" % compare)
Ejemplo n.º 4
0
    def test_7_delete_item_list(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)
            factory.create_item_list("http://localhost:3000/item_lists/1",
                                     "first item list", "shared")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-010")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-011")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-012")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-013")
            factory.create_item_list("http://localhost:3000/item_lists/2",
                                     "second item list", "own")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/2",
                "http://localhost:3000/catalog/cooee/items/1-013")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/2",
                "http://localhost:3000/catalog/cooee/items/1-014")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/2",
                "http://localhost:3000/catalog/cooee/items/1-015")

            itemlists = factory.get_item_lists()
            listitemlists = []
            for status in ["shared", "own"]:
                listitemlists.extend(itemlists[status])
            hit = len(listitemlists)
            compare = 2
            self.assertEqual(hit, compare,
                             "expected %s item lists" % str(compare))

            hit = [itemlist["item_list_url"] for itemlist in listitemlists]
            compare = "http://localhost:3000/item_lists/1"
            self.assertIn(compare, hit,
                          "expected '%s' to be in the list" % compare)

            factory.delete_item_list("http://localhost:3000/item_lists/1")
            itemlists = factory.get_item_lists()
            listitemlists = []
            for status in ["shared", "own"]:
                listitemlists.extend(itemlists[status])
            hit = len(listitemlists)
            compare = 1
            self.assertEqual(hit, compare,
                             "expected %s item lists" % str(compare))

            hit = [itemlist["item_list_url"] for itemlist in listitemlists]
            compare = "http://localhost:3000/item_lists/1"
            self.assertNotIn(compare, hit,
                             "expected '%s' not to be in the list" % compare)
Ejemplo n.º 5
0
 def test_3_empty_item_list(self):
     for method in self.methods:
         factory = ItemListFactory(method, self.basedir)
         self.prepare(factory)
         factory.create_item_list("http://localhost:3000/item_lists/1", "first item list", "shared")
         
         hit = factory.get_item_list("http://localhost:3000/item_lists/1")["num_items"]
         compare = 0
         self.assertEqual(hit, compare, "expected the itemlist to have %s items" % str(compare))
Ejemplo n.º 6
0
 def test_10_rename_item_list(self):
     for method in self.methods:
         factory = ItemListFactory(method, self.basedir)
         self.prepare(factory)
         factory.create_item_list("http://localhost:3000/item_lists/1", "first item list", "shared")
         factory.rename_item_list("http://localhost:3000/item_lists/1", "this is a new name")
         
         hit = factory.get_item_list("http://localhost:3000/item_lists/1")["name"]
         compare = "this is a new name"
         self.assertEqual(hit, compare, "Expected %s, got %s" %(compare, hit))
Ejemplo n.º 7
0
 def test_9_get_item_list_id(self):
     for method in self.methods:
         factory = ItemListFactory(method, self.basedir)
         self.prepare(factory)
         factory.create_item_list("http://localhost:3000/item_lists/1", "first item list", "shared")
         
         hit = factory.get_item_list_id("first item list")
         compare = "http://localhost:3000/item_lists/1"
         
         self.assertEqual(hit, compare, "Expected %s got %s" %(compare, hit))
Ejemplo n.º 8
0
    def test_9_get_item_list_id(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)
            factory.create_item_list("http://localhost:3000/item_lists/1",
                                     "first item list", "shared")

            hit = factory.get_item_list_id("first item list")
            compare = "http://localhost:3000/item_lists/1"

            self.assertEqual(hit, compare,
                             "Expected %s got %s" % (compare, hit))
Ejemplo n.º 9
0
 def test_2_create_item_list(self):
     for method in self.methods:
         factory = ItemListFactory(method, self.basedir)
         self.prepare(factory)
         factory.create_item_list("http://localhost:3000/item_lists/1", "first item list", "shared")
         
         hit = factory.get_item_list("http://localhost:3000/item_lists/1")["name"]
         compare = "first item list"
         self.assertEqual(hit, compare, "expected the name of the itemlist to be '%s'" % compare)
         
         hit = factory.get_item_list("http://localhost:3000/item_lists/1")["shared"]
         compare = "shared"
         self.assertEqual(hit, compare, "expected the shared status of the itemlist to be '%s'" % compare)
Ejemplo n.º 10
0
    def test_3_empty_item_list(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)
            factory.create_item_list("http://localhost:3000/item_lists/1",
                                     "first item list", "shared")

            hit = factory.get_item_list(
                "http://localhost:3000/item_lists/1")["num_items"]
            compare = 0
            self.assertEqual(
                hit, compare,
                "expected the itemlist to have %s items" % str(compare))
Ejemplo n.º 11
0
    def test_10_rename_item_list(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)
            factory.create_item_list("http://localhost:3000/item_lists/1",
                                     "first item list", "shared")
            factory.rename_item_list("http://localhost:3000/item_lists/1",
                                     "this is a new name")

            hit = factory.get_item_list(
                "http://localhost:3000/item_lists/1")["name"]
            compare = "this is a new name"
            self.assertEqual(hit, compare,
                             "Expected %s, got %s" % (compare, hit))
Ejemplo n.º 12
0
 def test_6_change_item_list_shared(self):
     for method in self.methods:
         factory = ItemListFactory(method, self.basedir)
         self.prepare(factory)
         
         factory.create_item_list("http://localhost:3000/item_lists/1", "first item list", "shared")
         hit = factory.get_item_list("http://localhost:3000/item_lists/1")["shared"]
         compare = "shared"
         self.assertEqual(hit, compare, "Expected shared status of the item list to be %s" % compare)
         
         factory.unshare_item_list("http://localhost:3000/item_lists/1")
         hit = factory.get_item_list("http://localhost:3000/item_lists/1")["shared"]
         compare = "own"
         self.assertEqual(hit, compare, "Expected shared status of the item list to be %s" % compare)
         
         factory.share_item_list("http://localhost:3000/item_lists/1")
         hit = factory.get_item_list("http://localhost:3000/item_lists/1")["shared"]
         compare = "shared"
         self.assertEqual(hit, compare, "Expected shared status of the item list to be %s" % compare)
Ejemplo n.º 13
0
    def test_8_clear_item_list(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)
            factory.create_item_list("http://localhost:3000/item_lists/1", "first item list", "shared")
            factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-010")
            factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-011")
            factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-012")
            factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-013")

            items = factory.get_item_list("http://localhost:3000/item_lists/1")["items"]
            hit = len(items)
            compare = 4
            self.assertEqual(hit, compare, "Expected the size of the list to be %s" % str(compare))
            
            factory.clear_item_list("http://localhost:3000/item_lists/1")
            items = factory.get_item_list("http://localhost:3000/item_lists/1")["items"]
            hit = len(items)
            compare = 0
            self.assertEqual(hit, compare, "Expected the size of the list to be %s" % str(compare))
Ejemplo n.º 14
0
    def test_2_create_item_list(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)
            factory.create_item_list("http://localhost:3000/item_lists/1",
                                     "first item list", "shared")

            hit = factory.get_item_list(
                "http://localhost:3000/item_lists/1")["name"]
            compare = "first item list"
            self.assertEqual(
                hit, compare,
                "expected the name of the itemlist to be '%s'" % compare)

            hit = factory.get_item_list(
                "http://localhost:3000/item_lists/1")["shared"]
            compare = "shared"
            self.assertEqual(
                hit, compare,
                "expected the shared status of the itemlist to be '%s'" %
                compare)
Ejemplo n.º 15
0
 def test_4_add_items(self):
     for method in self.methods:
         factory = ItemListFactory(method, self.basedir)
         self.prepare(factory)
         factory.create_item_list("http://localhost:3000/item_lists/1", "first item list", "shared")
         factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-010")
         factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-011")
         factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-012")
         factory.add_to_item_list("http://localhost:3000/item_lists/1", "http://localhost:3000/catalog/cooee/items/1-013")
         
         itemlist = factory.get_item_list("http://localhost:3000/item_lists/1")
         hit = itemlist["num_items"]
         compare = 4
         self.assertEqual(hit, compare, "expected the itemlist to have %s items" % str(compare))
         
         hit = itemlist["items"]
         compare = "http://localhost:3000/catalog/cooee/items/1-010"
         self.assertIn(compare, hit, "expected '%s' to be in the items" % compare)
         
         hit = itemlist["items"]
         compare = "http://localhost:3000/catalog/cooee/items/1-015"
         self.assertNotIn(compare, hit, "expected '%s' not to be in the items" % compare)
Ejemplo n.º 16
0
    def test_4_add_items(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)
            factory.create_item_list("http://localhost:3000/item_lists/1",
                                     "first item list", "shared")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-010")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-011")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-012")
            factory.add_to_item_list(
                "http://localhost:3000/item_lists/1",
                "http://localhost:3000/catalog/cooee/items/1-013")

            itemlist = factory.get_item_list(
                "http://localhost:3000/item_lists/1")
            hit = itemlist["num_items"]
            compare = 4
            self.assertEqual(
                hit, compare,
                "expected the itemlist to have %s items" % str(compare))

            hit = itemlist["items"]
            compare = "http://localhost:3000/catalog/cooee/items/1-010"
            self.assertIn(compare, hit,
                          "expected '%s' to be in the items" % compare)

            hit = itemlist["items"]
            compare = "http://localhost:3000/catalog/cooee/items/1-015"
            self.assertNotIn(compare, hit,
                             "expected '%s' not to be in the items" % compare)