Skip to content
Snippets Groups Projects
Unverified Commit 885ac295 authored by Duncan Macleod's avatar Duncan Macleod
Browse files

tests: fix usage of called_with mocks

need to properly use `assert_called_with` for Python 3.12
parent f535e7b3
No related branches found
No related tags found
No related merge requests found
Pipeline #584076 passed
......@@ -125,7 +125,10 @@ def test_ping(mping):
)
out = StringIO()
main.ping(args, out)
assert mping.called_with(host=args.server)
mping.assert_called_with(
host=args.server,
ext=args.extension,
)
out.seek(0)
assert out.read().rstrip() == (
'LDRDataFindServer at test.datafind.com:443 is alive')
......@@ -142,7 +145,11 @@ def test_show_observatories(mfindobs):
out = StringIO()
main.show_observatories(args, out)
out.seek(0)
assert mfindobs.called_with(host=args.server, match=args.match)
mfindobs.assert_called_with(
host=args.server,
match=args.match,
ext=args.extension,
)
assert list(map(str.rstrip, out.readlines())) == ['A', 'B', 'C']
......@@ -158,8 +165,12 @@ def test_show_types(mfindtypes):
out = StringIO()
main.show_types(args, out)
out.seek(0)
assert mfindtypes.called_with(host=args.server, match=args.match,
site=args.observatory)
mfindtypes.assert_called_with(
host=args.server,
match=args.match,
site=args.observatory,
ext=args.extension,
)
assert list(map(str.rstrip, out.readlines())) == ['A', 'B', 'C']
......@@ -176,9 +187,14 @@ def test_show_times(mfindtimes):
)
out = StringIO()
main.show_times(args, out)
assert mfindtimes.called_with(host=args.server, site=args.observatory,
frametype=args.type, gpsstart=args.gpsstart,
gpsend=args.gpsend)
mfindtimes.assert_called_with(
host=args.server,
site=args.observatory,
frametype=args.type,
gpsstart=args.gpsstart,
gpsend=args.gpsend,
ext=args.extension,
)
out.seek(0)
for i, line in enumerate(out.readlines()[1:]):
seg = mfindtimes.return_value[i]
......@@ -199,9 +215,14 @@ def test_latest(mlatest):
)
out = StringIO()
main.latest(args, out)
assert mlatest.called_with(args.observatory, args.type,
urltype=args.url_type, on_missing='warn',
host=args.server)
mlatest.assert_called_with(
args.observatory,
args.type,
urltype=args.url_type,
on_missing='warn',
host=args.server,
ext=args.extension,
)
out.seek(0)
assert out.read().rstrip() == mlatest.return_value[0]
......@@ -219,8 +240,12 @@ def test_filename(mfindurl):
)
out = StringIO()
main.filename(args, out)
assert mfindurl.called_with(args.filename, urltype=args.url_type,
on_missing='warn', host=args.server)
mfindurl.assert_called_with(
args.filename,
urltype=args.url_type,
on_missing='warn',
host=args.server,
)
out.seek(0)
assert out.read().rstrip() == mfindurl.return_value[0]
......@@ -247,7 +272,7 @@ def test_show_urls(mfindurls, ext):
)
out = StringIO()
main.show_urls(args, out)
assert mfindurls.called_with(
mfindurls.assert_called_with(
args.observatory,
args.type,
args.gpsstart,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment