Skip to content

Commit

Permalink
Merge pull request #1125 from ocefpaf/replace_httpretty
Browse files Browse the repository at this point in the history
Replace httpretty
  • Loading branch information
ocefpaf authored Nov 21, 2024
2 parents c1d0eed + 5c56994 commit 7d62f4f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:


- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
rev: v0.7.4
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down
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
2 changes: 1 addition & 1 deletion test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
codecov
codespell
flake8
httpretty
mocket
mypy
myst-parser
numpydoc
Expand Down

0 comments on commit 7d62f4f

Please sign in to comment.