"""Fixtures for tests.""" import random from threading import RLock import pytest current_id = random.randint(1_000_000, 100_000_000) current_id_lock = RLock() def _next_object_id(): global current_id, current_id_lock # use lock for case if run tests in parallel with current_id_lock: current_id += 1 return f'oat-tests-fake-id-{current_id}' @pytest.fixture def podcast_object_fixture(): """Return podcast object_type and object_id.""" # we use empty object_id for podcast and episode and generate object_id for adupload yield 'podcast', '' @pytest.fixture def episode_object_fixture(): """Return episode object_type and object_id.""" # we use empty object_id for podcast and episode and generate object_id for adupload yield 'episode', '' @pytest.fixture def adupload_object_fixture(): """Return adupload object_type and object_id.""" # we use empty object_id for podcast and episode and generate object_id for adupload yield 'adupload', _next_object_id()