Skip to content

Commit

Permalink
replace httpretty with mocket
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Nov 21, 2024
1 parent c1d0eed commit 0de2d1d
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions compliance_checker/tests/test_ioos_sos.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import unittest

import httpretty
from mocket.mocket import mocketize
from mocket.mockhttp import Entry

from compliance_checker.runner import ComplianceChecker
from compliance_checker.suite import CheckSuite
Expand All @@ -21,20 +22,20 @@ def setUp(self):
# classes will show up
CheckSuite().load_all_available_checkers()

@httpretty.activate
@mocketize
def test_retrieve_getcaps(self):
"""Method that simulates retrieving SOS GetCapabilities"""
url = "http://data.oceansmap.com/thredds/sos/caricoos_ag/VIA/VIA.ncml"
httpretty.register_uri(
httpretty.GET,
url,
content_type="text/xml",
Entry.single_register(
method=Entry.GET,
uri=url,
body=self.resp,
headers={"content-type": "text/xml"},
)
httpretty.register_uri(
httpretty.HEAD,
Entry.single_register(
Entry.HEAD,
url,
content_type="text/xml",
headers={"content-type": "text/xml"},
body="HTTP/1.1 200",
)
ComplianceChecker.run_checker(url, ["ioos_sos"], 1, "normal")
Expand All @@ -53,7 +54,7 @@ def setUp(self):
# classes will show up
CheckSuite().load_all_available_checkers()

@httpretty.activate
@mocketize
def test_retrieve_describesensor(self):
"""Method that simulates retrieving SOS DescribeSensor"""
url = (
Expand All @@ -64,17 +65,17 @@ def test_retrieve_describesensor(self):
"&outputFormat=text/xml%3Bsubtype%3D%22sensorML/1.0.1/profiles/ioos_sos/1.0%22"
"&version=1.0.0"
)
httpretty.register_uri(
httpretty.GET,
url,
content_type="text/xml",
Entry.single_register(
method=Entry.GET,
uri=url,
body=self.resp,
headers={"content-type": "text/xml"},
)
httpretty.register_uri(
httpretty.HEAD,
url,
content_type="text/xml",
Entry.single_register(
method=Entry.HEAD,
uri=url,
body="HTTP/1.1 200",
headers={"content-type": "text/xml"},
)
# need to mock out the HEAD response so that compliance checker
# recognizes this as some sort of XML doc instead of an OPeNDAP
Expand Down

0 comments on commit 0de2d1d

Please sign in to comment.