def test_system_module(): with clean_es(): id = create_input("DIT IS EEN TEST") assert_raises(ValueError, errortask, id) systemtask(id) d = systemtask.get_result(id) assert_equal(d.text, "dit is een test") id = create_input("Nog een test") systemtask_postprocess(id) d = systemtask_postprocess.get_result(id) assert_equal(d.text, "NOG EEN TEST (postprocessed)")
def test_module(): with clean_es(): id = create_input("Dit is een Test") uppertask(id) d = uppertask.get_result(id) assert_equal(d.text, "DIT IS EEN TEST") assert_equal(d.pipeline[0]["module"], "test_module.uppertask") assert_equal(d.pipeline[0]["version"], "0.1") doclowertask(id) d = doclowertask.get_result(id) assert_equal(d.text, "dit is een test")
def test_get_results(): with clean_es(): id, id2 = create_input(text="Een test"), create_input(text="Nog een test") doc_type = "TEST" assert_raises(NotFoundError, backend.get_document, id, doc_type) assert_equal([], list(dict(backend.get_cached_documents([id, id2], doc_type)).keys())) backend.store_result(doc_type, id, [{"module": "TEST"}], "test result") backend._es.indices.flush() d2 = backend.get_document(id, doc_type) assert_equal(d2.pipeline, [{"module": "TEST"}]) assert_equal(d2.text, "test result") assert_equal([id], list(dict(backend.get_cached_documents([id, id2], doc_type)).keys())) assert_equal(1, dict(backend.count_cached([id, id2]))[doc_type])
def test_get_input(): with clean_es(): id = create_input(text="Een test") d = backend.get_input(id) assert_equal(d.text, "Een test") assert_equal(d.id, id)