Skip to content

Commit

Permalink
Rewrite mock call tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mixxorz committed Jul 31, 2022
1 parent 015568a commit 6fc57ac
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,23 +262,16 @@ def test_settings_preference_order(
# Check that the correct order of settings is used
self.assertEqual(4, mock_cli_settings.initialize.call_count)

# Nothing is passed
self.assertEqual(
mock_cli_settings.initialize.mock_calls[0].kwargs,
{"debug": False, "url": ""},
)
# DATABASE_URL is present so use that
self.assertEqual(
mock_cli_settings.initialize.mock_calls[1].kwargs,
{"debug": False, "url": "postgres://envvar:pw@test:5432/my_db"},
)
# TOML is present, so use that over DATABASE_URL
self.assertEqual(
mock_cli_settings.initialize.mock_calls[2].kwargs,
{"debug": False, "url": "postgres://toml:pw@test:5432/my_db"},
)
# --url is present, so use that over everything
self.assertEqual(
mock_cli_settings.initialize.mock_calls[3].kwargs,
{"debug": False, "url": "postgres://cli:pw@test:5432/my_db"},
mock_cli_settings.initialize.call_args_list,
[
# Nothing is passed
mock.call(debug=False, url=""),
# DATABASE_URL is present so use that
mock.call(debug=False, url="postgres://envvar:pw@test:5432/my_db"),
# TOML is present, so use that over DATABASE_URL
mock.call(debug=False, url="postgres://toml:pw@test:5432/my_db"),
# --url is present, so use that over everything
mock.call(debug=False, url="postgres://cli:pw@test:5432/my_db"),
],
)

0 comments on commit 6fc57ac

Please sign in to comment.