Skip to content

Commit

Permalink
Add pytest-ordering to pyproject.toml, Add test_absent func for secon…
Browse files Browse the repository at this point in the history
…d public ip address
  • Loading branch information
M3GH4NN committed Mar 12, 2024
1 parent 49102d0 commit 0d595da
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ lint = [
]
tests = [
"pytest>=6.1.0",
"pytest-ordering>=0.6",
"pytest-salt-factories>=1.0.0rc19",
]

Expand Down
8 changes: 5 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
27 changes: 27 additions & 0 deletions tests/integration/states/test_public_ip_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
9 changes: 6 additions & 3 deletions tests/integration/states/test_resource_group.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0d595da

Please sign in to comment.