File: test_issue1160.py

package info (click to toggle)
rdflib 6.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 38,248 kB
  • sloc: python: 39,216; sh: 153; makefile: 110
file content (32 lines) | stat: -rw-r--r-- 764 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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",
        )