Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace httpretty #1125

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading