Пример #1
0
 def test_make_claim_qualifiers_sparql_detect_noclaim(self):
     make_claim_qualifiers_sparql('P123', '{NOCLAIM[prop:val]}')
     self.mock_claim_sparql.assert_not_called()
     self.mock_string_sparql.assert_not_called()
     self.mock_noclaim_sparql.assert_called_once_with('prop',
                                                      'val',
                                                      qualifier=True)
Пример #2
0
 def test_make_claim_qualifiers_sparql_detect_string(self):
     make_claim_qualifiers_sparql('P123', '{STRING[prop:"string"]}')
     self.mock_claim_sparql.assert_not_called()
     self.mock_string_sparql.assert_called_once_with('prop',
                                                     '"string"',
                                                     qualifier=True)
     self.mock_noclaim_sparql.assert_not_called()
Пример #3
0
 def test_make_claim_qualifiers_sparql_multiple_qualifiers_same(self):
     make_claim_qualifiers_sparql('P123',
                                  '{CLAIM[prop:val] OR CLAIM[prop2:val2]}')
     expected_calls = [
         mock.call('prop', 'val', qualifier=True),
         mock.call('prop2', 'val2', qualifier=True)
     ]
     self.mock_claim_sparql.assert_has_calls(expected_calls)
     self.mock_string_sparql.assert_not_called()
     self.mock_noclaim_sparql.assert_not_called()
Пример #4
0
 def test_make_claim_qualifiers_sparql_multiple_qualifiers_different(self):
     expected = "%s p:P123 ?dummy0 . { sparql } UNION { sparql } "
     result = make_claim_qualifiers_sparql(
         'P123', '{CLAIM[prop:val] OR STRING[prop:string]}')
     self.assertEqual(result, expected)
     self.mock_claim_sparql.assert_called_once_with('prop',
                                                    'val',
                                                    qualifier=True)
     self.mock_string_sparql.assert_called_once_with('prop',
                                                     'string',
                                                     qualifier=True)
     self.mock_noclaim_sparql.assert_not_called()
Пример #5
0
 def test_make_claim_qualifiers_sparql_multiple_qualifiers_inside(self):
     expected = "%s p:P123 ?dummy0 . { sparql } UNION { sparql } "
     result = make_claim_qualifiers_sparql('P123',
                                           '{CLAIM[prop:val,prop2:val2]}')
     self.assertEqual(result, expected)
     expected_calls = [
         mock.call('prop', 'val', qualifier=True),
         mock.call('prop2', 'val2', qualifier=True)
     ]
     self.mock_claim_sparql.assert_has_calls(expected_calls)
     self.mock_string_sparql.assert_not_called()
     self.mock_noclaim_sparql.assert_not_called()
Пример #6
0
 def test_make_claim_qualifiers_sparql_single_qualifiers_no_p(self):
     expected = "%s p:P123 ?dummy0 . { sparql } "
     result = make_claim_qualifiers_sparql('123', '{CLAIM[prop:val]}')
     self.assertEqual(result, expected)
Пример #7
0
 def test_make_claim_qualifiers_sparql_unsupported(self):
     with self.assertRaises(NotImplementedError):
         make_claim_qualifiers_sparql('P123', '{TREE[Q456]}')
     self.mock_claim_sparql.assert_not_called()
     self.mock_string_sparql.assert_not_called()
     self.mock_noclaim_sparql.assert_not_called()