diff --git a/tests/test_dates.py b/tests/test_dates.py index ad4a82544..ba5f553e7 100644 --- a/tests/test_dates.py +++ b/tests/test_dates.py @@ -16,6 +16,8 @@ is_before, is_after, is_between, + date_to_float, + month_to_int ) TEST_DATE = date(2019, 6, 15) @@ -36,10 +38,6 @@ def test_month_to_str(input, expected): assert month_to_str_int(input) == expected -import datetime -from regolith.dates import date_to_float, month_to_int - - @pytest.mark.parametrize( "input,expected", [ diff --git a/tests/test_helpers.py b/tests/test_helpers.py index ed963bfc7..db82d53bc 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1163,10 +1163,10 @@ # "--grants", "mrsec14", "dmref15", "--payee", "ashaaban", # "--where", "bank", "--begin-date", "2020-06-20", "--end-date", "2020-06-25"], # "2006as_timbuktoo has been added in expenses\n"), - ## The following Test Cases A-D test adding presentation-related expenses and map to user stories for Issue #910. All except one are commented out - ## because the current testing architecture (1) limits our ability to validate the addition of more than one entry to a collection, and - ## (2) only spins up one test database, but two would be needed to test a different destination database for expense data. The hope is - ## that, in the future when the test architecture is improved or changed, these commented-out tests can be useful and enable fully testing the added functionality. + # The following Test Cases A-D test adding presentation-related expenses and map to user stories for Issue #910. All except one are commented out + # because the current testing architecture (1) limits our ability to validate the addition of more than one entry to a collection, and + # (2) only spins up one test database, but two would be needed to test a different destination database for expense data. The hope is + # that, in the future when the test architecture is improved or changed, these commented-out tests can be useful and enable fully testing the added functionality. # Test Case A: Expect a new entry in outputs/presentations/presentations.yaml # (["helper", "a_presentation", "flat earth", "Mars", "2020-06-26", "2020-06-26", # "--type", "contributed_oral", "--person", "ashaaban", "--grants", "mrsec14", @@ -1334,7 +1334,7 @@ def test_helpers_bad(hmb, make_db): repo = Path(make_db) os.chdir(repo) with pytest.raises(hmb[2]) as excinfo: - actual = main(args=hmb[0]) + main(args=hmb[0]) assert str(excinfo.value) == hmb[1] @@ -1388,7 +1388,6 @@ def test_helper_python(hm, make_db, db_src, make_mongodb, capsys, mocker): @pytest.mark.parametrize("hm", helper_map_loose) def test_helper_python_loose(hm, make_db, capsys): repo = Path(make_db) - testfile = Path(__file__) os.chdir(repo) main(args=hm[0]) diff --git a/tests/test_tools.py b/tests/test_tools.py index 433c6d6db..c85fa466d 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1,13 +1,7 @@ -from copy import copy - import habanero import pytest import datetime as dt -import uuid - import copy -import requests -from unittest import mock import requests_mock from regolith.runcontrol import DEFAULT_RC @@ -208,7 +202,8 @@ def test_get_person_contact(input, expected): "ackno": "thanks", "grant": "fwp2", "month": "jun", - "note": "\\newline\\newline\\noindent Acknowledgement:\\newline\\noindent thanks\\newline\\newline\\noindent ", + "note": "\\newline\\newline\\noindent Acknowledgement:\\newline\\noindent thanks" + "\\newline\\newline\\noindent ", "year": "2020", }, { @@ -216,7 +211,8 @@ def test_get_person_contact(input, expected): "author": ["m1", "palin"], "ackno": "thanks", "grant": "fwp2", - "note": "\\newline\\newline\\noindent Acknowledgement:\\newline\\noindent thanks\\newline\\newline\\noindent ", + "note": "\\newline\\newline\\noindent Acknowledgement:\\newline\\noindent thanks" + "\\newline\\newline\\noindent ", "year": "2020", }, { @@ -225,7 +221,8 @@ def test_get_person_contact(input, expected): "author": ["m1", "cleese"], "grant": "fwp, dmref", "month": "apr", - "note": "\\newline\\newline\\noindent Acknowledgement:\\newline\\noindent thanks\\newline\\newline\\noindent ", + "note": "\\newline\\newline\\noindent Acknowledgement:\\newline\\noindent thanks" + "\\newline\\newline\\noindent ", "year": "2021", }, ], @@ -2570,7 +2567,7 @@ def test_group_member_employment_start_end(person, grpname, expected): try: actual = group_member_employment_start_end(person, grpname) assert actual == expected - except: + except RuntimeError: with pytest.raises(RuntimeError) as excinfo: actual = group_member_employment_start_end(person, grpname) assert str(excinfo.value) == expected @@ -2591,7 +2588,7 @@ def test_remove_duplicate_docs(inp, expected): try: actual = remove_duplicate_docs(inp, "dupe_key") assert actual == expected - except: + except RuntimeError: with pytest.raises(RuntimeError) as excinfo: actual = remove_duplicate_docs(inp, "dupe_key") assert str(excinfo.value) == expected @@ -3143,8 +3140,9 @@ def test_get_target_token(tokens, expected): actual = get_target_token("gitlab_private_token", tokens) assert actual == expected - # @mock.patch("requests.post") + + @requests_mock.Mocker(kw="mock") def test_create_repo(**kwargs): kwargs["mock"].post("https://example.com/url/example", status_code=201) @@ -3166,7 +3164,9 @@ def test_create_repo(**kwargs): actual = create_repo("talk_repo", "gitlab_private_token", rc) assert ( actual - == "repo 2206_my_talk has been created at https://example.com.\nClone this to your local using (HTTPS):\ngit clone https://example.com:/2206_my_talk.git\nor (SSH):\ngit clone git@example.com:/2206_my_talk.git" + == "repo 2206_my_talk has been created at https://example.com.\nClone this to your local using " + "(HTTPS):\ngit clone https://example.com:/2206_my_talk.git\nor " + "(SSH):\ngit clone git@example.com:/2206_my_talk.git" )