Edit

testing Package

Modules

about
dialog_test_client
dialog_test_logger
storage_base_tests

Base tests that all storage providers should implement in their own tests. They handle the storage-based assertions, internally.

All tests return true if assertions pass to indicate that the code ran to completion, passing internal assertions. Therefore, all tests using theses static tests should strictly check that the method returns true.

Note: Python cannot have dicts with properties with a None value like other SDKs can have properties with null values. Because of this, StoreItem tests have "e_tag: *" where the tests in the other SDKs do not. This has also caused us to comment out some parts of these tests where we assert that "e_tag" is None for the same reason. A null e_tag should work just like a * e_tag when writing, as far as the storage adapters are concerened, so this shouldn't cause issues.

:Example: async def test_handle_null_keys_when_reading(self): await reset()

    test_ran = await StorageBaseTests.handle_null_keys_when_reading(get_storage())


    assert test_ran

Classes

DialogTestClient

A client for testing dialogs in isolation.

Create a DialogTestClient to test a dialog without having to create a full-fledged adapter.

python client = DialogTestClient("test", MY_DIALOG, MY_OPTIONS) reply = await client.send_activity("first message") self.assertEqual(reply.text, "first reply", "reply failed")

For channel Id, use 'emulator' or 'test' if you are uncertain of the channel you are targeting. Otherwise, it is recommended that you use the id for the channel(s) your bot will be using and write a test case for each channel. Or, a test adapter instance can be used. :type channel_or_adapter: Union[str, TestAdapter] :param target_dialog: The dialog to be tested. This will be the root dialog for the test client. :type target_dialog: Dialog :param initial_dialog_options: (Optional) additional argument(s) to pass to the dialog being started. :type initial_dialog_options: object :param middlewares: (Optional) The test adapter to use. If this parameter is not provided, the test client will use a default TestAdapter. :type middlewares: List[Middleware] :param conversation_state: (Optional) A ConversationState instance to use in the test client. :type conversation_state: ConversationState

DialogTestLogger

A middleware to output incoming and outgoing activities as json strings to the console during unit tests.

Initialize a new instance of the dialog test logger.

default to logging.getLogger(name).info. :type log_func: Callable[..., None] :param json_indent: An indent for json output, default indent is 4. :type json_indent: int :param time_func: A time function to record time spans, default to time.monotonic. :type time_func: Callable[[], float]

StorageBaseTests