Skip to content

Commit

Permalink
Merge pull request #248 from metno/issue247_failing_tests
Browse files Browse the repository at this point in the history
#247: use fixture
  • Loading branch information
mortenwh authored Nov 12, 2024
2 parents b0979c6 + ef0bfba commit 05079f7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/test_dist/test_pycsw_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def testDistPyCSW_Run(tmpUUID):


@pytest.mark.dist
def testDistPyCSW_Insert(monkeypatch, mockXml, mockXslt):
def testDistPyCSW_Insert(monkeypatch, mockXml, mockXslt, tmpConf):
"""Test insert commands via run()."""
# Insert returns True
with monkeypatch.context() as mp:
Expand Down Expand Up @@ -91,6 +91,7 @@ def testDistPyCSW_Insert(monkeypatch, mockXml, mockXslt):
mp.setattr(
"dmci.distributors.pycsw_dist.requests.post", causeException)
tstPyCSW = PyCSWDist("insert", xml_file=mockXml)
tstPyCSW._conf = tmpConf
assert tstPyCSW.run() == (
False,
"http://localhost: service unavailable. Failed to insert."
Expand All @@ -100,11 +101,12 @@ def testDistPyCSW_Insert(monkeypatch, mockXml, mockXslt):


@pytest.mark.dist
def testDistPyCSW_Update(monkeypatch, mockXml, mockXslt, tmpUUID):
def testDistPyCSW_Update(monkeypatch, mockXml, mockXslt, tmpUUID, tmpConf):
"""Test update commands via run()."""

tstWorker = Worker("update", None, None)
tstWorker._file_metadata_id = tmpUUID
tstWorker._conf = tmpConf

# Update returns True
with monkeypatch.context() as mp:
Expand Down Expand Up @@ -137,6 +139,7 @@ def testDistPyCSW_Update(monkeypatch, mockXml, mockXslt, tmpUUID):
mp.setattr(
"dmci.distributors.pycsw_dist.requests.post", causeException)
tstPyCSW = PyCSWDist("update", xml_file=mockXml)
tstPyCSW._conf = tmpConf
assert tstPyCSW.run() == (
False,
"http://localhost: service unavailable. Failed to update."
Expand All @@ -146,7 +149,7 @@ def testDistPyCSW_Update(monkeypatch, mockXml, mockXslt, tmpUUID):


@pytest.mark.dist
def testDistPyCSW_Delete(monkeypatch, mockXml, tmpUUID):
def testDistPyCSW_Delete(monkeypatch, mockXml, tmpUUID, tmpConf):
"""Test delete commands via run()."""

assert PyCSWDist("delete").run() == (False, "The run job is invalid")
Expand Down Expand Up @@ -179,8 +182,10 @@ def testDistPyCSW_Delete(monkeypatch, mockXml, tmpUUID):
with monkeypatch.context() as mp:
mp.setattr(
"dmci.distributors.pycsw_dist.requests.post", causeException)
res = PyCSWDist("delete", metadata_UUID=tmpUUID, worker=mockWorker).run()
assert res == (False, "http://localhost: service unavailable. Failed to delete.")
tstPyCSW = PyCSWDist("delete", metadata_UUID=tmpUUID, worker=mockWorker)
tstPyCSW._conf = tmpConf
assert tstPyCSW.run() == (False,
"http://localhost: service unavailable. Failed to delete.")

# END Test testDistPyCSW_Delete

Expand Down

0 comments on commit 05079f7

Please sign in to comment.