Skip to content

Commit

Permalink
mark tests for testing only with mongodb; fix duplicate names
Browse files Browse the repository at this point in the history
  • Loading branch information
ikondov committed May 24, 2024
1 parent de7bd67 commit 378b055
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions fireworks/scripts/tests/test_lpad_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def lp(capsys):
lp.reset(password=None, require_password=False)


@pytest.mark.mongodb
@pytest.mark.parametrize(("detail", "expected_1", "expected_2"), [("count", "0\n", "1\n"), ("ids", "[]\n", "1\n")])
def test_lpad_get_fws(capsys, lp, detail, expected_1, expected_2) -> None:
"""Test lpad CLI get_fws command."""
Expand Down
11 changes: 10 additions & 1 deletion fireworks/user_objects/firetasks/tests/test_filepad_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def setUp(self) -> None:
self.identifiers = ["write", "delete"]
self.fp = FilePad.auto_load()

@pytest.mark.mongodb
def test_addfilestask_run(self) -> None:
t = AddFilesTask(paths=self.paths, identifiers=self.identifiers)
t.run_task({})
Expand All @@ -43,6 +44,7 @@ def test_deletefilestask_run(self) -> None:
assert file_contents is None
assert doc is None

@pytest.mark.mongodb
def test_getfilestask_run(self) -> None:
t = AddFilesTask(paths=self.paths, identifiers=self.identifiers)
t.run_task({})
Expand All @@ -56,6 +58,7 @@ def test_getfilestask_run(self) -> None:
assert write_file_contents == f.read().encode()
os.remove(os.path.join(dest_dir, new_file_names[0]))

@pytest.mark.mongodb
def test_getfilesbyquerytask_run(self) -> None:
"""Tests querying objects from FilePad by metadata."""
t = AddFilesTask(paths=self.paths, identifiers=self.identifiers, metadata={"key": "value"})
Expand All @@ -69,7 +72,8 @@ def test_getfilesbyquerytask_run(self) -> None:
assert test_file_contents == file.read().encode()
os.remove(os.path.join(dest_dir, new_file_names[0]))

def test_getfilesbyquerytask_run(self) -> None:
@pytest.mark.mongodb
def test_getfilesbyquerytask_run_some_identifier(self) -> None:
"""Tests querying objects from FilePad by metadata."""
with open("original_test_file.txt", "w") as f:
f.write("Some file with some content")
Expand All @@ -87,6 +91,7 @@ def test_getfilesbyquerytask_run(self) -> None:
assert test_file_contents == f.read().encode()
os.remove(os.path.join(dest_dir, "queried_test_file.txt"))

@pytest.mark.mongodb
def test_getfilesbyquerytask_metafile_run(self) -> None:
"""Tests writing metadata to a yaml file."""
with open("original_test_file.txt", "w") as f:
Expand Down Expand Up @@ -138,6 +143,7 @@ def test_getfilesbyquerytask_raise_empty_result_run(self) -> None:
t.run_task({})
# test successful if exception raised

@pytest.mark.mongodb
def test_getfilesbyquerytask_ignore_degenerate_file_name(self) -> None:
"""Tests on ignoring degenerate file name in result from FilePad query."""
with open("degenerate_file.txt", "w") as f:
Expand Down Expand Up @@ -179,6 +185,7 @@ def test_getfilesbyquerytask_raise_degenerate_file_name(self) -> None:
t.run_task({})
# test successful if exception raised

@pytest.mark.mongodb
def test_getfilesbyquerytask_sort_ascending_name_run(self) -> None:
"""Tests on sorting queried files in ascending order."""
file_contents = ["Some file with some content", "Some other file with some other content"]
Expand Down Expand Up @@ -209,6 +216,7 @@ def test_getfilesbyquerytask_sort_ascending_name_run(self) -> None:
with open("degenerate_file.txt") as f:
assert file_contents[-1] == f.read()

@pytest.mark.mongodb
def test_getfilesbyquerytask_sort_descending_name_run(self) -> None:
"""Tests on sorting queried files in descending order."""
file_contents = ["Some file with some content", "Some other file with some other content"]
Expand Down Expand Up @@ -244,6 +252,7 @@ def test_getfilesbyquerytask_sort_descending_name_run(self) -> None:

os.remove("degenerate_file.txt")

@pytest.mark.mongodb
def test_addfilesfrompatterntask_run(self) -> None:
t = AddFilesTask(paths="*.yaml", directory=module_dir)
t.run_task({})
Expand Down

0 comments on commit 378b055

Please sign in to comment.