예제 #1
0
 def test_1_empty_database(self):
     for method in self.methods:
         factory = ItemListFactory(method, self.basedir)
         self.prepare(factory)
         
         hit = factory.get_item_lists()
         compare = {"shared":[], "own":[]}
         self.assertEqual(hit, compare, "expected no item lists")
예제 #2
0
    def test_1_empty_database(self):
        for method in self.methods:
            factory = ItemListFactory(method, self.basedir)
            self.prepare(factory)

            hit = factory.get_item_lists()
            compare = {"shared": [], "own": []}
            self.assertEqual(hit, compare, "expected no item lists")
예제 #3
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))
예제 #4
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))
예제 #5
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))
예제 #6
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))
예제 #7
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)
예제 #8
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)
예제 #9
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))
예제 #10
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))
예제 #11
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)
예제 #12
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)
예제 #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))
예제 #14
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)
예제 #15
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))
예제 #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)
예제 #17
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)
예제 #18
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)
예제 #19
0
# -*- coding: utf-8 -*-

from bottle import Bottle, request, abort, response, jinja2_view as view, static_file
from alveolocal import API
import json
import os
from alveolocal.itemlist import ItemListFactory

application = Bottle()
alveo = API()
TEST_DATA = os.path.join(os.path.dirname(__file__), "..", "tests", "data")
factory = ItemListFactory("rdf", os.path.join(TEST_DATA, "itemlists"))


@application.get('/static/<path:path>')
def static_files(path):
    return static_file(path, root='./static')


@application.get('/')
@view('home')
def home():
    temp_col = alveo.get_collections()
    collections = {}
    for collection in temp_col:
        collections[alveo.get_collection(collection)
                    ['collection_name']] = collection
    itemlists = factory.get_item_lists()
    return {'collections': collections, 'itemlists': itemlists}