Exemplo n.º 1
0
    def test_other__service2(self):
        tc_desc = 'Test if "service" along with its service string is properly translated ' \
                  'into the query text. ' \
                  'The query must also be executable and shall not violate any SPARQL query syntax.'
        try:
            query_tree = parser.parseQuery(self.query_text)
        except Exception as e:
            print(e)
            return Test(test_number=25,
                        tc_desc=tc_desc,
                        expected_result="0",
                        actual_result=
                        "Not executable. Error returned from parseQuery().")
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(test_number=25,
                    tc_desc=tc_desc,
                    expected_result=self.query_from_algebra,
                    actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 2
0
    def test_other__service1(self):
        tc_desc = (
            "Test if a nested service pattern is properly translated "
            "into the query text. "
            "The query must also be executable and shall not violate any SPARQL query syntax."
        )
        try:
            query_tree = parser.parseQuery(self.query_text)
        except Exception as e:
            print(e)
            return Test(
                test_number=24,
                tc_desc=tc_desc,
                expected_result="0",
                actual_result="Not executable. Error returned from parseQuery",
            )
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=24,
            tc_desc=tc_desc,
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra,
        )

        return test
Exemplo n.º 3
0
    def test_functions__functional_forms(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)

        test = Test(
            test_number=1,
            tc_desc=
            'Test if functional forms are properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        try:
            self.rdf_engine.get_data(self.query_from_query_from_algebra,
                                     yn_timestamp_query=False)
        except Exception as e:
            print(e)
            print(
                "The query must be executable. Otherwise, the test has failed."
            )
            return Test(test_number=test.test_number,
                        tc_desc=test.tc_desc,
                        expected_result="0",
                        actual_result="not_executable")

        return test
Exemplo n.º 4
0
    def test_property_path__negated_property_set(self):
        tc_desc = 'Test if a negated property set gets properly translated into the query text. ' \
                  'The query must also be executable and shall not violate any SPARQL query syntax.'
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        try:
            self.query_from_algebra = translateAlgebra(query_algebra)
        except TypeError as e:
            print(e)
            return Test(
                test_number=29,
                tc_desc=tc_desc,
                expected_result="0",
                actual_result=
                "Not executable. n3() method of NegatedPath class should be fixed. "
            )

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(test_number=29,
                    tc_desc=tc_desc,
                    expected_result=self.query_from_algebra,
                    actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 5
0
    def test_graph_patterns__left_join(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=16,
            tc_desc=
            'Test if "left join" gets properly translated into "OPTIONAL {...}" in the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 6
0
    def test_graph_patterns__aggregate_join(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=8,
            tc_desc='Test if aggregate join including all aggregation functions '
            'are properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 7
0
    def test_graph_patterns__bgp(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=9,
            tc_desc=
            'Test if basic graph patterns are properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 8
0
    def test_functions__functions_on_dates_and_time(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=7,
            tc_desc=
            'Test if functions on dates and time are properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 9
0
    def test_solution_modifiers__slice(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=37,
            tc_desc="Test if slice get properly translated into the limit and offset. "
            "The query must also be executable and shall not violate any SPARQL query syntax.",
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra,
        )

        return test
Exemplo n.º 10
0
    def test_property_path__alternative_path(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=27,
            tc_desc="Test if an alternative path gets properly translated into the query text. "
            "The query must also be executable and shall not violate any SPARQL query syntax.",
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra,
        )

        return test
Exemplo n.º 11
0
    def test_other__values(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=26,
            tc_desc=
            'Test if "values" gets properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 12
0
    def test_operators__conditional_or(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=21,
            tc_desc=
            'Test if "conditional ors (||)" are properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 13
0
    def test_operators__unary(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=23,
            tc_desc="Test if unary expressions are properly translated into the query text. "
            "The query must also be executable and shall not violate any SPARQL query syntax.",
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra,
        )

        return test
Exemplo n.º 14
0
    def test_functions__functional_forms_not_exists(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=2,
            tc_desc=
            'Test if the not exists form is properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 15
0
    def test_property_path__zero_or_one_path(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=33,
            tc_desc=
            'Test if a zeroOrOne path gets properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 16
0
    def test_solution_modifiers__to_multiset(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=38,
            tc_desc=
            'Test if subqueries get properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 17
0
    def test_integration__complex_query1(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=39,
            tc_desc=
            'Test a query with multiple graph patterns and solution modifiers '
            'gets properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test
Exemplo n.º 18
0
    def test_graph_patterns__extend(self):
        query_tree = parser.parseQuery(self.query_text)
        query_algebra = algebra.translateQuery(query_tree)
        self.query_from_algebra = translateAlgebra(query_algebra)

        query_tree_2 = parser.parseQuery(self.query_from_algebra)
        query_algebra_2 = algebra.translateQuery(query_tree_2)
        self.query_from_query_from_algebra = translateAlgebra(query_algebra_2)
        _pprint_query(self.query_from_query_from_algebra)

        test = Test(
            test_number=10,
            tc_desc=
            'Test if "extend" (=Bind explicitly or implicitly in projection) '
            'gets properly translated into the query text. '
            'The query must also be executable and shall not violate any SPARQL query syntax.',
            expected_result=self.query_from_algebra,
            actual_result=self.query_from_query_from_algebra)

        return test