I am Python newbie. Trying to use this module https://pypi.org/project/sparql-client/
module.py
from sparql import Service
class MyModule:
def my_method(self):
s = Service('https://my-endpoint:8182/sparql', "utf-8", "GET")
statement = """
MOVE uri:temp_graph TO uri:user_graph
ADD uri:temp_graph TO uri:user_graph
""".format(user_graph="http://aws.amazon.com/account-uid",
temp_graph="http://aws.amazon.com/account-uid-temp")
s.query(statement)
I am trying to test it
test_module.py
import unittest
from unittest.mock import patch, Mock
class TestModule(unittest.TestCase):
@patch('sparql.Service', autospec=True)
def test_mymethod(self, sparql_mock):
sparql_instance = sparql_mock.return_value
sparql_instance.query = Mock()
While running I get
File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/mock.py", line 1564, in <lambda>
getter = lambda: _importer(target)
File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/mock.py", line 1236, in _importer
thing = __import__(import_path)
File "/usr/local/lib/python3.9/site-packages/sparql.py", line 50, in <module>
from base64 import encodestring
ImportError: cannot import name 'encodestring' from 'base64' (/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/base64.py)
So it can not import this line
https://github.com/eea/sparql-client/blob/master/sparql.py#L50
Any idea how to fix this?