Пример #1
0
class TestAlveolocalLoad(unittest.TestCase):

    def setUp(self):
        
        self.api = API()
        
        
    def test_attach_directory(self):
        """we can attach a directory containing RDF files"""
        
        # check the number of triples loaded
        self.assertEqual(7628, self.api.attach_directory(TEST_DATA))


    def test_version(self):
        """we return the right version string"""
        
        
        self.assertEqual("V2.0", self.api.version())
Пример #2
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}

Пример #3
0
 def setUp(self):
     
     self.api = API()
     self.api.attach_directory(TEST_DATA)
Пример #4
0
class TestAlveolocal(unittest.TestCase):

    def setUp(self):
        
        self.api = API()
        self.api.attach_directory(TEST_DATA)


    def test_item_base_url(self):
        """generating the right url for an item"""
        
        itemuri = "http://*****:*****@context', ann)
        
        self.assertEqual(2, len(ann['alveo:annotations']))
        
        self.assertEqual('dada:TextAnnotation', ann['alveo:annotations'][0]['@type'])
        
        self.assertEqual(docurl, ann['commonProperties']['alveo:annotates'])
        
        ann = self.api.get_annotations(itemuri, {"user":"******"})
        ann = self.api.get_annotations(itemuri, {"priorTo":datetime.strptime("2013-12-20T12:20:00", '%Y-%m-%dT%I:%M:%S')})
        
        pass

    def test_search(self):
        """we can search for items"""
        
        query = (('dc:created', '1788'), )
        
        items = self.api.search(query)
        
        self.assertEqual(5, len(items))
        self.assertIn('http://localhost:3000/catalog/cooee/items/1-011', items)

        query = (('dc:created', '1788'), ('cooee:texttype', 'Private Correspondence'))
        items = self.api.search(query)
        
        self.assertEqual(4, len(items))
        self.assertNotIn('http://localhost:3000/catalog/cooee/items/1-013', items)
        self.assertIn('http://localhost:3000/catalog/cooee/items/1-011', items)
        
    def test_search_sparql(self):
        
        query = "select * where {?s <http://purl.org/dc/terms/isPartOf> ?o}"
        collection_name = "cooee"
        result = self.api.search_sparql(collection_name, query)
        
        self.assertIsInstance(result, dict, "Expected dict, got %s" % type(result))
        for key in result.keys():
            self.assertIn(key, ["head", "results"], "Expected %s to be one of the items in the list" % key)
        self.assertIn("vars", result["head"], "Expected to include vars")
        self.assertIn("bindings", result["results"], "Expected to include bindings")
        for binding in result["results"]["bindings"]:
            for var in result["head"]["vars"]:
                self.assertIn(var, binding, "Expected all bindings to include items in vars")
        
    def tearDown(self):
        pass
Пример #5
0
 def setUp(self):
     
     self.api = API()
Пример #6
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}
    
@application.get('/version')
@view('version')
def version():