Parameterize test data (#116)
Browse files- .github/workflows/ci-cd.yaml +2 -2
- features/graphs.feature +7 -3
- features/steps/graphs.py +24 -16
- german.yaml +15 -0
- requirements.txt +1 -0
- tests/test_vocabulary_parser.py +1 -0
.github/workflows/ci-cd.yaml
CHANGED
@@ -160,7 +160,7 @@ jobs:
|
|
160 |
- name: Install dependencies
|
161 |
run: pip3 install -r requirements.txt
|
162 |
- name: Run acceptance tests
|
163 |
-
run: behave
|
164 |
- name: Copy over data onto host
|
165 |
run: docker cp data-loader:/data .
|
166 |
- name: Test image build
|
@@ -191,7 +191,7 @@ jobs:
|
|
191 |
readme-filepath: README.md
|
192 |
|
193 |
triggering:
|
194 |
-
name: Triggering data
|
195 |
needs: [sync-to-huggingface-space, docker]
|
196 |
if: github.ref == 'refs/heads/master'
|
197 |
runs-on: ubuntu-latest
|
|
|
160 |
- name: Install dependencies
|
161 |
run: pip3 install -r requirements.txt
|
162 |
- name: Run acceptance tests
|
163 |
+
run: behave -v
|
164 |
- name: Copy over data onto host
|
165 |
run: docker cp data-loader:/data .
|
166 |
- name: Test image build
|
|
|
191 |
readme-filepath: README.md
|
192 |
|
193 |
triggering:
|
194 |
+
name: Triggering data loader CI/CD
|
195 |
needs: [sync-to-huggingface-space, docker]
|
196 |
if: github.ref == 'refs/heads/master'
|
197 |
runs-on: ubuntu-latest
|
features/graphs.feature
CHANGED
@@ -13,6 +13,10 @@
|
|
13 |
# limitations under the License.
|
14 |
Feature: Neo4J in Docker shows expected graphs
|
15 |
|
16 |
-
Scenario:
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
13 |
# limitations under the License.
|
14 |
Feature: Neo4J in Docker shows expected graphs
|
15 |
|
16 |
+
Scenario Outline: Vocabulary Linking
|
17 |
+
When we expand "<term>" by <hops> hops at most
|
18 |
+
Then we get these distinct nodes: <nodes>
|
19 |
+
|
20 |
+
Examples: Ancient Greek
|
21 |
+
| term | hops | nodes |
|
22 |
+
| δέ | 3 | {"aber lieber", "aber", "but", "sed", "ἀλλά", "δέ", "and", "τε", "et", "καί", "also", "even", "δ᾽"} |
|
features/steps/graphs.py
CHANGED
@@ -11,32 +11,40 @@
|
|
11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
14 |
-
|
15 |
-
from neo4j import GraphDatabase
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
21 |
|
22 |
|
23 |
-
@
|
24 |
-
def step_impl(context):
|
25 |
driver = GraphDatabase.driver("neo4j://localhost:7687", auth=("not used", "not used"))
|
26 |
|
27 |
with driver.session() as session:
|
28 |
-
result = parse_apoc_path_expand_result(session.run(
|
29 |
-
"""
|
30 |
-
MATCH (node{label:"δέ"})
|
31 |
-
CALL apoc.path.expand(node, "LINK", null, 1, 3)
|
32 |
-
YIELD path
|
33 |
-
RETURN path;
|
34 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
))
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
|
41 |
|
42 |
def parse_apoc_path_expand_result(result):
|
|
|
11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
14 |
+
import logging
|
|
|
15 |
|
16 |
+
from behave import then
|
17 |
+
from behave import when
|
18 |
+
from hamcrest import assert_that
|
19 |
+
from hamcrest import equal_to
|
20 |
+
from neo4j import GraphDatabase
|
21 |
|
22 |
+
# Set up the logging
|
23 |
+
logging.basicConfig(level=logging.INFO)
|
24 |
+
neo4j_logger = logging.getLogger("neo4j")
|
25 |
+
neo4j_logger.setLevel(logging.DEBUG) # Log all queries
|
26 |
|
27 |
|
28 |
+
@when('we expand "{term}" by {num_hops:d} hops at most')
|
29 |
+
def step_impl(context, term, num_hops):
|
30 |
driver = GraphDatabase.driver("neo4j://localhost:7687", auth=("not used", "not used"))
|
31 |
|
32 |
with driver.session() as session:
|
33 |
+
context.result = parse_apoc_path_expand_result(session.run(
|
|
|
|
|
|
|
|
|
|
|
34 |
"""
|
35 |
+
MATCH (node{label:$term})
|
36 |
+
CALL apoc.path.expand(node, "LINK", null, 1, $num_hops)
|
37 |
+
YIELD path
|
38 |
+
RETURN path;
|
39 |
+
""",
|
40 |
+
term=term,
|
41 |
+
num_hops=num_hops
|
42 |
))
|
43 |
|
44 |
+
|
45 |
+
@then('we get these distinct nodes: {nodes}')
|
46 |
+
def step_impl(context, nodes):
|
47 |
+
assert_that(set(context.result["nodes"]), equal_to(eval(nodes)))
|
48 |
|
49 |
|
50 |
def parse_apoc_path_expand_result(result):
|
german.yaml
CHANGED
@@ -6083,6 +6083,21 @@ vocabulary:
|
|
6083 |
- (adv.) over there
|
6084 |
- (adv.) on the other side
|
6085 |
audio: https://upload.wikimedia.org/wikipedia/commons/5/51/De-dr%C3%BCben.ogg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6086 |
|
6087 |
|
6088 |
|
|
|
6083 |
- (adv.) over there
|
6084 |
- (adv.) on the other side
|
6085 |
audio: https://upload.wikimedia.org/wikipedia/commons/5/51/De-dr%C3%BCben.ogg
|
6086 |
+
- term: die Schweinerei
|
6087 |
+
definition: the mess
|
6088 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/a/a5/De-Schweinerei.ogg
|
6089 |
+
declension:
|
6090 |
+
- ["", singular, plural ]
|
6091 |
+
- [nominative, Schweinerei, Schweinereien]
|
6092 |
+
- [genitive, Schweinerei, Schweinereien]
|
6093 |
+
- [dative, Schweinerei, Schweinereien]
|
6094 |
+
- [accusative, Schweinerei, Schweinereien]
|
6095 |
+
- term: vorhin
|
6096 |
+
definition: (adv.) recently
|
6097 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/5/5d/De-vorhin.ogg
|
6098 |
+
- term: wegen
|
6099 |
+
definition: (prep.) because of
|
6100 |
+
audio: https://upload.wikimedia.org/wikipedia/commons/c/c1/De-wegen2.ogg
|
6101 |
|
6102 |
|
6103 |
|
requirements.txt
CHANGED
@@ -7,3 +7,4 @@ isort
|
|
7 |
|
8 |
behave
|
9 |
neo4j
|
|
|
|
7 |
|
8 |
behave
|
9 |
neo4j
|
10 |
+
PyHamcrest
|
tests/test_vocabulary_parser.py
CHANGED
@@ -11,6 +11,7 @@
|
|
11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
|
|
14 |
import unittest
|
15 |
|
16 |
import yaml
|
|
|
11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
14 |
+
|
15 |
import unittest
|
16 |
|
17 |
import yaml
|