alarms.tests package

Submodules

alarms.tests.factories module

class alarms.tests.factories.AlarmFactory

Bases: object

Factory to create random alarms based on Alarm model. Consider that the alarms are not saved in any database

ack = False

Acknowledgement status of the Alarm

classmethod build()
core_timestamp = 1556051403101

Core timestamp of the Alarm to be created

classmethod get_alarm_with_all_optional_fields()

Return a valid alarm with values for all the optional fields

classmethod get_invalid_alarm(core_id=None)

Returns a invalid Alarm

Args:
core_id (string): optional argument to specify the core_id of the Alarm to be returned
Returns:
alarm (Alarm): an instance of a invalid Alarm
classmethod get_modified_alarm(alarm)

Return the alarm with the value, core_timestamp and mode modified randomly

classmethod get_valid_alarm(core_id=None)

Returns a valid Alarm

Args:
core_id (string): optional argument to specify the core_id of the Alarm to be returned
Returns:
alarm (Alarm): an instance of a valid Alarm
mode = 0

Operational Mode of the Alarm to be created

sequence = 0
shelved = False

Shelved status of the Alarm

validity = 0

Validity of the Alarm to be created

value = 2

Value of the Alarm to be created

alarms.tests.tests_broadcast module

class alarms.tests.tests_broadcast.TestPeriodicBroadcastCase

Bases: object

This class defines the test suite for periodic notification of changes to consumer clients

create_communicator(**kwargs)

Auxiliary method to manage a token query string authentication

test_broadcast_status()

Test that the periodic request is sent and Alarms are invalidated after timeout

alarms.tests.tests_client_consumer_connect module

class alarms.tests.tests_client_consumer_connect.TestConnectionToClientConsumer

Bases: object

This class defines the test suite for the connection to the ClientConsumer

create_communicator(**kwargs)

Auxiliary method to manage a token query string authentication

test_connection_allowed_using_a_valid_password()

Test if clients can request the connection using a password

test_connection_allowed_using_a_valid_token_query_string()

Test if clients can request the connection using a token

test_connection_not_allowed_for_an_invalid_password()

Test the connection can not be allowed with an invalid password

test_connection_not_allowed_for_an_invalid_token()

Test the connection can not be allowed with an invalid token

test_connection_not_allowed_without_a_token_query_string()

Test the connection can not be allowed without token data

alarms.tests.tests_client_consumer_notify module

class alarms.tests.tests_client_consumer_notify.FakeCoroutine

Bases: object

cancelled()
done()
class alarms.tests.tests_client_consumer_notify.TestNotificationsToClientConsumer

Bases: object

This class defines the test suite for the notification of changes to the ClientConsumer

build_alarms()
create_communicator(**kwargs)

Auxiliary method to manage a token query string authentication

test_update(mocker)

Test if clients are notified when an alarm is created

alarms.tests.tests_client_consumer_request module

class alarms.tests.tests_client_consumer_request.TestRequestsToClientConsumer

Bases: object

This class defines the test suite for the requests messages to the ClientConsumer

create_communicator(**kwargs)

Auxiliary method to manage a token query string authentication

test_alarms_list()

Test if clients can request and receive a list of alarms

test_alarms_list_validity()

Test if clients receive a list of alarms with updated validity

test_close_connection_action()

Test if clients can close the connection to the ws using a request

test_unsupported_action()

Test if clients receive ‘Unsupported action’ when action is not ‘list’

alarms.tests.tests_collections module

class alarms.tests.tests_collections.TestAlarmsCollectionAcknowledge

Bases: object

This class defines the test suite for the Alarms Collection acknowledge and ticket handling

test_ack_multiple_alarms(mocker)

Test if the AlarmCollection can acknowledge multiple Alarms

test_alarm_cycle()

Test the changes in ack property of alarms as it changes through a cycle of values and Ack actions

test_create_tickets(mocker)

Test that AlarmCollection.create_tickets calls TicketConnector.create_tickets

test_new_set_alarm_ticket_is_updated_when_cleared()

Test if a ticket is created when a new SET Alarm arrives, and if the ticket is updated to cleared_ack or cleared_unack states accordingly when the Alarm changes to Clear

test_recursive_ack()

Test if the AlarmCollection can acknowledge multiple Alarms recursively

test_recursive_unack()

Test if the AlarmCollection can unacknowledge an alarms and its dependent alarms recursively.

class alarms.tests.tests_collections.TestAlarmsCollectionHandling

Bases: object

This class defines the test suite for the Alarms Collection general handling

test_create_old_alarm()

Test if an new alarm is created and notified to observers even if it is old (UNRELIABLE)

test_get_ancestors_recursively()

Test if the AlarmCollection can retrieve the list of ancestors

test_get_dependencies_recursively()

Test if the AlarmCollection can retrieve the list of dependencies of an alarm including itself

test_ignore_update_for_older_alarm(mocker)

Test if an alarm with an older timestamp is ignored (not updated and not notified)

test_initialize(mocker)

Test the AlarmCollection initialization

test_recalculation_alarms_validity()

Test if the alarms in the AlarmCollection are revalidated

test_record_multiple_parent_references()

Test if when an alarm with dependencies is created, and the alarms in the dependencies already have another parent, it adds itself to the list of parents associated with the alarm in the dependencies

test_record_parent_reference()

Test if when an alarm with dependencies is created, it records itself as a parent of its dependencies

test_update_alarm()

Test if an alarm with a different relevant field (in this case validity) and a timestamp higher than before is updated correctly and notified to observers

test_update_alarm_no_notification(mocker)

Test if an alarm with no different relevant fields and a timestamp higher than before is updated correctly but not notified

class alarms.tests.tests_collections.TestAlarmsCollectionShelve

Bases: object

This class defines the test suite for the Alarms Collection shelve and registry handling

test_alarm_shelving()

Test if an alarm can be shelved and unshelved

test_already_shelved_alarm()

Test if an already shelved alarm cannot be shelved

test_forbid_alarm_shelving()

Test if a non-shelvable alarm cannot be shelved and unshelved

test_no_ticket_for_shelved_alarm(mocker)

Test if tickets are not created for Alarms in shelved status

alarms.tests.tests_collections_aux module

class alarms.tests.tests_collections_aux.TestAlarmsCollectionAux

Bases: object

This class defines the test suite for the Alarms Collection auxiliary functions

test_create_alarm_from_cdb_iasio()

Test the behaviour of the function tohat creates Alarms from IASIOS in the CDB

test_get_core_id_from()

Test if the core_id value is extracted correctly from the full running id field

test_get_templated_core_id_from()

Test if the core_id corresponding to a templated alarm is extracted and cleaned correctly from running id field

alarms.tests.tests_collections_counter_by_view_cases module

class alarms.tests.tests_collections_counter_by_view_cases.TestCountByViewForDependencies

Bases: object

Test suite for selected cases of alarms with dependencies

build_alarms()
set_mock_views_configuration(mocker)
test_count_for_alarm_parent_with_SET_ACK_to_SET_UNACK_transition(mocker)
class alarms.tests.tests_collections_counter_by_view_cases.TestCountByViewForNewAlarms

Bases: object

This class defines the test suite for the alarms count by view for new alarms

The update test cases are new alarms for the following cases: - SET UNACK - SET ACK - CLEAR ACK - CLEAR UNACK

build_alarms()
set_mock_views_configuration(mocker)
test_counter_by_view_update_for_new_CLEAR_ACK_alarms(mocker)
test_counter_by_view_update_for_new_CLEAR_UNACK_alarms(mocker)
test_counter_by_view_update_for_new_SET_ACK_alarms(mocker)
test_counter_by_view_update_for_new_SET_UNACK_alarms(mocker)
class alarms.tests.tests_collections_counter_by_view_cases.TestCountPerViewForAlarmsUpdates

Bases: object

This class defines the test suite for the alarms count per view after an alarm update

The update test cases are: - SET ACK from and to SET UNACK - CLEARED ACK from and to CLEARED UNACK - SET ACK from and to CLEAR ACK - SET UNACK from and to CLEAR UNACK - SET ACK from and to CLEARED UNACK - CLEARED ACK from and to SET UNACK

build_alarms()
set_mock_views_configuration(mocker)
test_CLEARED_ACK_from_and_to_CLEARED_UNACK(mocker)
test_CLEAR_ACK_from_and_to_SET_UNACK(mocker)
test_CLEAR_UNACK_from_and_to_SET_ACK(mocker)
test_SET_ACK_from_and_to_CLEAR_ACK(mocker)
test_SET_ACK_from_and_to_SET_UNACK(mocker)
test_SET_UNACK_from_and_to_CLEAR_UNACK(mocker)

alarms.tests.tests_collections_values module

class alarms.tests.tests_collections_values.TestIasValueUpdates

Bases: object

This class defines the test suite for the Alarms Collection management of IASValues that are not of type Alarm

test_create_and_update_value_to_collection()

Test if the other types of values are added successfully to values_collection

alarms.tests.tests_connectors module

class alarms.tests.tests_connectors.TestCdbConnector(methodName='runTest')

Bases: django.test.testcases.TestCase

This class defines the test suite for the Tickets Connector

test_initialize_ias()

Test that the initialize_ias function can read the refresh rate and tolerance from the CDB

test_read_get_iasios()

Test that the get_iasios function can the correct iasios from the CDB

class alarms.tests.tests_connectors.TestPanelsConnector(methodName='runTest')

Bases: django.test.testcases.TestCase

This class defines the test suite for the Tickets Connector

test_get_alarm_ids_of_alarm_configs(IPanels_get_alarm_ids_of_alarm_configs)

Test that PanelsConnector.get_alarm_ids_of_alarm_configs calls IPanels.get_alarm_ids_of_alarm_configs

test_get_alarms_views_dict_of_alarm_configs(IPanels_get_alarms_views_dict_of_alarm_configs)

Test that PanelsConnector.get_alarm_ids_of_alarm_configs calls IPanels.get_alarms_views_dict_of_alarm_configs

class alarms.tests.tests_connectors.TestTicketConnector(methodName='runTest')

Bases: django.test.testcases.TestCase

This class defines the test suite for the Tickets Connector

test_check_acknowledgement()

Test if the check_acknowledgement return true or false depending if the alarm has open tickets (UNACK or CLEARED_UNACK) or not

test_check_shelve()

Test if the check_shelve return true or false depending if the alarm has opened shelve registries

test_clear_tickets()

Test that the clear_tickets function can clear a ticket

test_create_tickets()

Test that the create_tickets function can create a ticket

alarms.tests.tests_core_consumer module

class alarms.tests.tests_core_consumer.TestCoreConsumer

Bases: object

This class defines the test suite for the CoreConsumer

setup_method()

TestCase setup, executed before each test of the TestCase

test_receive_json()

Test if the core consumer receives the list of iasios and passes it to the AlarmCollection

alarms.tests.tests_core_consumer_connect module

class alarms.tests.tests_core_consumer_connect.TestConnectionToCoreConsumer

Bases: object

This class defines the test suite for the connection to the CoreConsumer

create_communicator(**kwargs)

Auxiliary method to manage a token query string authentication

test_connection_allowed_using_a_valid_password()

Test if clients can request the connection using a password

test_connection_allowed_using_a_valid_token_query_string()

Test if clients can request the connection using a token

test_connection_not_allowed_for_an_invalid_password()

Test the connection can not be allowed with an invalid password

test_connection_not_allowed_for_an_invalid_token()

Test the connection can not be allowed with an invalid token

test_connection_not_allowed_without_a_token_or_password()

Test the connection can not be allowed without token data

alarms.tests.tests_interfaces module

class alarms.tests.tests_interfaces.TestIAlarm(methodName='runTest')

Bases: django.test.testcases.TestCase

This class defines the test suite for the Alarms Connector

test_acknowledge_alarms(AlarmCollection_acknowledge)

Test that IAlarm.acknowledge_alarms calls AlarmCollection.acknowledge

test_get_alarm_ancestors(AlarmCollection_get_ancestors_recursively)

Test that IAlarm.get_alarm_ancestors calls AlarmCollection.get_ancestors_recursively

test_get_alarm_dependencies(AlarmCollection_get_dependencies_recursively)

Test that IAlarm.get_alarm_dependencies calls AlarmCollection.get_dependencies_recursively

test_shelve_alarms(AlarmCollection_shelve)

Test that IAlarm.shelve_alarm calls AlarmCollection.shelve

test_unshelve_alarms(AlarmCollection_unshelve)

Test that IAlarm.unshelve_alarms calls AlarmCollection.unshelve

alarms.tests.tests_models module

class alarms.tests.tests_models.AlarmModelTestCase(methodName='runTest')

Bases: django.test.testcases.TestCase

This class defines the test suite for the Alarm model tests

test_acknowledge_clear_alarms()

Test if a CLEAR alarm can be acknowledged

test_acknowledge_set_alarms()

Test if a SET alarm can be acknowledged

test_alarm_factory()

Test if the alarm factory is creating alarms as expected

test_cannot_shelve_non_shelvable_alarm()

Test if a non-shelvable alarm cannot be shelved

test_ignored_invalid_alarms_update()

Test if the UNREALIABLE alarm keep the validity as UNREALIABLE even if the validity is recalculated before the valid refresh time elapsed

test_ignored_valid_alarm_update()

Test if a RELIABLE alarm keep the validity as RELIABLE if the validity is recalculated before the valid refresh time elapsed

test_shelve_alarm()

Test if an alarm can be shelved

test_unshelve_alarm()

Test if an alarm can be unshelved

test_update_alarm_mode()

Test that an Alarm mode can be updated and its state_change_timestamp is updated accordingly

test_update_alarm_validity()

Test that an Alarm validity can be updated and its state_change_timestamp stays unchanged

test_update_alarm_value()

Test that an Alarm value can be updated and its state_change_timestamp is updated accordingly

test_updated_invalid_alarms()

Test if the alarm validity is changed to UNREALIABLE when the elapsed time is greater than the refresh rate considering a margin error

Module contents