Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mjschultz committed Sep 17, 2024
1 parent 7b44fb2 commit ebc7f75
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
coverage report --show-missing --fail-under=99.0
- name: Lint with flake8
run: |
flake8 .
flake8 gcp_flowlogs_reader tests
- name: Check formatting with black
if: "matrix.python-version == '3.8'"
run: |
Expand Down
1 change: 0 additions & 1 deletion gcp_flowlogs_reader/gcp_flowlogs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def safe_tuple_from_dict(cls, attrs):
return cls(**attr_payload)



class FlowRecord:
src_ip: Union[IPv4Address, IPv6Address]
src_port: int
Expand Down
42 changes: 35 additions & 7 deletions tests/test_gcp_flowlogs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,23 @@ def test_init_outbound(self):
('rtt_msec', 61),
('reporter', 'DEST'),
('src_instance', None),
('dest_instance', safe_tuple_from_dict(InstanceDetails, SAMPLE_PAYLOADS[0]['dest_instance'])),
(
'dest_instance',
safe_tuple_from_dict(
InstanceDetails, SAMPLE_PAYLOADS[0]['dest_instance']
),
),
('src_vpc', None),
('dest_vpc', safe_tuple_from_dict(VpcDetails, SAMPLE_PAYLOADS[0]['dest_vpc'])),
('src_location', safe_tuple_from_dict(GeographicDetails, SAMPLE_PAYLOADS[0]['src_location'])),
(
'dest_vpc',
safe_tuple_from_dict(VpcDetails, SAMPLE_PAYLOADS[0]['dest_vpc']),
),
(
'src_location',
safe_tuple_from_dict(
GeographicDetails, SAMPLE_PAYLOADS[0]['src_location']
),
),
('dest_location', None),
]:
with self.subTest(attr=attr):
Expand All @@ -249,12 +262,25 @@ def test_init_inbound(self):
('packets_sent', 6),
('rtt_msec', None),
('reporter', 'SRC'),
('src_instance', safe_tuple_from_dict(InstanceDetails, SAMPLE_PAYLOADS[1]['src_instance'])),
(
'src_instance',
safe_tuple_from_dict(
InstanceDetails, SAMPLE_PAYLOADS[1]['src_instance']
),
),
('dest_instance', None),
('src_vpc', safe_tuple_from_dict(VpcDetails, SAMPLE_PAYLOADS[1]['src_vpc'])),
(
'src_vpc',
safe_tuple_from_dict(VpcDetails, SAMPLE_PAYLOADS[1]['src_vpc']),
),
('dest_vpc', None),
('src_location', None),
('dest_location', safe_tuple_from_dict(GeographicDetails, SAMPLE_PAYLOADS[1]['dest_location'])),
(
'dest_location',
safe_tuple_from_dict(
GeographicDetails, SAMPLE_PAYLOADS[1]['dest_location']
),
),
]:
with self.subTest(attr=attr):
actual = getattr(flow_record, attr)
Expand Down Expand Up @@ -322,7 +348,9 @@ def test_to_dict(self):
with self.subTest(attr=attr):
actual = flow_dict[attr]
if isinstance(expected, dict):
expected = {k: v for k, v in expected.items() if k != 'subnetwork_region'}
expected = {
k: v for k, v in expected.items() if k != 'subnetwork_region'
}
self.assertEqual(actual, expected)

def test_from_payload(self):
Expand Down

0 comments on commit ebc7f75

Please sign in to comment.