diff --git a/pyproject.toml b/pyproject.toml index 3bbc2c5..d9d693b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,6 +99,7 @@ lint = [ ] tests = [ "pytest>=6.1.0", + "pytest-ordering>=0.6", "pytest-salt-factories>=1.0.0rc19", ] diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 2935c35..50d8988 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -49,9 +49,11 @@ def tags(): @pytest.fixture(scope="session") def resource_group(): - yield "rg-salt-inttest-" + "".join( - random.choice(string.ascii_lowercase + string.digits) for _ in range(20) - ) + # yield "rg-salt-inttest-" + "".join( + # random.choice(string.ascii_lowercase + string.digits) for _ in range(20) + # ) + # + yield "github" @pytest.fixture(scope="session") diff --git a/tests/integration/states/test_public_ip_address.py b/tests/integration/states/test_public_ip_address.py index c9abef6..f9cf47c 100644 --- a/tests/integration/states/test_public_ip_address.py +++ b/tests/integration/states/test_public_ip_address.py @@ -145,3 +145,30 @@ def test_absent(salt_call_cli, public_ip_addr, resource_group, connection_auth): assert data["changes"]["new"] == expected["changes"]["new"] assert data["changes"]["old"]["name"] == expected["changes"]["old"]["name"] assert data["result"] == expected["result"] + + +@pytest.mark.run(order=-3) +def test_absent_second_ip(salt_call_cli, public_ip_addr2, resource_group, connection_auth): + expected = { + "changes": { + "new": {}, + "old": { + "name": public_ip_addr2, + }, + }, + "comment": f"Public IP address {public_ip_addr2} has been deleted.", + "name": public_ip_addr2, + "result": True, + } + ret = salt_call_cli.run( + "--local", + "state.single", + "azurerm_network.public_ip_address_absent", + name=public_ip_addr2, + resource_group=resource_group, + connection_auth=connection_auth, + ) + data = list(ret.data.values())[0] + assert data["changes"]["new"] == expected["changes"]["new"] + assert data["changes"]["old"]["name"] == expected["changes"]["old"]["name"] + assert data["result"] == expected["result"] diff --git a/tests/integration/states/test_resource_group.py b/tests/integration/states/test_resource_group.py index e8ccc08..3415f2e 100644 --- a/tests/integration/states/test_resource_group.py +++ b/tests/integration/states/test_resource_group.py @@ -1,7 +1,8 @@ import pytest -@pytest.mark.run(order=1) +# @pytest.mark.run(order=1) +@pytest.mark.skip(reason="resource group already exists") def test_present(salt_call_cli, resource_group, location, connection_auth): expected = { "__id__": resource_group, @@ -36,7 +37,8 @@ def test_present(salt_call_cli, resource_group, location, connection_auth): assert data == expected -@pytest.mark.run(order=1, after="test_present", before="test_absent") +# @pytest.mark.run(order=1, after="test_present", before="test_absent") +@pytest.mark.skip(reason="resource group already exists") def test_changes(salt_call_cli, resource_group, location, tags, connection_auth): expected = { "__id__": resource_group, @@ -73,7 +75,8 @@ def test_changes(salt_call_cli, resource_group, location, tags, connection_auth) assert data == expected -@pytest.mark.run(order=-1) +# @pytest.mark.run(order=-1) +@pytest.mark.skip(reason="do not delete this rg during testing") def test_absent(salt_call_cli, resource_group, location, tags, connection_auth): expected = { "__id__": resource_group,