Skip to content

Commit

Permalink
fix(tests): simplify;
Browse files Browse the repository at this point in the history
- Simplify test with specific file suffix check.
  • Loading branch information
JVickery-TBS committed Dec 9, 2024
1 parent d1eef74 commit b9f71c7
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions ckanext/xloader/tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ def data(create_with_upload, apikey):
@pytest.mark.ckan_config("ckan.jobs.timeout", 15)
class TestXLoaderJobs(helpers.FunctionalRQTestBase):

@classmethod
def setup_method(self, method):
"""Method is called at class level before EACH test methods of the class are called.
Setup any state specific to the execution of the given class methods.
"""
for f in _get_temp_files():
os.remove(f)

def test_xloader_data_into_datastore(self, cli, data):
self.enqueue(jobs.xloader_data_into_datastore, [data])
with mock.patch("ckanext.xloader.jobs.get_response", get_response):
Expand Down Expand Up @@ -146,13 +138,14 @@ def test_data_max_excerpt_lines_config(self, cli, data):
assert resource["datastore_contains_all_records_of_source_file"] is False

def test_data_with_rq_job_timeout(self, cli, data):
assert len(_get_temp_files()) == 0
file_suffix = 'multiplication_2.csv'
self.enqueue(jobs.xloader_data_into_datastore, [data], rq_kwargs=dict(timeout=15))
with mock.patch("ckanext.xloader.jobs.get_response", get_large_data_response):
stdout = cli.invoke(ckan, ["jobs", "worker", "--burst"]).output
assert "Job timed out after" in stdout
assert len(_get_temp_files()) == 0

for f in _get_temp_files():
# make sure that the tmp file has been closed/deleted in job timeout exception handling
assert file_suffix not in f


@pytest.mark.usefixtures("clean_db")
Expand Down

0 comments on commit b9f71c7

Please sign in to comment.