tests.api package

Contents

tests.api package#

Submodules#

tests.api.test_endpoints module#

Module for tests for application api endpoints.

Classes:

SetUpChatEndpointTestCase WebSocketTestCase

class tests.api.test_endpoints.ApplicationBackendStartupAndShutdownFunctionsTest(methodName='runTest')[source]#

Bases: IsolatedAsyncioTestCase

Test case class for testing functions called during start up and shut down of backend.

setUp()[source]#

Hook method for setting up the test fixture before exercising it.

classmethod setUpClass()[source]#

Hook method for setting up class fixture before running tests in the class.

tearDown()[source]#

Hook method for deconstructing the test fixture after testing it.

async test_close_apache_kafka_producer_calls_close_on_the_server_AIOKafkaProducer_object() None[source]#

Test that function to close server Apache Kafka Producer (in this case AIOKafkaProducer) closes the server producer AIOKafkaProducer object.

Returns:

None

async test_close_apache_kafka_producer_triggers_warning_when_supplied_fastapi_application_instance_has_no_kafka_producer_state_attribute()[source]#

Test that functon to close server Apache Kafka Producer triggers a warning in the case that there is no kafka producer state attribute on the passed fastapi application argument. :return: None

async test_start_apache_kafka_producer_does_not_recreate_another_producer_on_the_same_instance_of_fastapi() None[source]#

Test that function to start apache kafka producer does not create more than one for a single fastapi app instance.

Returns:

None

test_start_apache_kafka_producer_sets_fastapi_app_kafka_producer_attribute() None[source]#

Test that function to start apache kafka producer sets the fastapi state kafka_producer attribute.

Returns:

None

async test_start_apache_kafka_producer_starts_AIOKafkaProducer_with_expected_argument_for_boostrap_servers() None[source]#

Test that function to start apache kafka producer starts AIOKafkaProducer with expected values. :return: None

test_start_apache_kafka_producer_starts_the_kafka_producer() None[source]#

Test that function to start apache kafka producer calls .start() on the AIOKafkaProducer object. :return: None

test_start_apache_kafka_producer_takes_a_fastapi_object_argument(mocked_start_apache_kafka_producer: Mock) None[source]#

Test that function to start apache kafka producer takes FastAPI app instance argument.

Parameters:

mocked_start_apache_kafka_producer – Mocked start_apache_kafka_producer() object.

Returns:

None

class tests.api.test_endpoints.ApplicationBackendStartupAndShutdownTest(methodName='runTest')[source]#

Bases: IsolatedAsyncioTestCase

Test case class for application backend lifecycle.

setUp()[source]#

Hook method for setting up the test fixture before exercising it.

async test_kafka_producer_for_chat_end_point_starts_at_startup(mocked_start_apache_kafka_producer: Mock) None[source]#

Test that apache kafka producer is started at backend startup.

Parameters:

mocked_start_apache_kafka_producer – Mocked function to start apache kafka producer

Returns:

None

class tests.api.test_endpoints.SetUpChatEndpointTestCase(methodName='runTest')[source]#

Bases: BaseTestDatabaseTestCase

Test case class for end point setting up chat.

classmethod setUpClass()[source]#

Hook method for setting up class fixture before running tests in the class.

test_endpoint_creates_kafka_topic_for_the_chat_before_returning_response_on_successful_function_call() None[source]#

Test that endpoint calls function to create kafka topic before returning a response. :return: None

test_endpoint_creates_new_application_controller_for_chat_session(*_) None[source]#

Test that endpoint creates application controller. :return: None

test_endpoint_creates_new_chat_uuid_in_database_chats_table(*_) None[source]#

Test that request to endpoint creates new unique UUID record in test database :return: None

test_endpoint_does_not_create_new_application_controller_if_there_is_a_failure_to_create_kafka_topic(mocked_application_controller: Mock) None[source]#

Test that endpoint does not create application controller in the event that creation of kafka topic was unsuccessful. :return: None

test_endpoint_only_takes_post_requests(*_) None[source]#

Test that the endpoint only takes post request. :return: None

test_endpoint_redirect_url_matches_that_of_the_expected_chat_url(*_) None[source]#

Test that URL redirected to from endpoint matches expected chat url :return: None

test_endpoint_returns_redirect_response_pointing_to_the_url_for_the_chat(*_) None[source]#

Test that response to endpoint is a redirect request which points to the URL for the chat. :return: None

test_endpoint_returns_server_error_on_exception_from_function_to_create_kafka_topic() None[source]#

Test that endpoints returns with server error in the event that there is a failure (characterised by an exception while creating the kafka topic). :return: None

test_endpoint_takes_request_json_body_of_expected_type() None[source]#

Test that endpoint takes json request body of expected type (currently SetUpChatRequestBody) :return: None

class tests.api.test_endpoints.WebSocketTestCase(methodName='runTest')[source]#

Bases: BaseTestDatabaseTestCase

Test case class for application web socket tests.

classmethod setUpClass()[source]#

Hook method for setting up class fixture before running tests in the class.

test_that_connection_to_invalid_chat_websocket_url_cannot_be_established() None[source]#

Test that connection establishment with invalid chat web socket url cannot be established. The web socket connection route must pass validation checks.

Returns:

None

Module contents#