Skip to content

Commit e2a4cb9

Browse files
authored
Merge pull request #94 from RomanoLab/fix/issue-89/fix-test-badge-displaying-failure-on-github-readme-page
chore: Modify GitHub action for Python test
2 parents c14078c + 9ad4eac commit e2a4cb9

File tree

4 files changed

+99
-89
lines changed

4 files changed

+99
-89
lines changed

.github/workflows/ci-app-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
# Define the jobs in the workflow
1414
jobs:
15-
build-all:
15+
build-app:
1616
runs-on: ubuntu-latest
1717

1818
# You can change the default value as needed

.github/workflows/ci-doc-build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
# Define the jobs in the workflow
1414
jobs:
15-
build-all:
15+
build-doc:
1616
runs-on: ubuntu-latest
1717

1818
# You can change the default value as needed
@@ -41,6 +41,7 @@ jobs:
4141
- name: install-dependencies
4242
run: |
4343
python -m pip install --upgrade pip setuptools wheel
44+
python -m pip install .
4445
python -m pip install ".[docs]"
4546
# Modify the name inside the brackets to match the name of the
4647
# extras_require you would like to install. There should be no

.github/workflows/ci-python-package.yml renamed to .github/workflows/ci-python-test.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: ci-python-package
2+
name: ci-python-test
33

44
# Define the events that trigger the workflow
55
on:
@@ -18,7 +18,8 @@ jobs:
1818
strategy:
1919
matrix:
2020
# You can change the default value as needed
21-
python-version: ['3.8', '3.9', '3.10']
21+
# python-version: ['3.8', '3.9', '3.10']
22+
python-version: ['3.8']
2223

2324
steps:
2425
# Step: Check out the repository's code to the runner
@@ -33,4 +34,14 @@ jobs:
3334

3435
# Step: Install project dependencies using pip
3536
- name: install-dependencies
36-
run: python -m pip install --upgrade pip setuptools wheel
37+
run: |
38+
python -m pip install --upgrade pip setuptools wheel
39+
python -m pip install .
40+
41+
# Step: List installed packages
42+
- name: list-packages
43+
run: pip list
44+
45+
# Step: Run tests with Pytest
46+
- name: run-tests
47+
run: python -m pytest

tests/test_db.py

Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,93 @@
1-
from comptox_ai.db import GraphDB
1+
import os
2+
import warnings
23

34
import pytest
4-
import warnings
5-
import os
5+
6+
from comptox_ai.db import GraphDB
67

78
TEST_DIR = os.path.dirname(os.path.realpath(__file__))
89

910

1011
# Module-level scope so we don't keep reconnecting with every test
1112
@pytest.fixture(scope="module")
1213
def G():
13-
G = GraphDB(verbose=True, hostname="neo4j.comptox.ai")
14-
return G
14+
G = GraphDB(verbose=True, hostname="neo4j.comptox.ai")
15+
return G
16+
1517

1618
class TestGraphDB(object):
17-
18-
<<<<<<< HEAD
19-
=======
20-
21-
>>>>>>> master
22-
def test_neo4j_connection_does_exist(self, G):
23-
with warnings.catch_warnings():
24-
# Supress the ExperimentalWarning for now
25-
warnings.simplefilter("ignore")
26-
assert G._driver.verify_connectivity() is not None
27-
28-
def test_cypher_query_does_run(self, G):
29-
x = G.run_cypher("RETURN 'hello';")
30-
assert len(x[0]) > 0
31-
32-
def test_dsstox_to_casrn_converts(self, G):
33-
converted_ids = G.convert_ids(
34-
node_type='Chemical',
35-
from_id='xrefDTXSID',
36-
to_id='xrefCasRN',
37-
ids=['DTXSID40857898', 'DTXSID40858749']
38-
)
39-
40-
# Hopefully DSSTOX -> CASRN mappings are stable between versions...
41-
assert converted_ids == ['69313-80-0', '4559-79-9']
42-
43-
## THE FOLLOWING ARE OBSOLETE UNTIL GDS GRAPH CATALOG IS COMPATIBLE WITH
44-
# def test_raise_when_config_file_not_found(self):
45-
# with pytest.raises(RuntimeError) as e_info:
46-
# G_pre = GraphDB(config_file="/dev/null")
47-
48-
# def test_raise_when_bad_config_given(self):
49-
# bad_config_file = os.path.join(TEST_DIR, 'badconfig.txt')
50-
# with pytest.raises(RuntimeError) as e_info:
51-
# G_pre = GraphDB(config_file=bad_config_file)
52-
53-
# def test_raise_when_database_unavailable(self):
54-
# unavail_config_file = os.path.join(TEST_DIR, 'unavailconfig.txt')
55-
# with pytest.raises(RuntimeError) as e_info:
56-
# G_pre = GraphDB(config_file=unavail_config_file)
57-
## STRING PROPERTIES:
58-
59-
# def test_gds_list_existing_graphs(self, G):
60-
# x = G.list_existing_graphs()
61-
# assert isinstance(x, list)
62-
63-
# def test_gds_delete_existing_graphs(self, G):
64-
# x = G.drop_all_existing_graphs()
65-
66-
# y = G.list_existing_graphs()
67-
68-
# assert len(y) is 0
69-
70-
# def test_gds_create_graph_native_projection(self, G):
71-
# newgraph1 = G.build_graph_native_projection(
72-
# "testgraph1",
73-
# ["Chemical", "Disease"],
74-
# "*",
75-
# )
76-
77-
# def test_gds_new_num_graphs_is_1(self, G):
78-
# y = G.list_existing_graphs()
79-
# assert len(y) == 1
80-
81-
# def test_gds_delete_graph_native_projection(self, G):
82-
# x = G.drop_existing_graph("testgraph1")
83-
# assert x['graphName'] == "testgraph1"
84-
85-
# def test_gds_create_graph_cypher_projection(self, G):
86-
# newgraph2 = G.build_graph_cypher_projection(
87-
# "testgraph2",
88-
# "MATCH (n) WHERE n:Chemical OR n:Disease RETURN id(n) AS id, labels(n) AS labels",
89-
# "MATCH (c:Chemical)-->(d:Disease) RETURN id(c) as source, id(d) as target"
90-
# )
91-
92-
# def test_gds_delete_graph_cypher_projection(self, G):
93-
# # Note: this test will fail if the previous test fails
94-
# x = G.drop_existing_graph("testgraph2")
95-
# assert x['graphName'] == "testgraph2"
19+
20+
def test_neo4j_connection_does_exist(self, G):
21+
with warnings.catch_warnings():
22+
# Supress the ExperimentalWarning for now
23+
warnings.simplefilter("ignore")
24+
assert G._driver.verify_connectivity() is not None
25+
26+
def test_cypher_query_does_run(self, G):
27+
x = G.run_cypher("RETURN 'hello';")
28+
assert len(x[0]) > 0
29+
30+
def test_dsstox_to_casrn_converts(self, G):
31+
converted_ids = G.convert_ids(
32+
node_type='Chemical',
33+
from_id='xrefDTXSID',
34+
to_id='xrefCasRN',
35+
ids=['DTXSID40857898', 'DTXSID40858749']
36+
)
37+
38+
# Hopefully DSSTOX -> CASRN mappings are stable between versions...
39+
assert converted_ids == ['69313-80-0', '4559-79-9']
40+
41+
# THE FOLLOWING ARE OBSOLETE UNTIL GDS GRAPH CATALOG IS COMPATIBLE WITH
42+
# def test_raise_when_config_file_not_found(self):
43+
# with pytest.raises(RuntimeError) as e_info:
44+
# G_pre = GraphDB(config_file="/dev/null")
45+
46+
# def test_raise_when_bad_config_given(self):
47+
# bad_config_file = os.path.join(TEST_DIR, 'badconfig.txt')
48+
# with pytest.raises(RuntimeError) as e_info:
49+
# G_pre = GraphDB(config_file=bad_config_file)
50+
51+
# def test_raise_when_database_unavailable(self):
52+
# unavail_config_file = os.path.join(TEST_DIR, 'unavailconfig.txt')
53+
# with pytest.raises(RuntimeError) as e_info:
54+
# G_pre = GraphDB(config_file=unavail_config_file)
55+
# STRING PROPERTIES:
56+
57+
# def test_gds_list_existing_graphs(self, G):
58+
# x = G.list_existing_graphs()
59+
# assert isinstance(x, list)
60+
61+
# def test_gds_delete_existing_graphs(self, G):
62+
# x = G.drop_all_existing_graphs()
63+
64+
# y = G.list_existing_graphs()
65+
66+
# assert len(y) is 0
67+
68+
# def test_gds_create_graph_native_projection(self, G):
69+
# newgraph1 = G.build_graph_native_projection(
70+
# "testgraph1",
71+
# ["Chemical", "Disease"],
72+
# "*",
73+
# )
74+
75+
# def test_gds_new_num_graphs_is_1(self, G):
76+
# y = G.list_existing_graphs()
77+
# assert len(y) == 1
78+
79+
# def test_gds_delete_graph_native_projection(self, G):
80+
# x = G.drop_existing_graph("testgraph1")
81+
# assert x['graphName'] == "testgraph1"
82+
83+
# def test_gds_create_graph_cypher_projection(self, G):
84+
# newgraph2 = G.build_graph_cypher_projection(
85+
# "testgraph2",
86+
# "MATCH (n) WHERE n:Chemical OR n:Disease RETURN id(n) AS id, labels(n) AS labels",
87+
# "MATCH (c:Chemical)-->(d:Disease) RETURN id(c) as source, id(d) as target"
88+
# )
89+
90+
# def test_gds_delete_graph_cypher_projection(self, G):
91+
# # Note: this test will fail if the previous test fails
92+
# x = G.drop_existing_graph("testgraph2")
93+
# assert x['graphName'] == "testgraph2"

0 commit comments

Comments
 (0)