Fix some paths, use prod settings in Dockerfile

This commit is contained in:
Daoud Clarke 2023-10-10 20:18:43 +01:00
parent 213bdaa365
commit c6d9e6ebb0
5 changed files with 24 additions and 14 deletions

View file

@ -53,5 +53,7 @@ jobs:
# run test suite # run test suite
#---------------------------------------------- #----------------------------------------------
- name: Run tests - name: Run tests
env:
DJANGO_SETTINGS_MODULE: mwmbl.settings_dev
run: | run: |
poetry run pytest poetry run pytest

View file

@ -46,8 +46,6 @@ VOLUME ["/data"]
EXPOSE 5000 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"] CMD ["/venv/bin/mwmbl-tinysearchengine"]

View file

@ -1,10 +1,14 @@
import pandas as pd import pandas as pd
from mwmbl import tinysearchengine
from mwmbl.tinysearchengine.completer import Completer
def mockCompleterData(mocker, data): def mockCompleterData(mocker, data):
testDataFrame = pd.DataFrame(data, columns=['','term','count']) testDataFrame = pd.DataFrame(data, columns=['','term','count'])
mocker.patch('mwmbl.tinysearchengine.completer.Completer.get_terms', mocker.patch('mwmbl.tinysearchengine.completer.Completer.get_terms',
return_value = testDataFrame) return_value = testDataFrame)
def test_correctCompletions(mocker): def test_correctCompletions(mocker):
# Mock completer with custom data # Mock completer with custom data
testdata = [ testdata = [
@ -14,10 +18,11 @@ def test_correctCompletions(mocker):
[3, 'buildings', 1]] [3, 'buildings', 1]]
mockCompleterData(mocker, testdata) mockCompleterData(mocker, testdata)
completer = app.tinysearchengine.completer.Completer() completer = Completer()
completion = completer.complete('build') completion = completer.complete('build')
assert ['build', 'builder', 'buildings'] == completion assert ['build', 'builder', 'buildings'] == completion
def test_correctSortOrder(mocker): def test_correctSortOrder(mocker):
# Mock completer with custom data # Mock completer with custom data
testdata = [ testdata = [
@ -27,10 +32,11 @@ def test_correctSortOrder(mocker):
[3, 'buildings', 3]] [3, 'buildings', 3]]
mockCompleterData(mocker, testdata) mockCompleterData(mocker, testdata)
completer = app.tinysearchengine.completer.Completer() completer = Completer()
completion = completer.complete('build') completion = completer.complete('build')
assert ['build', 'buildings', 'builder'] == completion assert ['build', 'buildings', 'builder'] == completion
def test_noCompletions(mocker): def test_noCompletions(mocker):
# Mock completer with custom data # Mock completer with custom data
testdata = [ testdata = [
@ -40,10 +46,11 @@ def test_noCompletions(mocker):
[3, 'buildings', 1]] [3, 'buildings', 1]]
mockCompleterData(mocker, testdata) mockCompleterData(mocker, testdata)
completer = app.tinysearchengine.completer.Completer() completer = Completer()
completion = completer.complete('test') completion = completer.complete('test')
assert [] == completion assert [] == completion
def test_singleCompletions(mocker): def test_singleCompletions(mocker):
# Mock completer with custom data # Mock completer with custom data
testdata = [ testdata = [
@ -53,10 +60,11 @@ def test_singleCompletions(mocker):
[3, 'buildings', 1]] [3, 'buildings', 1]]
mockCompleterData(mocker, testdata) mockCompleterData(mocker, testdata)
completer = app.tinysearchengine.completer.Completer() completer = Completer()
completion = completer.complete('announce') completion = completer.complete('announce')
assert ['announce'] == completion assert ['announce'] == completion
def test_idempotencyWithSameScoreCompletions(mocker): def test_idempotencyWithSameScoreCompletions(mocker):
# Mock completer with custom data # Mock completer with custom data
testdata = [ testdata = [
@ -66,7 +74,7 @@ def test_idempotencyWithSameScoreCompletions(mocker):
[3, 'buildings', 1]] [3, 'buildings', 1]]
mockCompleterData(mocker, testdata) mockCompleterData(mocker, testdata)
completer = app.tinysearchengine.completer.Completer() completer = Completer()
for i in range(3): for i in range(3):
print(f"iteration: {i}") print(f"iteration: {i}")
completion = completer.complete('build') completion = completer.complete('build')

View file

@ -1,9 +1,11 @@
from pathlib import Path from pathlib import Path
from tempfile import TemporaryDirectory 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 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(): def test_create_index():
num_pages = 10 num_pages = 10

View file

@ -1,4 +1,4 @@
from mwmbl.indexer import process_link from mwmbl.indexer.update_urls import process_link
def test_process_link_normal(): def test_process_link_normal():