def test_should_not_complain_upon_instantiating_heartbeat_events(self): Event( 'target-name', { 'id': 'heartbeat', 'type': 'event', 'target': 'dev12', 'tracking_id': None, 'payload': None })
def test_should_return_description_of_command_without_message(self): event = Event('target-name', { 'id': 'cmd', 'cmd': 'command', 'state': 'state' }) self.assertEqual( '(broadcaster) target[target-name] command "command" state.', str(event))
def test_should_return_description_of_heartbeat(self): event = Event( 'target-name', { 'id': 'heartbeat', 'type': 'event', 'target': 'target-name', 'tracking_id': None, 'payload': None }) self.assertEqual('Heartbeat on target-name', str(event))
def test_should_return_description_of_request(self): event = Event('target-name', { 'id': 'request', 'cmd': 'command', 'args': 'arg1 arg2 arg3' }) self.assertEqual( 'target[target-name] requested command "command" using arguments "arg1 arg2 arg3"', str(event))
def test_should_return_description_of_a_service_change(self): event = Event( 'target-name', { 'id': 'service-change', 'payload': [{ 'uri': 'service://host/test-service', 'state': 'up' }] }) self.assertEqual( 'target[target-name] services changed: service://host/test-service is up', str(event))
def test_should_return_description_of_multiple_service_changes(self): event = Event( 'target-name', { 'id': 'service-change', 'payload': [{ 'uri': 'spam', 'state': 'up' }, { 'uri': 'eggs', 'state': 'down' }] }) self.assertEqual( str(event), 'target[target-name] services changed: spam is up, eggs is down')
def test_should_create_event_with_target_from_payload_if_possible(self): event = Event(None, {"id": "any-id", "target": "any-target"}) self.assertEqual(event.target, "any-target")
def test_should_create_event_without_target(self): event = Event(None, {"id": "any-id"}) self.assertEqual(event.target, None)
def test_should_create_event_with_target(self): event = Event("any-target", {"id": "any-id"}) self.assertEqual(event.target, "any-target")
def test_should_return_description_of_full_update(self): event = Event('target-name', {'id': 'full-update'}) self.assertEqual( 'target[target-name] full update of status information.', str(event))
def test_should_return_description_of_call_info(self): event = Event('target-name', {'id': 'call-info', 'target': 'foo'}) self.assertEqual('Call info from target target-name', str(event))
def test_should_return_description_of_vote(self): event = Event('target-name', {'id': 'vote', 'payload': 42}) self.assertEqual('Vote with value 42', str(event))
def test_should_not_raise_exception_when_event_type_unknown(self): unknown_type_data = {'id': 'spameggs'} Event('target-name', unknown_type_data)