def test_query_select_related_and_for_update_when_using_of():
    with query_lock_limiter(enable=True):
        list(SampleModelWithFK.objects.select_related().select_for_update(of=("self",)))
def test_query_select_related_and_for_update():
    with pytest.raises(WouldSelectMultipleTablesForUpdate):
        with query_lock_limiter(enable=True):
            list(SampleModelWithFK.objects.select_related().select_for_update())
def test_query_locking_whitelisted_multiple_tables():
    whitelist = [["tests_samplemodel", "tests_samplemodelwithfk"]]
    with query_lock_limiter(enable=True, whitelisted_table_sets=whitelist):
        list(SampleModelWithFK.objects.filter(parent__a="").select_for_update())
def test_query_locking_multiple_tables():
    with pytest.raises(WouldSelectMultipleTablesForUpdate):
        with query_lock_limiter(enable=True):
            list(SampleModelWithFK.objects.filter(parent__a="").select_for_update())
def test_queries_locking_single_tables():
    with query_lock_limiter(enable=True):
        list(SampleModel.objects.all().select_for_update())
        list(SampleModelWithFK.objects.all().select_for_update())
def test_nonlocking_queries():
    with query_lock_limiter(enable=True):
        list(SampleModel.objects.all())
        list(SampleModelWithFK.objects.all().select_related())