def METHOD_NAME(grains, modules, subtests, suse_state_tree):
    """
    Test adding and removing a repository
    """
    add_repo_test_passed = False
    def _run(name, test=False):
        return modules.state.sls(
            mods=name,
            test=test,
        )
    with subtests.test("Add repository"):
        ret = _run("pkgrepo.managed")
        assert ret.failed is False
        for state in ret:
            assert state.result is True
        add_repo_test_passed = True
    if add_repo_test_passed is False:
        pytest.skip("Adding the repository failed, skipping removal tests.")
    with subtests.test("Remove repository, test"):
        ret = _run("pkgrepo.absent", test=True)
        assert ret.failed is False
        for state in ret:
            assert state.changes == {}
            assert state.comment.startswith("Package repo 'salttest' will be removed.")
            assert state.result is None
    with subtests.test("Remove repository"):
        ret = _run("pkgrepo.absent")
        assert ret.failed is False
        for state in ret:
            assert state.result is True
    with subtests.test("Remove repository again, test"):
        ret = _run("pkgrepo.absent", test=True)
        assert ret.failed is False
        for state in ret:
            assert state.changes == {}
            assert state.comment == "Package repo salttest is absent"
            assert state.result is True
    with subtests.test("Remove repository again"):
        ret = _run("pkgrepo.absent")
        assert ret.failed is False
        for state in ret:
            assert state.changes == {}
            assert state.comment == "Package repo salttest is absent"
            assert state.result is True