Skip to content

Commit

Permalink
Verify that the set_ports() method works.
Browse files Browse the repository at this point in the history
This can be flakey, because we're working with sets but then asserting that things happen in a specific order. That should get resolved.
  • Loading branch information
tonyandrewmeyer committed Sep 20, 2023
1 parent 79edca1 commit 1e35640
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3406,6 +3406,30 @@ def test_opened_ports_warnings(self):
['opened-ports', ''],
])

def test_set_ports(self):
fake_script(self, 'open-port', 'exit 0')
fake_script(self, 'close-port', 'exit 0')
fake_script(self, 'opened-ports', 'exit 0')
self.unit.set_ports(8000, 8025)
self.assertEqual(fake_script_calls(self, clear=True), [
['opened-ports', ''],
['open-port', '8025/tcp'],
['open-port', '8000/tcp'],
])
fake_script(self, 'opened-ports', 'echo 8025/tcp')
self.unit.set_ports(ops.Port('udp', 8022))
self.assertEqual(fake_script_calls(self, clear=True), [
['opened-ports', ''],
['close-port', '8025/tcp'],
['open-port', '8022/udp'],
])
fake_script(self, 'opened-ports', 'echo 8022/udp')
self.unit.set_ports()
self.assertEqual(fake_script_calls(self, clear=True), [
['opened-ports', ''],
['close-port', '8022/udp'],
])


if __name__ == "__main__":
unittest.main()

0 comments on commit 1e35640

Please sign in to comment.