Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsaxon committed Apr 10, 2020
1 parent aa3e947 commit c1d5625
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 2 additions & 0 deletions zeroconf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,7 @@ def enqueue_callback(state_change: ServiceStateChange, name: str) -> None:
return

if self._handlers_to_call.count([name, ServiceStateChange.Added]) == 1:
warnings.warn("not adding update as adding", DeprecationWarning)
return

if self._handlers_to_call.count([name, ServiceStateChange.Updated]) == 1:
Expand All @@ -1453,6 +1454,7 @@ def enqueue_callback(state_change: ServiceStateChange, name: str) -> None:
self._handlers_to_call.remove([name, ServiceStateChange.Removed])

if self._handlers_to_call.count([name, ServiceStateChange.Updated]) == 1:
warnings.warn("removing update as adding", DeprecationWarning)
self._handlers_to_call.remove([name, ServiceStateChange.Updated])

if self._handlers_to_call.count([name, ServiceStateChange.Added]) == 1:
Expand Down
13 changes: 1 addition & 12 deletions zeroconf/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,8 +1124,7 @@ def mock_incoming_msg(service_state_change: r.ServiceStateChange) -> r.DNSIncomi
service_browser = r.ServiceBrowser(zeroconf, service_type, listener=MyServiceListener())

try:
wait_time = 1
wait_time_2 = 1
wait_time = 2

# service added
zeroconf.handle_response(mock_incoming_msg(r.ServiceStateChange.Added))
Expand All @@ -1134,8 +1133,6 @@ def mock_incoming_msg(service_state_change: r.ServiceStateChange) -> r.DNSIncomi
assert service_updated_count == 0
assert service_removed_count == 0

time.sleep(wait_time_2)

# service SRV updated
service_updated_event.clear()
service_server = 'ash-2.local.'
Expand All @@ -1145,8 +1142,6 @@ def mock_incoming_msg(service_state_change: r.ServiceStateChange) -> r.DNSIncomi
assert service_updated_count == 1
assert service_removed_count == 0

time.sleep(wait_time_2)

# service TXT updated
service_updated_event.clear()
service_text = b'path=/~matt2/'
Expand All @@ -1156,8 +1151,6 @@ def mock_incoming_msg(service_state_change: r.ServiceStateChange) -> r.DNSIncomi
assert service_updated_count == 2
assert service_removed_count == 0

time.sleep(wait_time_2)

# service A updated
service_updated_event.clear()
service_address = '10.0.1.3'
Expand All @@ -1167,8 +1160,6 @@ def mock_incoming_msg(service_state_change: r.ServiceStateChange) -> r.DNSIncomi
assert service_updated_count == 3
assert service_removed_count == 0

time.sleep(wait_time_2)

# service all updated
service_updated_event.clear()
service_server = 'ash-3.local.'
Expand All @@ -1180,8 +1171,6 @@ def mock_incoming_msg(service_state_change: r.ServiceStateChange) -> r.DNSIncomi
assert service_updated_count == 4
assert service_removed_count == 0

time.sleep(wait_time_2)

# service removed
zeroconf.handle_response(mock_incoming_msg(r.ServiceStateChange.Removed))
service_removed_event.wait(wait_time)
Expand Down

0 comments on commit c1d5625

Please sign in to comment.