helpers#

Collection of helper functions used in conda.notices tests.

Classes#

DummyArgs

Dummy object that sets all kwargs as object properties.

MockResponse

Functions#

get_test_notices(→ dict)

add_resp_to_mock(→ None)

Adds any number of MockResponse to MagicMock object as side_effects

create_notice_cache_files(→ None)

Creates the cache files that we use in tests

offset_cache_file_mtime(→ None)

Allows for offsetting the mtime of the notices cache file. This is often

notices_decorator_assert_message_in_stdout(captured, ...)

Tests a run of notices decorator where we expect to see the messages

get_notice_cache_filenames(→ tuple[str])

Returns the filenames of the cache files that will be searched for

Attributes#

DEFAULT_NOTICE_MESG

DEFAULT_NOTICE_MESG = 'Here is an example message that will be displayed to users'#
get_test_notices(messages: Sequence[str], level: str | None = 'info', created_at: datetime.datetime | None = None, expired_at: datetime.datetime | None = None) dict#
add_resp_to_mock(mock_session: unittest.mock.MagicMock, status_code: int, messages_json: dict, raise_exc: bool = False) None#

Adds any number of MockResponse to MagicMock object as side_effects

create_notice_cache_files(cache_dir: pathlib.Path, cache_files: Sequence[str], messages_json_seq: Sequence[dict]) None#

Creates the cache files that we use in tests

offset_cache_file_mtime(mtime_offset) None#

Allows for offsetting the mtime of the notices cache file. This is often used to mock an older creation time the cache file.

class DummyArgs(**kwargs)#

Dummy object that sets all kwargs as object properties.

notices_decorator_assert_message_in_stdout(captured, messages: Sequence[str], dummy_mesg: str | None = None, not_in: bool = False)#

Tests a run of notices decorator where we expect to see the messages print to stdout.

class MockResponse(status_code, json_data, raise_exc=False)#
json()#
get_notice_cache_filenames(ctx: conda.base.context.Context) tuple[str]#

Returns the filenames of the cache files that will be searched for