Skip to content

Commit f1941cc

Browse files
authored
add back missing tests (#209)
1 parent d36c6fa commit f1941cc

13 files changed

+339
-310
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ dev = [
116116
]
117117

118118
[tool.pytest.ini_options]
119+
tmp_path_retention_policy = "failed"
119120
testpaths = ["tests"]
120121
addopts = "--capture=tee-sys --tb=native -p no:warnings"
121122
markers =[

tests/conftest.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Global fixtures go here."""
22

33
from pathlib import Path
4-
from random import choice, random
5-
from string import ascii_letters
4+
from random import randint
5+
from uuid import uuid4
66

77
import pytest
88

@@ -30,31 +30,25 @@ def adr_service_create(pytestconfig: pytest.Config) -> Service:
3030

3131
# Paths setup
3232
base_dir = Path(__file__).parent / "test_data"
33-
dir_name = "auto_delete_" + "".join(choice(ascii_letters) for _ in range(5))
34-
db_dir = base_dir / dir_name
35-
tmp_docker_dir = base_dir / "tmp_docker"
33+
local_db = base_dir / f"auto_delete_{str(uuid4()).replace('-', '')}"
34+
tmp_docker_dir = base_dir / "tmp_docker_create"
3635

3736
if use_local:
3837
adr_service = Service(
3938
ansys_installation=pytestconfig.getoption("install_path"),
40-
docker_image=DOCKER_DEV_REPO_URL,
41-
db_directory=str(db_dir),
42-
port=8000 + int(random() * 4000),
39+
db_directory=str(local_db),
40+
port=8000 + randint(0, 3999),
4341
)
4442
else:
4543
adr_service = Service(
4644
ansys_installation="docker",
4745
docker_image=DOCKER_DEV_REPO_URL,
48-
db_directory=str(db_dir),
46+
db_directory=str(local_db),
4947
data_directory=str(tmp_docker_dir),
50-
port=8000 + int(random() * 4000),
48+
port=8000 + randint(0, 3999),
5149
)
5250

53-
_ = adr_service.start(
54-
create_db=True,
55-
exit_on_close=True,
56-
delete_db=True,
57-
)
51+
adr_service.start(create_db=True, exit_on_close=True, delete_db=True)
5852

5953
yield adr_service # Return to running the test session
6054

@@ -72,17 +66,19 @@ def adr_service_query(pytestconfig: pytest.Config) -> Service:
7266
tmp_docker_dir = base_dir / "tmp_docker_query"
7367

7468
if use_local:
75-
ansys_installation = pytestconfig.getoption("install_path")
69+
adr_service = Service(
70+
ansys_installation=pytestconfig.getoption("install_path"),
71+
db_directory=str(local_db),
72+
port=8000 + randint(0, 3999),
73+
)
7674
else:
77-
ansys_installation = "docker"
78-
79-
adr_service = Service(
80-
ansys_installation=ansys_installation,
81-
docker_image=DOCKER_DEV_REPO_URL,
82-
db_directory=str(local_db),
83-
data_directory=str(tmp_docker_dir),
84-
port=8000 + int(random() * 4000),
85-
)
75+
adr_service = Service(
76+
ansys_installation="docker",
77+
docker_image=DOCKER_DEV_REPO_URL,
78+
db_directory=str(local_db),
79+
data_directory=str(tmp_docker_dir),
80+
port=8000 + randint(0, 3999),
81+
)
8682

8783
if not use_local:
8884
adr_service._container.save_config()

tests/test_download_html.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from ansys.dynamicreporting.core.utils import report_download_html as rd
44

55

6-
def test_download_use_data(request, adr_service_query) -> bool:
6+
def test_download_use_data(request, adr_service_query) -> None:
77
test_dir = join(join(request.fspath.dirname, "test_data"), "test_html_ext")
88
my_url = "http://localhost:" + str(adr_service_query._port)
99
my_url += "/reports/report_display/?report_table_length=10&view=c4afe878-a4fe-11ed-a616-747827182a82&usemenus=on&dpi=96&pwidth=19.41&query="
@@ -12,7 +12,7 @@ def test_download_use_data(request, adr_service_query) -> bool:
1212
assert test_res
1313

1414

15-
def test_download_nourl(request, adr_service_query) -> bool:
15+
def test_download_nourl(request, adr_service_query) -> None:
1616
test_dir = join(join(request.fspath.dirname, "test_data"), "exp_test_html")
1717
my_url = None
1818
a = rd.ReportDownloadHTML(url=my_url, directory=test_dir, debug=True)
@@ -24,7 +24,7 @@ def test_download_nourl(request, adr_service_query) -> bool:
2424
assert success
2525

2626

27-
def test_download_nodir(request, adr_service_query) -> bool:
27+
def test_download_nodir(request, adr_service_query) -> None:
2828
my_url = "http://localhost:" + str(adr_service_query._port)
2929
my_url += "/reports/report_display/?report_table_length=10&view=c4afe878-a4fe-11ed-a616-747827182a82&usemenus=on&dpi=96&pwidth=19.41&query="
3030
a = rd.ReportDownloadHTML(url=my_url, directory=None, debug=True)
@@ -36,7 +36,7 @@ def test_download_nodir(request, adr_service_query) -> bool:
3636
assert success
3737

3838

39-
def test_download_sqlite(request, adr_service_query) -> bool:
39+
def test_download_sqlite(request, adr_service_query) -> None:
4040
test_dir = join(join(join(request.fspath.dirname, "test_data"), "query_db"), "db.sqlite3")
4141
my_url = "http://localhost:" + str(adr_service_query._port)
4242
my_url += "/reports/report_display/?report_table_length=10&view=c4afe878-a4fe-11ed-a616-747827182a82&usemenus=on&dpi=96&pwidth=19.41&query="
@@ -49,7 +49,7 @@ def test_download_sqlite(request, adr_service_query) -> bool:
4949
assert success
5050

5151

52-
def test_download(request, adr_service_query) -> bool:
52+
def test_download(request, adr_service_query) -> None:
5353
test_dir = join(join(request.fspath.dirname, "test_data"), "html_exp")
5454
my_url = "http://localhost:" + str(adr_service_query._port)
5555
my_url += "/reports/report_display/?report_table_length=10&view=c4afe878-a4fe-11ed-a616-747827182a82&usemenus=on&dpi=96&pwidth=19.41&query="

tests/test_encoders.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,39 @@
99

1010

1111
@pytest.mark.ado_test
12-
def test_payload() -> bool:
12+
def test_payload() -> None:
1313
b = en.PayloaddataEncoder()
1414
res = b.default(obj=ru.nexus_array())
1515
assert res == [[0.0]]
1616

1717

1818
@pytest.mark.ado_test
19-
def test_base_datetime() -> bool:
19+
def test_base_datetime() -> None:
2020
a = en.BaseEncoder()
2121
assert a.default(obj=datetime.datetime(year=2023, month=4, day=10)) == "2023-04-10T00:00:00"
2222

2323

2424
@pytest.mark.ado_test
25-
def test_uuid() -> bool:
25+
def test_uuid() -> None:
2626
a = en.PayloaddataEncoder()
2727
assert type(a.default(obj=uuid.uuid1())) is str
2828

2929

3030
@pytest.mark.ado_test
31-
def test_bytes() -> bool:
31+
def test_bytes() -> None:
3232
a = en.BaseEncoder()
3333
mystr = "aa"
3434
assert a.default(obj=mystr.encode()) == mystr
3535

3636

3737
@pytest.mark.ado_test
38-
def test_dict() -> bool:
38+
def test_dict() -> None:
3939
a = en.BaseEncoder()
4040
mydict = {"a": 1}
4141
assert a.default(obj=mydict) == mydict
4242

4343

4444
@pytest.mark.ado_test
45-
def test_nparray() -> bool:
45+
def test_nparray() -> None:
4646
a = en.PayloaddataEncoder()
4747
assert isinstance(a.default(obj=np.ndarray(shape=(1, 1))), list)

tests/test_filelock.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
@pytest.mark.ado_test
22-
def test_timeout(request) -> bool:
22+
def test_timeout(request) -> None:
2323
test_path = join(request.fspath.dirname, "test_data")
2424
tmp_file = join(test_path, "time.txt")
2525
open(tmp_file, "a").close()
@@ -28,7 +28,7 @@ def test_timeout(request) -> bool:
2828

2929

3030
@pytest.mark.ado_test
31-
def test_base_acquire(request) -> bool:
31+
def test_base_acquire(request) -> None:
3232
test_path = join(request.fspath.dirname, "test_data")
3333
tmp_file = join(test_path, "base.txt")
3434
open(tmp_file, "a").close()
@@ -43,7 +43,7 @@ def test_base_acquire(request) -> bool:
4343

4444

4545
@pytest.mark.ado_test
46-
def test_base_release(request) -> bool:
46+
def test_base_release(request) -> None:
4747
test_path = join(request.fspath.dirname, "test_data")
4848
tmp_file = join(test_path, "base2.txt")
4949
open(tmp_file, "a").close()
@@ -58,7 +58,7 @@ def test_base_release(request) -> bool:
5858

5959

6060
@pytest.mark.ado_test
61-
def test_base_locked(request) -> bool:
61+
def test_base_locked(request) -> None:
6262
test_path = join(request.fspath.dirname, "test_data")
6363
tmp_file = join(test_path, "base3.txt")
6464
open(tmp_file, "a").close()
@@ -67,7 +67,7 @@ def test_base_locked(request) -> bool:
6767

6868

6969
@pytest.mark.ado_test
70-
def test_base_rel(request) -> bool:
70+
def test_base_rel(request) -> None:
7171
test_path = join(request.fspath.dirname, "test_data")
7272
tmp_file = join(test_path, "base4.txt")
7373
open(tmp_file, "a").close()
@@ -76,7 +76,7 @@ def test_base_rel(request) -> bool:
7676

7777

7878
@pytest.mark.ado_test
79-
def test_platform_lock(request) -> bool:
79+
def test_platform_lock(request) -> None:
8080
test_path = join(request.fspath.dirname, "test_data")
8181
tmp_file = join(test_path, "platform.txt")
8282
tmp_file2 = join(test_path, "platform2.txt")
@@ -96,7 +96,7 @@ def test_platform_lock(request) -> bool:
9696

9797

9898
@pytest.mark.ado_test
99-
def test_soft(request) -> bool:
99+
def test_soft(request) -> None:
100100
test_path = join(request.fspath.dirname, "test_data")
101101
tmp_file = join(test_path, "soft.txt")
102102
tmp_file2 = join(test_path, "soft2.txt")
@@ -108,7 +108,7 @@ def test_soft(request) -> bool:
108108
assert rel is None
109109

110110

111-
def test_nexus_filelock(request) -> bool:
111+
def test_nexus_filelock(request) -> None:
112112
test_path = join(request.fspath.dirname, "test_data")
113113
tmp_file = join(test_path, "n_lock.txt")
114114
try:

tests/test_geofile_processing.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def return_file_paths(request):
1818

1919

2020
@pytest.mark.ado_test
21-
def test_get_evsn_proxy_image(request) -> bool:
21+
def test_get_evsn_proxy_image(request) -> None:
2222
try:
2323
_ = gp.get_evsn_proxy_image(filename=return_file_paths(request)[6])
2424
success = True
@@ -28,33 +28,33 @@ def test_get_evsn_proxy_image(request) -> bool:
2828

2929

3030
@pytest.mark.ado_test
31-
def test_get_evsn_proxy_error(request) -> bool:
31+
def test_get_evsn_proxy_error(request) -> None:
3232
succ = gp.get_evsn_proxy_image(filename=return_file_paths(request)[5]) is None
3333
assert succ
3434

3535

3636
@pytest.mark.ado_test
37-
def test_file_can_have_proxy(request) -> bool:
37+
def test_file_can_have_proxy(request) -> None:
3838
scene = gp.file_can_have_proxy(return_file_paths(request)[1])
3939
img = gp.file_can_have_proxy(return_file_paths(request)[0])
4040
assert scene is True and img is False
4141

4242

4343
@pytest.mark.ado_test
44-
def test_file_is_3d_geometry(request) -> bool:
44+
def test_file_is_3d_geometry(request) -> None:
4545
scene = gp.file_is_3d_geometry(return_file_paths(request)[1], file_item_only=False)
4646
img = gp.file_is_3d_geometry(return_file_paths(request)[0])
4747
assert scene is True and img is False
4848

4949

5050
@pytest.mark.ado_test
51-
def test_get_avz_directory(request) -> bool:
51+
def test_get_avz_directory(request) -> None:
5252
avz_dir = gp.get_avz_directory(return_file_paths(request)[1])
5353
assert isinstance(avz_dir, str) and avz_dir != ""
5454

5555

5656
@pytest.mark.ado_test
57-
def test_rebuild_3d_geom_avz(request) -> bool:
57+
def test_rebuild_3d_geom_avz(request) -> None:
5858
_ = gp.rebuild_3d_geometry(
5959
csf_file=return_file_paths(request)[1], unique_id="abc", exec_basis="avz"
6060
)
@@ -64,7 +64,7 @@ def test_rebuild_3d_geom_avz(request) -> bool:
6464

6565

6666
@pytest.mark.ado_test
67-
def test_rebuild_3d_geom_ens(request) -> bool:
67+
def test_rebuild_3d_geom_ens(request) -> None:
6868
_ = gp.rebuild_3d_geometry(
6969
csf_file=return_file_paths(request)[2], unique_id="abc", exec_basis="avz"
7070
)
@@ -74,7 +74,7 @@ def test_rebuild_3d_geom_ens(request) -> bool:
7474

7575

7676
@pytest.mark.ado_test
77-
def test_rebuild_3d_geom_evsn(request) -> bool:
77+
def test_rebuild_3d_geom_evsn(request) -> None:
7878
_ = gp.rebuild_3d_geometry(
7979
csf_file=return_file_paths(request)[3], unique_id="abc", exec_basis="avz"
8080
)
@@ -84,7 +84,7 @@ def test_rebuild_3d_geom_evsn(request) -> bool:
8484

8585

8686
@pytest.mark.ado_test
87-
def test_rebuild_3d_geom_scdoc(request) -> bool:
87+
def test_rebuild_3d_geom_scdoc(request) -> None:
8888
_ = gp.rebuild_3d_geometry(
8989
csf_file=return_file_paths(request)[4], unique_id="abc", exec_basis="avz"
9090
)
@@ -93,7 +93,7 @@ def test_rebuild_3d_geom_scdoc(request) -> bool:
9393
assert isdir(new_dir)
9494

9595

96-
def test_rebuild_3d_geom_scdoc_second(request) -> bool:
96+
def test_rebuild_3d_geom_scdoc_second(request) -> None:
9797
_ = gp.rebuild_3d_geometry(
9898
csf_file=return_file_paths(request)[4], unique_id="abc", exec_basis="avz"
9999
)
@@ -102,7 +102,7 @@ def test_rebuild_3d_geom_scdoc_second(request) -> bool:
102102
assert isdir(new_dir)
103103

104104

105-
def test_rebuild_3d_geom_csf(request, get_exec) -> bool:
105+
def test_rebuild_3d_geom_csf(request, get_exec) -> None:
106106
exec_basis = get_exec
107107
if exec_basis:
108108
_ = gp.rebuild_3d_geometry(

tests/test_hacks.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@
77

88

99
@pytest.mark.ado_test
10-
def test_unpicke() -> bool:
10+
def test_unpicke() -> None:
1111
assert ex.safe_unpickle(input_data="!@P{}", item_type="tree") == "!@P{}"
1212

1313

1414
@pytest.mark.ado_test
15-
def test_unpickle_empty() -> bool:
15+
def test_unpickle_empty() -> None:
1616
assert ex.safe_unpickle(input_data="") == ""
1717

1818

1919
@pytest.mark.ado_test
20-
def test_unpickle_bytes() -> bool:
20+
def test_unpickle_bytes() -> None:
2121
assert ex.safe_unpickle(input_data=pickle.dumps("!@P{}")) == "!@P{}"
2222

2323

2424
@pytest.mark.ado_test
25-
def test_unpickle_none() -> bool:
25+
def test_unpickle_none() -> None:
2626
assert ex.safe_unpickle(input_data=None) is None
2727

2828

2929
@pytest.mark.ado_test
30-
def test_unpickle_nobeg() -> bool:
30+
def test_unpickle_nobeg() -> None:
3131
assert ex.safe_unpickle(input_data=pickle.dumps("abcde")) == "abcde"
3232

3333

3434
@pytest.mark.ado_test
35-
def test_unpickle_error() -> bool:
35+
def test_unpickle_error() -> None:
3636
success = False
3737
try:
3838
ex.safe_unpickle(input_data="abcde")
@@ -42,14 +42,14 @@ def test_unpickle_error() -> bool:
4242

4343

4444
@pytest.mark.ado_test
45-
def test_rec_tree() -> bool:
45+
def test_rec_tree() -> None:
4646
test = ex.reconstruct_tree_item(
4747
[{b"a": 1}, {1: b"b"}, {1: uuid.uuid1()}, {1: [{"a": "b"}, {}]}]
4848
)
4949
assert len(test) == 4
5050

5151

5252
@pytest.mark.ado_test
53-
def test_rec_int_data() -> bool:
53+
def test_rec_int_data() -> None:
5454
test = ex.reconstruct_international_text(data={"a": [1, 2, 3], "b": 2})
5555
assert test == {"a": [1, 2, 3], "b": 2}

0 commit comments

Comments
 (0)