Esempio n. 1
0
 def test_validate_graphs_restriction_raises_error(self, mocked_filter_values):
     expected_message = "Classes in the range of predicate 'predicate1' are not in graphs ['graph3']"
     params = {
         "graphs": ["graph1", "graph2", "graph3"],
         "target": "predicate1"
     }
     try:
         suggest._validate_graph_restriction(params, None)  # None because filter_values is mocked
     except HTTPError as e:
         self.assertEqual(e.status_code, 400)
         self.assertEqual(e.log_message, expected_message)
     else:
         self.fail("a HTTPError should be raised")
Esempio n. 2
0
 def test_validate_graphs_restriction_raises_error_for_graphs_without_instances(self, mocked_settings, mocked_filter_values):
     expected_message = "Classes in the range of predicate 'predicate1' are in graphs without instances," + \
         " such as: ['graph_without_instances1', 'graph_without_instances2']"
     params = {
         "target": "predicate1"
     }
     try:
         suggest._validate_graph_restriction(params, None)  # None because filter_values is mocked
     except HTTPError as e:
         self.assertEqual(e.status_code, 400)
         self.assertEqual(e.log_message, expected_message)
     else:
         self.fail("a HTTPError should be raised")
Esempio n. 3
0
 def test_validate_graphs_restriction_raises_error_for_graphs_without_instances(self, mocked_settings, mocked_filter_values):
     expected_message = "Classes in the range of predicate 'predicate1' are in graphs without instances," + \
         " such as: ['graph_without_instances1', 'graph_without_instances2']"
     params = {
         "target": "predicate1"
     }
     try:
         suggest._validate_graph_restriction(params, None)  # None because filter_values is mocked
     except HTTPError as e:
         self.assertEqual(e.status_code, 400)
         self.assertEqual(e.log_message, expected_message)
     else:
         self.fail("a HTTPError should be raised")
Esempio n. 4
0
 def test_validate_graphs_restriction_raises_error(self, mocked_filter_values):
     expected_message = "Classes in the range of predicate 'predicate1' are not in graphs ['graph3']"
     params = {
         "graphs": ["graph1", "graph2", "graph3"],
         "target": "predicate1"
     }
     try:
         suggest._validate_graph_restriction(params, None)  # None because filter_values is mocked
     except HTTPError as e:
         self.assertEqual(e.status_code, 400)
         self.assertEqual(e.log_message, expected_message)
     else:
         self.fail("a HTTPError should be raised")
Esempio n. 5
0
    def test_validate_graphs_restriction_with_no_restriction_param(self, mocked_filter_values):
        expected = ["graph1", "graph2"]

        params = {}

        response = suggest._validate_graph_restriction(params, None)  # None because filter_values is mocked
        self.assertListEqual(sorted(expected), sorted(response))
Esempio n. 6
0
    def test_validate_graphs_restriction_with_no_restriction_param(self, mocked_filter_values):
        expected = ["graph1", "graph2"]

        params = {}

        response = suggest._validate_graph_restriction(params, None)  # None because filter_values is mocked
        self.assertListEqual(sorted(expected), sorted(response))
Esempio n. 7
0
    def test_validate_graphs_restriction(self, mocked_filter_values):
        expected = ["graph1"]

        params = {
            "graphs": ["graph1"]
        }

        response = suggest._validate_graph_restriction(params, None)  # None because filter_values is mocked
        self.assertEqual(expected, response)
Esempio n. 8
0
    def test_validate_graphs_restriction(self, mocked_filter_values):
        expected = ["graph1"]

        params = {
            "graphs": ["graph1"]
        }

        response = suggest._validate_graph_restriction(params, None)  # None because filter_values is mocked
        self.assertEqual(expected, response)