Skip to content

Commit a931a60

Browse files
authored
test: refactor integration test directory structure and improve test command usage (#397)
* change directory structure and makefile usage * remove unnecessary init files * remove unnecessary init files
1 parent b0920fd commit a931a60

File tree

16 files changed

+16
-13
lines changed

16 files changed

+16
-13
lines changed

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
PYTHON ?= python3
22

3-
INTEGRATION_TEST_PATH :=
43
TEST_CASE_COMMAND :=
5-
MODEL_COMMAND :=
4+
TEST_SUITE :=
65

76
LINODE_SDK_VERSION ?= "0.0.0.dev"
87
VERSION_MODULE_DOCSTRING ?= \"\"\"\nThe version of this linode_api4 package.\n\"\"\"\n\n
98
VERSION_FILE := ./linode_api4/version.py
109

1110
ifdef TEST_CASE
12-
TEST_CASE_COMMAND = -k $(TEST_CASE)
11+
TEST_CASE_COMMAND = -k $(TEST_CASE)
1312
endif
1413

15-
ifdef TEST_MODEL
16-
MODEL_COMMAND = models/$(TEST_MODEL)
14+
ifdef TEST_SUITE
15+
ifneq ($(TEST_SUITE),linode_client)
16+
TEST_COMMAND = models/$(TEST_SUITE)
17+
else
18+
TEST_COMMAND = linode_client
19+
endif
1720
endif
1821

1922
.PHONY: clean
@@ -67,7 +70,7 @@ lint: build
6770

6871
.PHONY: testint
6972
testint:
70-
$(PYTHON) -m pytest test/integration/${INTEGRATION_TEST_PATH}${MODEL_COMMAND} ${TEST_CASE_COMMAND}
73+
$(PYTHON) -m pytest test/integration/${TEST_COMMAND} ${TEST_CASE_COMMAND}
7174

7275
.PHONY: testunit
7376
testunit:

README.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,10 @@ Run the tests locally using the make command. Run the entire test suite using co
150150

151151
make testint
152152

153-
To run a specific package, use environment variable `INTEGRATION_TEST_PATH` with `testint` command::
153+
To run a specific package/suite, use the environment variable `TEST_SUITE` using directory names in `integration/...` folder ::
154154

155-
make INTEGRATION_TEST_PATH="linode_client" testint
156-
157-
To run a specific model test suite, set the environment variable `TEST_MODEL` using file name in `integration/models`::
158-
159-
make TEST_MODEL="test_account.py" testint
155+
make TEST_SUITE="account" testint // Runs tests in `integration/models/account` directory
156+
make TEST_SUITE="linode_client" testint // Runs tests in `integration/linode_client` directory
160157

161158
Lastly to run a specific test case use environment variable `TEST_CASE` with `testint` command::
162159

test/integration/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,11 @@ def test_firewall(test_linode_client):
252252
"inbound_policy": "ACCEPT",
253253
}
254254

255+
timestamp = str(time.time_ns())
256+
label = "firewall_" + timestamp
257+
255258
firewall = client.networking.firewall_create(
256-
"test-firewall", rules=rules, status="enabled"
259+
label=label, rules=rules, status="enabled"
257260
)
258261

259262
yield firewall

0 commit comments

Comments
 (0)