コード例 #1
0
ファイル: test_load.py プロジェクト: yangxhcaf/cymod
    def test_custom_labels_applied_for_tabular(self):
        """Custom labels should be applied via load_tabular."""
        gl = GraphLoader()
        gl.load_tabular(
            self.demo_explicit_table,
            "start",
            "end",
            labels=NodeLabels({"State": "MyState"}),
        )

        query_iter = gl.iterqueries()

        query1 = CypherQuery(
            'MERGE (start:MyState {code:"state1"}) ' +
            'MERGE (end:MyState {code:"state2"}) ' +
            "MERGE (start)<-[:SOURCE]-(trans:Transition)-[:TARGET]->(end) " +
            'MERGE (cond:Condition {cond:"low"})-[:CAUSES]->(trans);')

        query2 = CypherQuery(
            'MERGE (start:MyState {code:"state2"}) ' +
            'MERGE (end:MyState {code:"state3"}) ' +
            "MERGE (start)<-[:SOURCE]-(trans:Transition)-[:TARGET]->(end) " +
            'MERGE (cond:Condition {cond:"high"})-[:CAUSES]->(trans);')

        self.assertEqual(six.next(query_iter).statement, query1.statement)
        self.assertEqual(six.next(query_iter).statement, query2.statement)
        self.assertRaises(StopIteration, partial(six.next, query_iter))
コード例 #2
0
ファイル: test_load.py プロジェクト: yangxhcaf/cymod
    def test_global_params_specified_for_tabular(self):
        """Global params specified in load_tabular should appear in queries."""
        gl = GraphLoader()
        gl.load_tabular(
            self.demo_explicit_table,
            "start",
            "end",
            global_params={
                "id": "test-id",
                "version": 2
            },
        )

        query_iter = gl.iterqueries()

        query1 = CypherQuery(
            'MERGE (start:State {code:"state1", id:"test-id", version:2}) ' +
            'MERGE (end:State {code:"state2", id:"test-id", version:2}) ' +
            "MERGE (start)<-[:SOURCE]-" +
            '(trans:Transition {id:"test-id", version:2})-[:TARGET]->(end) ' +
            'MERGE (cond:Condition {cond:"low", id:"test-id", version:2})' +
            "-[:CAUSES]->(trans);")

        query2 = CypherQuery(
            'MERGE (start:State {code:"state2", id:"test-id", version:2}) ' +
            'MERGE (end:State {code:"state3", id:"test-id", version:2}) ' +
            "MERGE (start)<-[:SOURCE]-" +
            '(trans:Transition {id:"test-id", version:2})-[:TARGET]->(end) ' +
            'MERGE (cond:Condition {cond:"high", id:"test-id", version:2})' +
            "-[:CAUSES]->(trans);")

        self.assertEqual(six.next(query_iter).statement, query1.statement)
        self.assertEqual(six.next(query_iter).statement, query2.statement)
        self.assertRaises(StopIteration, partial(six.next, query_iter))
コード例 #3
0
ファイル: test_load.py プロジェクト: yangxhcaf/cymod
    def test_coded_transition_table_can_be_used(self):
        trans = EnvrStateAliasTranslator()

        gl = GraphLoader()
        try:
            gl.load_tabular(self.demo_coded_table,
                            "start",
                            "end",
                            state_alias_translator=trans)
        except Exception:
            self.fail("Could not use state_alias_translator in load_tabular.")