Skip to content

Commit

Permalink
fixes regression bug with EBI Search dump commands, following refacto…
Browse files Browse the repository at this point in the history
…ring for metagenomics exchange. also adds some simple e2e tests for ebisearch dump commands. (#352)
  • Loading branch information
SandyRogers authored May 2, 2024
1 parent c98171c commit 1f2ec72
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 6 deletions.
4 changes: 2 additions & 2 deletions emgapi/management/commands/ebi_search_analysis_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ def handle(self, *args, **options):
analyses: QuerySet = AnalysisJob.objects_dump.available(None)

if not is_full_snapshot:
analyses = AnalysisJob.objects_for_indexing.to_add()
analyses = AnalysisJob.objects_for_ebisearch_indexing.to_add()

removals = AnalysisJob.objects_for_indexing.to_delete()
removals = AnalysisJob.objects_for_ebisearch_indexing.to_delete()

# produce incremental deletion file
deletions_file = pathlib.Path(output_dir) / pathlib.Path('analyses-deletes.xml')
Expand Down
4 changes: 2 additions & 2 deletions emgapi/management/commands/ebi_search_study_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def handle(self, *args, **options):
studies: QuerySet = Study.objects.available(None)

if not is_full_snapshot:
studies = Study.objects_for_indexing.to_add()
studies = Study.objects_for_ebisearch_indexing.to_add()

removals = Study.objects_for_indexing.to_delete()
removals = Study.objects_for_ebisearch_indexing.to_delete()

# produce incremental deletion file
deletions_file = pathlib.Path(output_dir) / pathlib.Path('projects-deletes.xml')
Expand Down
2 changes: 1 addition & 1 deletion emgcli/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__: str = "2.4.45"
__version__: str = "2.4.46"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ max-line-length = 119
"""

[tool.bumpversion]
current_version = "2.4.45"
current_version = "2.4.46"

[[tool.bumpversion.files]]
filename = "emgcli/__init__.py"
48 changes: 48 additions & 0 deletions tests/external_indexing_services/test_ebisearch_dump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os

import pytest
from django.core.management import call_command

from test_utils.emg_fixtures import * # noqa

@pytest.mark.django_db(transaction=True)
@pytest.mark.usefixtures("experiment_type")
class TestEbiSearchDump:
def test_dump_studies(self, sample):
"""Test ebi search dump studies"""
call_command(
"ebi_search_study_dump", "-o", f"/tmp/emg_dump_studies",
)
assert os.path.exists(f"/tmp/emg_dump_studies/projects.xml")
assert os.path.isfile(f"/tmp/emg_dump_studies/projects.xml")
assert os.path.exists(f"/tmp/emg_dump_studies/projects-deletes.xml")
assert os.path.isfile(f"/tmp/emg_dump_studies/projects-deletes.xml")

with open(f"/tmp/emg_dump_studies/projects.xml") as f:
dump = f.read()
assert "MGYS00001234" in dump
assert "<entry_count>1</entry_count>" in dump

with open(f"/tmp/emg_dump_studies/projects-deletes.xml") as f:
dump = f.readlines()
assert len(dump) == 5 # i.e. no entries within the xml

def test_dump_analyses(self, run_v5):
"""Test ebi search dump analyses"""
call_command(
"ebi_search_analysis_dump", "-o", f"/tmp/emg_dump_analyses",
)
assert os.path.exists(f"/tmp/emg_dump_analyses/analyses_0001.xml")
assert os.path.isfile(f"/tmp/emg_dump_analyses/analyses_0001.xml")
assert os.path.exists(f"/tmp/emg_dump_analyses/analyses-deletes.xml")
assert os.path.isfile(f"/tmp/emg_dump_analyses/analyses-deletes.xml")

with open(f"/tmp/emg_dump_analyses/analyses_0001.xml") as f:
dump = f.read()
assert "MGYA00001234" in dump
assert "<entry_count>1</entry_count>" in dump

with open(f"/tmp/emg_dump_analyses/analyses-deletes.xml") as f:
dump = f.readlines()
assert len(dump) == 5 # i.e. no entries within the xml

File renamed without changes.

0 comments on commit 1f2ec72

Please sign in to comment.