Skip to content

Commit

Permalink
Rework test for task 4
Browse files Browse the repository at this point in the history
  • Loading branch information
KubEF committed May 6, 2024
1 parent ff9f4d4 commit afe9860
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tests/autotests/test_task4.py
Expand Up @@ -6,7 +6,7 @@
from copy import deepcopy
import pytest
from regex_constants import REGEXES
from helper import generate_rnd_start_and_final
from helper import generate_rnd_start_and_final, rpq_dict_to_set
from fixtures import graph

# Fix import statements in try block to run tests
Expand All @@ -30,15 +30,11 @@ def test(self, graph, query) -> None:
graph_to_nfa(deepcopy(graph), deepcopy(start_nodes), deepcopy(final_nodes))
)
constraint_fa = FiniteAutomaton(regex_to_dfa(query))
reachable: dict = reachability_with_constraints(
deepcopy(fa), deepcopy(constraint_fa)
reachable = rpq_dict_to_set(
reachability_with_constraints(deepcopy(fa), deepcopy(constraint_fa))
)
reachable = {k: v for k, v in reachable.items() if len(v) != 0}
ends = paths_ends(
deepcopy(graph), deepcopy(start_nodes), deepcopy(final_nodes), query
)

assert len(set(reachable.keys())) == len(set(map(lambda x: x[0], ends)))

for start, final in ends:
assert start in reachable.keys() and final in reachable[start]
assert set(ends) == reachable

0 comments on commit afe9860

Please sign in to comment.