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_raises_exception_when_chat_context_is_an_empty_string() None[source]#

Test that function raises exception if the chat context is essentially an empty string.

test_function_raises_exception_when_chat_title_is_an_empty_string() None[source]#

Test that function raises exception if the chat title is essentially an empty string.

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.

property randomly_generated_kafka_test_topic: str#

Generate random kafka topic string :return: String topic name

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.

test_function_creates_kafka_topic() None[source]#

Test function creates kafka topic with given name. :return: None

test_function_displays_warning_in_the_event_topic_to_be_created_already_exists() None[source]#

Test function raises warning in the event that topic to be created has already been created and the augmented topic is created. :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 1 argument: 1. topic name/title. :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#