|
@@ 141-155 (lines=15) @@
|
| 138 |
|
|
| 139 |
|
assert response.data == b"Flow does not exist" |
| 140 |
|
|
| 141 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_from_id") |
| 142 |
|
def test_bytes_count(self, mock_from_flow): |
| 143 |
|
"""Test bytes_count rest call.""" |
| 144 |
|
flow_id = '1' |
| 145 |
|
dpid_id = '1' |
| 146 |
|
mock_from_flow.return_value = self._get_mocked_flow_base() |
| 147 |
|
|
| 148 |
|
rest_name = "bytes_count" |
| 149 |
|
self._patch_switch_flow(flow_id) |
| 150 |
|
|
| 151 |
|
response = self._get_rest_response(rest_name, dpid_id) |
| 152 |
|
json_response = json.loads(response.data) |
| 153 |
|
assert json_response["flow_id"] == flow_id |
| 154 |
|
assert json_response["bytes_counter"] == 10 |
| 155 |
|
assert json_response["bits_per_second"] == 4.0 |
| 156 |
|
|
| 157 |
|
def test_packet_count_per_flow__empty(self): |
| 158 |
|
"""Test packet_count rest call with a flow that does not exist .""" |
|
@@ 117-131 (lines=15) @@
|
| 114 |
|
|
| 115 |
|
assert response.data == b"Flow does not exist" |
| 116 |
|
|
| 117 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_from_id") |
| 118 |
|
def test_packet_count(self, mock_from_flow): |
| 119 |
|
"""Test packet_count rest call.""" |
| 120 |
|
flow_id = '1' |
| 121 |
|
dpid_id = '1' |
| 122 |
|
mock_from_flow.return_value = self._get_mocked_flow_base() |
| 123 |
|
|
| 124 |
|
rest_name = "packet_count" |
| 125 |
|
self._patch_switch_flow(flow_id) |
| 126 |
|
|
| 127 |
|
response = self._get_rest_response(rest_name, dpid_id) |
| 128 |
|
json_response = json.loads(response.data) |
| 129 |
|
assert json_response["flow_id"] == flow_id |
| 130 |
|
assert json_response["packet_counter"] == 40 |
| 131 |
|
assert json_response["packet_per_second"] == 2.0 |
| 132 |
|
|
| 133 |
|
def test_bytes_count__fail(self): |
| 134 |
|
"""Test bytes_count rest call with wrong flow_id.""" |