Skip to content

Commit cbeb41d

Browse files
committed
chore: exclude integration tests on deployment
1 parent c6f61af commit cbeb41d

File tree

11 files changed

+50
-3
lines changed

11 files changed

+50
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: uv sync --all-extras
2727

2828
- name: Run tests
29-
run: uv run pytest
29+
run: uv run pytest -m "not integration"
3030

3131
- name: Build package
3232
run: uv build

tests/test_core.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from argparse import Namespace
22
import unittest
3+
4+
import pytest
35
from obiba_opal import OpalClient
46
from obiba_opal.core import HTTPError
57
from os.path import exists
@@ -13,7 +15,7 @@ def setup_class(cls):
1315
# Make sure to place your own certificate files
1416
cls.SSL_CERTIFICATE = "./resources/certificates/publickey.pem"
1517
cls.SSL_KEY = "./resources/certificates/privatekey.pem"
16-
18+
1719
def test_sendRestBadServer(self):
1820
# FIXME for some reason, the cookie_file is not removed (despite the os.remove()
1921
# is called and os.path.exists() says it was removed)
@@ -24,6 +26,7 @@ def test_sendRestBadServer(self):
2426
except RequestException:
2527
assert True
2628

29+
@pytest.mark.integration
2730
def test_sendRestBadCredentials(self):
2831
client = OpalClient.buildWithAuthentication(server=TEST_SERVER, user="admin", password=TEST_PASSWORD)
2932

@@ -32,6 +35,7 @@ def test_sendRestBadCredentials(self):
3235
finally:
3336
client.close()
3437

38+
@pytest.mark.integration
3539
def test_sendRest(self):
3640
client = None
3741
try:
@@ -43,6 +47,7 @@ def test_sendRest(self):
4347
if client:
4448
client.close()
4549

50+
@pytest.mark.integration
4651
def test_sendSecuredRest(self):
4752
if exists(self.SSL_CERTIFICATE):
4853
client = None
@@ -57,6 +62,7 @@ def test_sendSecuredRest(self):
5762
if client:
5863
client.close()
5964

65+
@pytest.mark.integration
6066
def test_validAuthLoginInfo(self):
6167
client = None
6268
try:
@@ -69,6 +75,7 @@ def test_validAuthLoginInfo(self):
6975
if client:
7076
client.close()
7177

78+
@pytest.mark.integration
7279
def test_validSslLoginInfo(self):
7380
if exists(self.SSL_CERTIFICATE):
7481
client = None
@@ -86,10 +93,12 @@ def test_validSslLoginInfo(self):
8693
if client:
8794
client.close()
8895

96+
@pytest.mark.integration
8997
def test_invalidServerInfo(self):
9098
args = Namespace(opl=TEST_SERVER, user=TEST_USER, password=TEST_PASSWORD)
9199
self.assertRaises(ValueError, OpalClient.LoginInfo.parse, args)
92100

101+
@pytest.mark.integration
93102
def test_invalidLoginInfo(self):
94103
args = Namespace(opal=TEST_SERVER, usr="administrator", password=TEST_PASSWORD)
95104
self.assertRaises(ValueError, OpalClient.LoginInfo.parse, args)

tests/test_data.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from obiba_opal import DataService, EntityService
23
from tests.utils import make_client
34

@@ -12,12 +13,14 @@ def setup_class(cls):
1213
def teardown_class(cls):
1314
cls.client.close()
1415

16+
@pytest.mark.integration
1517
def test_entities(self):
1618
client = self.client
1719
res = DataService(client).get_entities("CNSIM", "CNSIM1")
1820
assert isinstance(res, list)
1921
assert len(res) == 2163
2022

23+
@pytest.mark.integration
2124
def test_valueset(self):
2225
client = self.client
2326
res = DataService(client).get_valueset("CNSIM", "CNSIM1", id="1604")
@@ -27,18 +30,21 @@ def test_valueset(self):
2730
assert isinstance(res["variables"], list)
2831
assert len(res["variables"]) == 11
2932

33+
@pytest.mark.integration
3034
def test_value(self):
3135
client = self.client
3236
res = DataService(client).get_value("CNSIM", "CNSIM1", "GENDER", id="1604")
3337
assert res["value"] == "1"
3438

39+
@pytest.mark.integration
3540
def test_entity(self):
3641
client = self.client
3742
res = EntityService(client).get_entity("1604")
3843
assert isinstance(res, dict)
3944
assert res["entityType"] == "Participant"
4045
assert res["identifier"] == "1604"
4146

47+
@pytest.mark.integration
4248
def test_entity_tables(self):
4349
client = self.client
4450
res = EntityService(client).get_entity_tables("1604")

tests/test_dictionary.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from obiba_opal import DictionaryService, ExportAnnotationsService
23
from tests.utils import make_client
34
import io
@@ -13,42 +14,49 @@ def setup_class(cls):
1314
def teardown_class(cls):
1415
cls.client.close()
1516

17+
@pytest.mark.integration
1618
def test_datasource(self):
1719
client = self.client
1820
res = DictionaryService(client).get_datasource("CNSIM")
1921
assert res["name"] == "CNSIM"
2022

23+
@pytest.mark.integration
2124
def test_datasources(self):
2225
client = self.client
2326
res = DictionaryService(client).get_datasources()
2427
assert isinstance(res, list)
2528
assert "CNSIM" in [x["name"] for x in res]
2629

30+
@pytest.mark.integration
2731
def test_table(self):
2832
client = self.client
2933
res = DictionaryService(client).get_table("CNSIM", "CNSIM1")
3034
assert res["name"] == "CNSIM1"
3135
assert res["datasourceName"] == "CNSIM"
3236
assert res["link"] == "/datasource/CNSIM/table/CNSIM1"
3337

38+
@pytest.mark.integration
3439
def test_tables(self):
3540
client = self.client
3641
res = DictionaryService(client).get_tables("CNSIM")
3742
assert isinstance(res, list)
3843
assert "CNSIM1" in [x["name"] for x in res]
3944

45+
@pytest.mark.integration
4046
def test_variable(self):
4147
client = self.client
4248
res = DictionaryService(client).get_variable("CNSIM", "CNSIM1", "GENDER")
4349
assert res["name"] == "GENDER"
4450
assert res["parentLink"]["link"] == "/datasource/CNSIM/table/CNSIM1"
4551

52+
@pytest.mark.integration
4653
def test_variables(self):
4754
client = self.client
4855
res = DictionaryService(client).get_variables("CNSIM", "CNSIM1")
4956
assert isinstance(res, list)
5057
assert len(res) == 11
5158

59+
@pytest.mark.integration
5260
def test_variable_annotations(self):
5361
client = self.client
5462
output = io.StringIO()

tests/test_exports.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from obiba_opal import ExportCSVCommand, TaskService
23
from tests.utils import make_client
34
import random
@@ -13,6 +14,7 @@ def setup_class(cls):
1314
def teardown_class(cls):
1415
cls.client.close()
1516

17+
@pytest.mark.integration
1618
def test_csv(self):
1719
client = self.client
1820
service = ExportCSVCommand(client)

tests/test_file.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import unittest
2+
3+
import pytest
24
from tests.utils import make_client
35
from obiba_opal.file import FileService
46
from obiba_opal.core import HTTPError
@@ -22,6 +24,7 @@ def setup_class(cls):
2224
cls.TEST_ZIPPED_FILE = f"/tmp/data_{suffix}.zip"
2325
cls.LOCAL_UPLOAD_FILE = f"/tmp/{cls.TEST_FILENAME}"
2426

27+
@pytest.mark.integration
2528
def test_1_fileUpload(self):
2629
try:
2730
# print(f"Uploading file to {self.TEST_FILE}...")
@@ -41,6 +44,7 @@ def test_1_fileUpload(self):
4144
except Exception as e:
4245
raise AssertionError("Failed to upload file, check if the file exists and if the name is correct.") from e
4346

47+
@pytest.mark.integration
4448
def test_2_fileDownload(self):
4549
try:
4650
# print(f"Downloading file to {self.TEST_FILE}...")
@@ -56,7 +60,8 @@ def test_2_fileDownload(self):
5660
) from None
5761
except Exception as e:
5862
raise AssertionError("Failed to download file, check if the file exists and if the name is correct.") from e
59-
63+
64+
@pytest.mark.integration
6065
def test_3_fileDownloadWithPassword(self):
6166
try:
6267
# print(f"Downloading file with password to {self.TEST_ZIPPED_FILE}...")
@@ -76,6 +81,7 @@ def test_3_fileDownloadWithPassword(self):
7681
"Failed to download file with password, check if the file exists and if the name is correct."
7782
) from e
7883

84+
@pytest.mark.integration
7985
def test_4_deleteUpload(self):
8086
try:
8187
# print(f"Deleting file {self.TEST_FILE}...")

tests/test_imports.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from obiba_opal import ImportCSVCommand, TaskService, FileService, DictionaryService
23
from tests.utils import make_client
34
import random
@@ -15,6 +16,7 @@ def setup_class(cls):
1516
def teardown_class(cls):
1617
cls.client.close()
1718

19+
@pytest.mark.integration
1820
def test_csv(self):
1921
client = self.client
2022
fs = FileService(client)

tests/test_perm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from obiba_opal import TablePermService
23
from tests.utils import make_client
34
import random
@@ -13,6 +14,7 @@ def setup_class(cls):
1314
def teardown_class(cls):
1415
cls.client.close()
1516

17+
@pytest.mark.integration
1618
def test_table(self):
1719
client = self.client
1820
service = TablePermService(client)

tests/test_project.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from obiba_opal import ProjectService, BackupProjectCommand
23
from tests.utils import make_client
34
import random
@@ -13,6 +14,7 @@ def setup_class(cls):
1314
def teardown_class(cls):
1415
cls.client.close()
1516

17+
@pytest.mark.integration
1618
def test_project(self):
1719
client = self.client
1820
service = ProjectService(client)
@@ -24,6 +26,7 @@ def test_project(self):
2426
assert isinstance(project, dict)
2527
assert project["name"] == "CNSIM"
2628

29+
@pytest.mark.integration
2730
def test_add_delete_project(self):
2831
client = self.client
2932
service = ProjectService(client)
@@ -36,6 +39,7 @@ def test_add_delete_project(self):
3639
project = service.get_project(name)
3740
assert project is None
3841

42+
@pytest.mark.integration
3943
def test_backup_command(self):
4044
client = self.client
4145
res = BackupProjectCommand(client).backup_project("CNSIM", "/tmp/test", force=True)

tests/test_subjects.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from obiba_opal import UserService, GroupService
23
from tests.utils import make_client
34
import random
@@ -13,6 +14,7 @@ def setup_class(cls):
1314
def teardown_class(cls):
1415
cls.client.close()
1516

17+
@pytest.mark.integration
1618
def test_user_group(self):
1719
client = self.client
1820
service = UserService(client)

0 commit comments

Comments
 (0)