Skip to content

Commit c418470

Browse files
committed
Revert "Revert "Fix broken test cases by adding an is_empty function""
This reverts commit b446a59.
1 parent aacf1ee commit c418470

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

aikido_zen/background_process/cloud_connection_manager/update_firewall_lists_test.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,15 @@ def test_update_firewall_lists_no_token(connection_manager):
141141
connection_manager.token = None
142142
update_firewall_lists(connection_manager)
143143
# No changes should be made, so we check the initial state
144-
assert len(connection_manager.conf.bypassed_ips.blocked_subnets) == 0
145-
assert len(connection_manager.conf.bypassed_ips.blocked_addresses) == 0
144+
assert connection_manager.conf.bypassed_ips.is_empty()
146145

147146

148147
def test_update_firewall_lists_serverless(connection_manager):
149148
# Set serverless to True
150149
connection_manager.serverless = True
151150
update_firewall_lists(connection_manager)
152151
# No changes should be made, so we check the initial state
153-
assert len(connection_manager.conf.bypassed_ips.blocked_subnets) == 0
154-
assert len(connection_manager.conf.bypassed_ips.blocked_addresses) == 0
152+
assert connection_manager.conf.bypassed_ips.is_empty()
155153

156154

157155
def test_update_firewall_lists_api_failure(connection_manager):
@@ -163,8 +161,7 @@ def fetch_firewall_lists(self, token):
163161
connection_manager.api = FailingApi()
164162
update_firewall_lists(connection_manager)
165163
# No changes should be made, so we check the initial state
166-
assert len(connection_manager.conf.bypassed_ips.blocked_subnets) == 0
167-
assert len(connection_manager.conf.bypassed_ips.blocked_addresses) == 0
164+
assert connection_manager.conf.bypassed_ips.is_empty()
168165

169166

170167
def test_update_firewall_lists_exception_handling(connection_manager):
@@ -176,5 +173,4 @@ def fetch_firewall_lists(self, token):
176173
connection_manager.api = ExceptionApi()
177174
update_firewall_lists(connection_manager)
178175
# No changes should be made, so we check the initial state
179-
assert len(connection_manager.conf.bypassed_ips.blocked_subnets) == 0
180-
assert len(connection_manager.conf.bypassed_ips.blocked_addresses) == 0
176+
assert connection_manager.conf.bypassed_ips.is_empty()

aikido_zen/helpers/ip_matcher/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ def add(self, network):
4242
return self
4343
self.sorted.insert(idx, net)
4444
return self
45+
46+
def is_empty(self):
47+
return len(self.sorted) == 0

0 commit comments

Comments
 (0)