Skip to content

Fix issues caused by version 1.6 #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/itoolkit/db2/idb2call.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ def call(self, itool):
Returns:
The XML returned from XMLSERVICE
"""
super(iDB2Call, self).call(itool)
return super(iDB2Call, self).call(itool)
2 changes: 1 addition & 1 deletion src/itoolkit/lib/ilibcall.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def call(self, itool):
Returns:
The XML returned from XMLSERVICE
"""
super(iLibCall, self).call(itool)
return super(iLibCall, self).call(itool)
2 changes: 1 addition & 1 deletion src/itoolkit/rest/irestcall.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def call(self, itool):
Returns:
The XML returned from XMLSERVICE
"""
super(iRestCall, self).call(itool)
return super(iRestCall, self).call(itool)
16 changes: 12 additions & 4 deletions tests/test_unit_idb2call.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
def test_idb2call_transport_minimal_callproc(database_callproc):
transport = iDB2Call(database_callproc)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

cursor = database_callproc.cursor()

Expand All @@ -26,7 +28,9 @@ def test_idb2call_transport_minimal_callproc(database_callproc):
def test_idb2call_transport_minimal_execute(database_execute):
transport = iDB2Call(database_execute)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

cursor = database_execute.cursor()

Expand All @@ -48,7 +52,9 @@ class MockConn(object):
conn = MockConn()
transport = iDB2Call(conn)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

Connection.assert_called_once_with(conn)

Expand All @@ -74,7 +80,9 @@ class MockConn(object):

transport = iDB2Call(user, password)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

kwargs = dict(database='*LOCAL', user=user, password=password)
connect.assert_called_once_with(**kwargs)
Expand Down
29 changes: 19 additions & 10 deletions tests/test_unit_irestcall.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
def mock_http_urlopen(mocker):
mock_urlopen = mocker.patch('itoolkit.transport.http.urlopen')
mock_response = mocker.Mock()
mock_response.read.side_effect = XMLIN.encode('utf-8')
mock_response.read.side_effect = (XMLIN.encode('utf-8'),)
mock_urlopen.return_value = mock_response

return mock_urlopen
Expand Down Expand Up @@ -66,9 +66,6 @@ def assert_urlopen_params_correct(mock_urlopen, url, uid, pwd, db2='*LOCAL',
'xmlout': int(xmlout)
}).encode("utf-8"))





def test_irestcall_transport_minimal(mocker):
mock_urlopen = mock_http_urlopen(mocker)
Expand All @@ -79,7 +76,9 @@ def test_irestcall_transport_minimal(mocker):

transport = iRestCall(url, user, password)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

assert_urlopen_params_correct(
mock_urlopen,
Expand All @@ -100,7 +99,9 @@ def test_irestcall_transport_without_password(mocker, monkeypatch):

transport = iRestCall(url, user, password)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

assert_urlopen_params_correct(
mock_urlopen,
Expand All @@ -120,7 +121,9 @@ def test_irestcall_transport_with_database(mocker):

transport = iRestCall(url, user, password, idb2=database)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

assert_urlopen_params_correct(
mock_urlopen,
Expand All @@ -141,7 +144,9 @@ def test_irestcall_transport_with_ipc(mocker):

transport = iRestCall(url, user, password, ipc=ipc)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

assert_urlopen_params_correct(
mock_urlopen,
Expand All @@ -162,7 +167,9 @@ def test_irestcall_transport_with_ctl(mocker):

transport = iRestCall(url, user, password, ictl=ctl)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

assert_urlopen_params_correct(
mock_urlopen,
Expand Down Expand Up @@ -198,7 +205,9 @@ def allow_deprecated():
with allow_deprecated():
transport = iRestCall(url, user, password, isiz=size)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))
assert len(recwarn) == 2
assert isinstance(recwarn[0].category, type(DeprecationWarning))
assert isinstance(recwarn[1].category, type(DeprecationWarning))
Expand Down
20 changes: 14 additions & 6 deletions tests/test_unit_transport_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
def test_database_transport_callproc(database_callproc):
transport = DatabaseTransport(database_callproc)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

cursor = database_callproc.cursor()

Expand All @@ -16,7 +18,9 @@ def test_database_transport_callproc(database_callproc):
def test_database_transport_execute(database_execute):
transport = DatabaseTransport(database_execute)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

cursor = database_execute.cursor()

Expand All @@ -28,27 +32,31 @@ def test_database_transport_execute_schema(database_execute):
schema = 'MYSCHEMA'
transport = DatabaseTransport(database_execute, schema=schema)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

cursor = database_execute.cursor()

cursor.execute.assert_called_once()
cursor.__iter__.assert_called_once()

assert len(cursor.execute.call_args[0]) > 0
assert schema in cursor.execute.call_args[0][1] # argument 0 is self
assert schema in cursor.execute.call_args[0][0]


def test_database_transport_callproc_schema(database_execute):
schema = 'MYSCHEMA'
transport = DatabaseTransport(database_execute, schema=schema)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

cursor = database_execute.cursor()

cursor.execute.assert_called_once()
cursor.__iter__.assert_called_once()

assert len(cursor.execute.call_args[0]) > 0
assert schema in cursor.execute.call_args[0][1] # argument 0 is self
assert schema in cursor.execute.call_args[0][0]
10 changes: 7 additions & 3 deletions tests/test_unit_transport_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
def mock_http_urlopen(mocker):
mock_urlopen = mocker.patch('itoolkit.transport.http.urlopen')
mock_response = mocker.Mock()
mock_response.read.side_effect = XMLIN.encode('utf-8')
mock_response.read.side_effect = (XMLIN.encode('utf-8'), )
mock_urlopen.return_value = mock_response

return mock_urlopen
Expand Down Expand Up @@ -71,7 +71,9 @@ def test_http_transport_minimal(mocker):

transport = HttpTransport(url, user, password)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

assert_urlopen_params_correct(
mock_urlopen,
Expand All @@ -91,7 +93,9 @@ def test_http_transport_with_database(mocker):

transport = HttpTransport(url, user, password, database=database)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

assert_urlopen_params_correct(
mock_urlopen,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_unit_transport_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def test_ssh_transport_minimal(mocker):

transport = SshTransport(ssh_client)
tk = iToolKit()
transport.call(tk)
out = transport.call(tk)

assert isinstance(out, (bytes, str))

command = "/QOpenSys/pkgs/bin/xmlservice-cli"
ssh_client.exec_command.assert_called_once_with(command)