import inspect

from src.workers.tasks.migrate_runtime_primitives import migrate_runtime_primitives


def test_worker_installs_contact_capture_before_any_push():
    src = inspect.getsource(migrate_runtime_primitives)
    body = src.split('logger.info("migrate_runtime_primitives_start"', 1)[1]
    pack = body.index("_install_contact_capture_pack")
    push = body.index("push_repo")
    blocked = body.index("pack_blocked")
    assert pack < push
    assert blocked < push
    assert "_enqueue_preview_for_sha" in body
