From da1781646ac77fef54756b45b4290e80a5393d81 Mon Sep 17 00:00:00 2001 From: BeritJanssen Date: Thu, 26 Oct 2023 11:53:19 +0200 Subject: [PATCH] fix tests --- backend/download/create_csv.py | 11 ++--------- backend/download/tests/test_download_views.py | 6 +++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/backend/download/create_csv.py b/backend/download/create_csv.py index 6298d8e80..b807f7f10 100644 --- a/backend/download/create_csv.py +++ b/backend/download/create_csv.py @@ -102,20 +102,13 @@ def format_field_value(value, unit): } return date.strftime(formats[unit]) -def ngram_csv(results, parameters): +def ngram_csv(results, log_id): rows = ngram_table(results) fieldnames = ['date', 'N-gram', 'Frequency'] - filename = ngram_filename(parameters) + filename = create_filename(log_id) filepath = write_file(filename, fieldnames, rows) return filepath -def ngram_filename(parameters): - query_string = get_query_text(parameters['es_query']) - timestamp = datetime.now().isoformat(sep='_', timespec='minutes') # ensure csv filenames are unique with timestamp - suffix = '_' + timestamp + '.csv' - description = 'ngram_{}_{}'.format(query_string, suffix) - return create_filename(description, suffix) - def ngram_table(results): rows = [] for index, time_point in enumerate(results['time_points']): diff --git a/backend/download/tests/test_download_views.py b/backend/download/tests/test_download_views.py index cfecb1aa9..42607a238 100644 --- a/backend/download/tests/test_download_views.py +++ b/backend/download/tests/test_download_views.py @@ -6,7 +6,7 @@ from download import SEARCH_RESULTS_DIALECT from addcorpus.models import Corpus import io -from visualization.query import MATCH_ALL +from visualization import query from es.search import hits from tag.models import Tag, TaggedDocument @@ -172,7 +172,7 @@ def test_csv_download_view(admin_client, finished_download): def some_document_id(admin_client, small_mock_corpus, index_small_mock_corpus): search_response = admin_client.post( f'/api/es/{small_mock_corpus}/_search', - {'es_query': MATCH_ALL}, + {'es_query': query.MATCH_ALL}, content_type='application/json' ) @@ -200,7 +200,7 @@ def test_download_with_tag(db, admin_client, small_mock_corpus, index_small_mock encoding = 'utf-8' download_request_json = { 'corpus': small_mock_corpus, - 'es_query': MATCH_ALL, + 'es_query': query.MATCH_ALL, 'tags': [tag_on_some_document.id], 'fields': ['date','content'], 'size': 3,