Skip to content

Commit

Permalink
feat: Add tests for packet loss
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Gomena committed Nov 8, 2020
1 parent dfc6777 commit b46bcef
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,47 @@ def test_success_half_success(self):
'Unable to calculate success on all with half responses successful'
)

def test_no_packets_lost(self):
rs = executor.ResponseList([
SuccessfulResponseMock(None, 1),
SuccessfulResponseMock(None, 1),
SuccessfulResponseMock(None, 1),
SuccessfulResponseMock(None, 1)
])

self.assertEqual(
rs.packet_loss,
0.0,
"Unable to calculate packet loss correctly when all resposes successful"
)

def test_all_packets_lost(self):
rs = executor.ResponseList([
FailingResponseMock(None, 1),
FailingResponseMock(None, 1),
FailingResponseMock(None, 1),
FailingResponseMock(None, 1)
])

self.assertEqual(
rs.packet_loss,
1.0,
"Unable to calculate packet loss correctly when all resposes failed"
)

def test_some_packets_lost(self):
rs = executor.ResponseList([
SuccessfulResponseMock(None, 1),
SuccessfulResponseMock(None, 1),
FailingResponseMock(None, 1),
FailingResponseMock(None, 1)
])

self.assertEqual(
rs.packet_loss,
0.5,
"Unable to calculate packet loss correctly when some of the responses failed"
)

class CommunicatorTestCase(unittest.TestCase):
"""Tests for Communicator"""
Expand Down

0 comments on commit b46bcef

Please sign in to comment.