Skip to content

Commit

Permalink
Fix firewall unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
yhaliaw committed Jan 31, 2024
1 parent 131c214 commit 44a39a9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def test__refresh_firewall(monkeypatch, harness: Harness, runner_binary_path: Pa
act: when refresh_firewall is called.
assert: the unit ip addresses are included in allowlist.
"""
monkeypatch.setattr("charm.Firewall", mock_firewall := unittest.mock.MagicMock())

runner_binary_path.touch()

Expand Down Expand Up @@ -229,9 +228,9 @@ def test__refresh_firewall(monkeypatch, harness: Harness, runner_binary_path: Pa
},
)

monkeypatch.setattr("charm.Firewall", mock_firewall := unittest.mock.MagicMock())
harness.charm._refresh_firewall()
mocked_firewall_instance = mock_firewall.return_value

allowlist = mocked_firewall_instance.refresh_firewall.call_args_list[0][1]["allowlist"]
assert all(
FirewallEntry(ip) in allowlist for ip in test_unit_ip_addresses
Expand Down

0 comments on commit 44a39a9

Please sign in to comment.