tests.utils.functions package

Contents

tests.utils.functions package#

Submodules#

tests.utils.functions.test_functions module#

Module for tests on utility functions.

This module contains test cases for testing the functions module in the utilities package and all related functionality to the function module.

Classes:

TestCreateMessageJSON TestGenerateMessage TestAddChat

class tests.utils.functions.test_functions.TestAddChat(methodName='runTest')[source]#

Bases: BaseTestDatabaseTestCase

Test case class for tests on function for adding Chat to database

test_function_adds_new_chat_record_to_database() None[source]#

Test that function adds new chat record to database.

Returns:

None

test_function_takes_session_argument() None[source]#

Test that function takes in session argument, this argument is used internally by the function to pick a database to operate on. :return: None

class tests.utils.functions.test_functions.TestCreateApacheKafkaTopic(methodName='runTest')[source]#

Bases: TestCase

Test case class for tests on function for calling Apache Kafka topic.

setUp()[source]#

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

tearDown()[source]#

Hook method for deconstructing the test fixture after testing it.

test_function_calls_subprocess_popen_to_create_topic() None[source]#

Test function calls subprocess.Popen to run command to create new kafka topic. :return: None

test_function_raises_exception_if_fastapi_application_kafka_zookeeper_is_not_available() None[source]#

Test that function raises RuntimeError if FastAPI application instance does not have Apache Kafka Zookeeper started successfully. :return: None

test_function_raises_exception_if_kafka_topic_was_not_created_successfully() None[source]#

Test function raises RuntimeError in the event that creation of kafka topic was not successful. :return: None

test_function_raises_value_error_on_invalid_inputs() None[source]#

Test that function raises ValueError on invalid input for topic title and fastapi_application :return: None

test_function_takes_topic_argument() None[source]#

Test that function takes 2 arguments: 1. topic name/title. 2. fastapi application instance :return: None

class tests.utils.functions.test_functions.TestCreateMessageJSON(methodName='runTest')[source]#

Bases: TestCase

Test case class for tests on function for creating user message JSON object. Here, “User” may refer to user.User or any comparable user entity existing outside this code base.

More importantly, the emphasis here is on the message from the user. This can be either generated from User.generate_message or received at the websocket (for example fastapi.Websocket.receive_json()

test_function_returns_json_object_when_called_with_required_arguments() None[source]#

Test that return value of function is a JSON object. :return: None

class tests.utils.functions.test_functions.TestGenerateMessage(methodName='runTest')[source]#

Bases: TestCase

Test case class for tests on function for generating message.

classmethod setUpClass()[source]#

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

test_function_calls_User_generate_message_method_once_during_function_call() None[source]#

Test that User’s generate_message method was called during execution of function as it is the function that generates the message content for the user. :return: None

test_function_return_type_is_of_expected_json_type() None[source]#

Test that the function returns a result of expected type. :return: None

test_function_returns_message_json_with_different_context_id_from_passed_context_id_if_parent_id_is_None() None[source]#

Test that function returns message json with context_id different to that of passed context_id if parent_id is None. :return: None

test_function_returns_message_json_with_same_context_id_from_passed_context_id_if_parent_id_is_not_None() None[source]#

Test that function returns message json with same context_id as passed context_id if parent_id is not None :return: None

test_function_takes_User_object_argument_where_the_passed_object_must_already_be_instantiated() None[source]#

Test that the function takes User object argument which must have already been instantiated. :return: None

test_function_takes_other_other_arguments_including_instantiated_user_object_to_populate_return_value() None[source]#

Test that function takes arguments as well as instantiated User object to populate return value. :return: None

Module contents#