Esempio n. 1
0
def test_fetch_Entity(monkeypatch, fx_session, fx_celery_app):

    class FakeQuery(object):
        offset = 0

        def convert(self):
            with open(os.path.join(os.path.dirname(__file__),
                      'select_class_with_revision.json')) as fp:
                offset = FakeQuery.offset
                fakeResult = (json.load(fp))[offset:offset+100:]
                FakeQuery.offset += 100
                return {"results": {"bindings": fakeResult}}

    monkeypatch.setattr("SPARQLWrapper.SPARQLWrapper.query", FakeQuery)

    dbpedia.fetch_classes(1, Entity, [
        'dbpedia-owl:Cartoon',
        'dbpedia-owl:MovieDirector',
        'dbpedia-owl:Producer',
        'dbpedia-owl:TheatreDirector',
        'dbpedia-owl:TelevisionDirector',
        'dbpedia-owl:TelevisionPersonality'
    ])

    assert fx_session.query(Entity).count() > 0
Esempio n. 2
0
def test_fetch_Work(monkeypatch, fx_session, fx_celery_app):
    class FakeQuery(object):
        offset = 0

        def convert(self):
            with open(
                    os.path.join(os.path.dirname(__file__),
                                 'fetch_work.json')) as fp:
                offset = FakeQuery.offset
                fakeResult = (json.load(fp))[offset:offset + 100:]
                FakeQuery.offset += 100
                return {"results": {"bindings": fakeResult}}

    monkeypatch.setattr("SPARQLWrapper.SPARQLWrapper.query", FakeQuery)

    dbpedia.fetch_classes(1, Work, ['dbpedia-owl:Work'])
    assert fx_session.query(Work).count() > 0
Esempio n. 3
0
def test_fetch_Work(monkeypatch, fx_session, fx_celery_app):

    class FakeQuery(object):
        offset = 0

        def convert(self):
            with open(os.path.join(os.path.dirname(__file__),
                      'fetch_work.json')) as fp:
                offset = FakeQuery.offset
                fakeResult = (json.load(fp))[offset:offset+100:]
                FakeQuery.offset += 100
                return {"results": {"bindings": fakeResult}}

    monkeypatch.setattr("SPARQLWrapper.SPARQLWrapper.query", FakeQuery)

    dbpedia.fetch_classes(1, Work, ['dbpedia-owl:Work'])
    assert fx_session.query(Work).count() > 0
Esempio n. 4
0
def test_fetch_Entity(monkeypatch, fx_session, fx_celery_app):
    class FakeQuery(object):
        offset = 0

        def convert(self):
            with open(
                    os.path.join(os.path.dirname(__file__),
                                 'select_class_with_revision.json')) as fp:
                offset = FakeQuery.offset
                fakeResult = (json.load(fp))[offset:offset + 100:]
                FakeQuery.offset += 100
                return {"results": {"bindings": fakeResult}}

    monkeypatch.setattr("SPARQLWrapper.SPARQLWrapper.query", FakeQuery)

    dbpedia.fetch_classes(1, Entity, [
        'dbpedia-owl:Cartoon', 'dbpedia-owl:MovieDirector',
        'dbpedia-owl:Producer', 'dbpedia-owl:TheatreDirector',
        'dbpedia-owl:TelevisionDirector', 'dbpedia-owl:TelevisionPersonality'
    ])

    assert fx_session.query(Entity).count() > 0