Skip to content

Commit

Permalink
fix: Failing test for getting custom fields (nautobot#114)
Browse files Browse the repository at this point in the history
Attempt to fix test cases `AppCustomFieldsTestCase` and
`AppCustomFieldChoicesTestCase`.
  • Loading branch information
nautics889 committed Apr 16, 2023
1 parent 69ef638 commit 562f17e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ def test_custom_fields(self, session_get_mock):
choices = api.extras.custom_fields()

session_get_mock.assert_called_once()
expect_url = f"{api.base_url}/extras/custom-fields/"
url_passed_in_args = expect_url in session_get_mock.call_args.args
url_passed_in_kwargs = expect_url == session_get_mock.call_args.kwargs.get("url")
expect_location = f"/custom-fields"
url_passed_in_args = url_passed_in_kwargs = False
if session_get_mock.call_args.args:
url_passed_in_args = expect_location in session_get_mock.call_args.args[0]
else:
url_passed_in_kwargs = expect_location in session_get_mock.call_args.kwargs.get("url", "")
self.assertTrue(url_passed_in_args or url_passed_in_kwargs)

self.assertIsInstance(choices, list)
Expand All @@ -46,9 +49,12 @@ def test_custom_field_choices(self, session_get_mock):
choices = api.extras.custom_field_choices()

session_get_mock.assert_called_once()
expect_url = f"{api.base_url}/extras/custom-field-choices/"
url_passed_in_args = expect_url in session_get_mock.call_args.args
url_passed_in_kwargs = expect_url == session_get_mock.call_args.kwargs.get("url")
expect_location = f"/custom-field-choices"
url_passed_in_args = url_passed_in_kwargs = False
if session_get_mock.call_args.args:
url_passed_in_args = expect_location in session_get_mock.call_args.args[0]
else:
url_passed_in_kwargs = expect_location in session_get_mock.call_args.kwargs.get("url", "")
self.assertTrue(url_passed_in_args or url_passed_in_kwargs)

self.assertIsInstance(choices, list)
Expand Down

0 comments on commit 562f17e

Please sign in to comment.