-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1163 from anatoly-scherbakov/issue-1160-missing-u…
…rl-fragment Issue 1160 missing url fragment
- Loading branch information
Showing
3 changed files
with
99 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import unittest | ||
|
||
from rdflib.parser import create_input_source | ||
|
||
|
||
class ParserTestCase(unittest.TestCase): | ||
def test_empty_arguments(self): | ||
"""create_input_source() function must receive exactly one argument.""" | ||
self.assertRaises( | ||
ValueError, | ||
create_input_source, | ||
) | ||
|
||
def test_too_many_arguments(self): | ||
"""create_input_source() function has a few conflicting arguments.""" | ||
self.assertRaises( | ||
ValueError, | ||
create_input_source, | ||
source='a', | ||
location='b', | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import unittest | ||
from unittest import mock | ||
|
||
import rdflib | ||
|
||
from rdflib import ConjunctiveGraph | ||
from rdflib.parser import URLInputSource | ||
|
||
QUERY = ''' | ||
SELECT DISTINCT ?g | ||
FROM NAMED <http://ns.example.com/named#> | ||
WHERE { | ||
GRAPH ?g { | ||
?s ?p ?o . | ||
} | ||
} | ||
''' | ||
|
||
|
||
class NamedGraphWithFragmentTest(unittest.TestCase): | ||
def test_named_graph_with_fragment(self): | ||
"""Test that fragment part of the URL is not erased.""" | ||
graph = ConjunctiveGraph() | ||
|
||
with mock.patch('rdflib.parser.URLInputSource') as load_mock: | ||
# We have to expect an exception here. | ||
self.assertRaises(Exception, graph.query, QUERY) | ||
|
||
load_mock.assert_called_with( | ||
rdflib.URIRef('http://ns.example.com/named#'), | ||
'nt', | ||
) |