Skip to content

Commit 1a3afb8

Browse files
committed
move pytest config to pyproject.toml
1 parent b58a36e commit 1a3afb8

File tree

3 files changed

+76
-7
lines changed

3 files changed

+76
-7
lines changed

pyproject.toml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,40 @@ strict = true
44
pretty = true
55

66
exclude = [
7-
'^policy_sentry/analysis',
87
'^policy_sentry/bin',
98
'^policy_sentry/command',
10-
'^policy_sentry/querying',
119
'^policy_sentry/writing',
1210
]
11+
12+
[tool.pytest.ini_options]
13+
testpaths = [
14+
"test",
15+
"test/analysis",
16+
"test/command",
17+
"test/querying",
18+
"test/util",
19+
"test/writing",
20+
]
21+
norecursedirs = [
22+
"_build",
23+
"tmp*",
24+
"__pycache__",
25+
]
26+
27+
# supported from version 7.3.0
28+
#[tool.coverage]
29+
#omit = [
30+
# "policy_sentry/shared/awsdocs.py",
31+
# # ignore v1 variants
32+
# "policy_sentry/querying/actions_v1.py",
33+
# "policy_sentry/querying/all_v1.py",
34+
# "policy_sentry/querying/arns_v1.py",
35+
# # omit anything in a .local directory anywhere
36+
# "*/.local/*",
37+
# "*/virtualenv/*",
38+
# "*/venv/*",
39+
# "*/.venv/*",
40+
# "*/docs/*",
41+
# "*/examples/*",
42+
# "utils/*",
43+
#]

setup.cfg

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
[tool:pytest]
2-
testpaths = test test/analysis test/command test/querying test/util test/writing
3-
python_files=test/*/test_*.py
4-
norecursedirs = .svn _build tmp* __pycache__
5-
61
# Exclude: __pycache__ / .pyc
72
[coverage:run]
83
;include =
@@ -11,6 +6,10 @@ norecursedirs = .svn _build tmp* __pycache__
116
;source=policy_sentry/*
127
omit =
138
policy_sentry/shared/awsdocs.py
9+
# ignore v1 variants
10+
policy_sentry/querying/actions_v1.py
11+
policy_sentry/querying/all_v1.py
12+
policy_sentry/querying/arns_v1.py
1413
# omit anything in a .local directory anywhere
1514
*/.local/*
1615
*/virtualenv/*

test/util/test_actions.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from policy_sentry.util.actions import (
2+
get_service_from_action,
3+
get_action_name_from_action,
4+
get_full_action_name,
5+
)
6+
7+
8+
def test_get_service_from_action():
9+
# given
10+
action = "ec2:DescribeInstance"
11+
12+
# when
13+
service = get_service_from_action(action=action)
14+
15+
# then
16+
assert service == "ec2"
17+
18+
19+
def test_get_action_name_from_action():
20+
# given
21+
action = "ec2:DescribeInstance"
22+
23+
# when
24+
service = get_action_name_from_action(action=action)
25+
26+
# then
27+
assert service == "describeinstance"
28+
29+
30+
def test_get_full_action_name():
31+
# given
32+
service = "ec2"
33+
action_name = "DescribeInstance"
34+
35+
# when
36+
action = get_full_action_name(service=service, action_name=action_name)
37+
38+
# then
39+
assert action == "ec2:DescribeInstance"

0 commit comments

Comments
 (0)