From c6d9e6ebb04ad014df3d096e1ba6329510ac531d Mon Sep 17 00:00:00 2001 From: Daoud Clarke Date: Tue, 10 Oct 2023 20:18:43 +0100 Subject: [PATCH] Fix some paths, use prod settings in Dockerfile --- .github/workflows/ci.yml | 4 +++- Dockerfile | 4 +--- test/test_completer.py | 24 ++++++++++++++++-------- test/test_indexer.py | 4 +++- test/test_update_urls.py | 2 +- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee07639..2d35915 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,5 +53,7 @@ jobs: # run test suite #---------------------------------------------- - name: Run tests + env: + DJANGO_SETTINGS_MODULE: mwmbl.settings_dev run: | - poetry run pytest \ No newline at end of file + poetry run pytest diff --git a/Dockerfile b/Dockerfile index 4283a14..5163e67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,8 +46,6 @@ VOLUME ["/data"] EXPOSE 5000 -ENV DJANGO_SETTINGS_MODULE=mwmbl.settings_dev +ENV DJANGO_SETTINGS_MODULE=mwmbl.settings_prod -# WORKDIR "/venv/lib/python3.10/site-packages/mwmbl/" -# CMD ["/venv/bin/python", "-m", "uvicorn", "app.asgi:application"] CMD ["/venv/bin/mwmbl-tinysearchengine"] diff --git a/test/test_completer.py b/test/test_completer.py index 8867f26..e9612a3 100644 --- a/test/test_completer.py +++ b/test/test_completer.py @@ -1,10 +1,14 @@ import pandas as pd +from mwmbl import tinysearchengine +from mwmbl.tinysearchengine.completer import Completer + def mockCompleterData(mocker, data): testDataFrame = pd.DataFrame(data, columns=['','term','count']) mocker.patch('mwmbl.tinysearchengine.completer.Completer.get_terms', return_value = testDataFrame) + def test_correctCompletions(mocker): # Mock completer with custom data testdata = [ @@ -14,10 +18,11 @@ def test_correctCompletions(mocker): [3, 'buildings', 1]] mockCompleterData(mocker, testdata) - completer = app.tinysearchengine.completer.Completer() + completer = Completer() completion = completer.complete('build') assert ['build', 'builder', 'buildings'] == completion + def test_correctSortOrder(mocker): # Mock completer with custom data testdata = [ @@ -27,10 +32,11 @@ def test_correctSortOrder(mocker): [3, 'buildings', 3]] mockCompleterData(mocker, testdata) - completer = app.tinysearchengine.completer.Completer() + completer = Completer() completion = completer.complete('build') assert ['build', 'buildings', 'builder'] == completion - + + def test_noCompletions(mocker): # Mock completer with custom data testdata = [ @@ -40,10 +46,11 @@ def test_noCompletions(mocker): [3, 'buildings', 1]] mockCompleterData(mocker, testdata) - completer = app.tinysearchengine.completer.Completer() + completer = Completer() completion = completer.complete('test') assert [] == completion - + + def test_singleCompletions(mocker): # Mock completer with custom data testdata = [ @@ -53,10 +60,11 @@ def test_singleCompletions(mocker): [3, 'buildings', 1]] mockCompleterData(mocker, testdata) - completer = app.tinysearchengine.completer.Completer() + completer = Completer() completion = completer.complete('announce') assert ['announce'] == completion - + + def test_idempotencyWithSameScoreCompletions(mocker): # Mock completer with custom data testdata = [ @@ -66,7 +74,7 @@ def test_idempotencyWithSameScoreCompletions(mocker): [3, 'buildings', 1]] mockCompleterData(mocker, testdata) - completer = app.tinysearchengine.completer.Completer() + completer = Completer() for i in range(3): print(f"iteration: {i}") completion = completer.complete('build') diff --git a/test/test_indexer.py b/test/test_indexer.py index cf714c0..6c1705f 100644 --- a/test/test_indexer.py +++ b/test/test_indexer.py @@ -1,9 +1,11 @@ from pathlib import Path from tempfile import TemporaryDirectory -from mwmbl.tinysearchengine import Document, TinyIndex, _binary_search_fitting_size, astuple, _trim_items_to_page, _get_page_data, _pad_to_page_size from zstandard import ZstdCompressor +from mwmbl.tinysearchengine.indexer import TinyIndex, Document, _binary_search_fitting_size, astuple, \ + _trim_items_to_page, _pad_to_page_size, _get_page_data + def test_create_index(): num_pages = 10 diff --git a/test/test_update_urls.py b/test/test_update_urls.py index 089caea..8f205f8 100644 --- a/test/test_update_urls.py +++ b/test/test_update_urls.py @@ -1,4 +1,4 @@ -from mwmbl.indexer import process_link +from mwmbl.indexer.update_urls import process_link def test_process_link_normal():