Commit c8e804aa authored by Jeroen F.J. Laros's avatar Jeroen F.J. Laros

Fixed encoding problem, added more tests.

parent 83077c20
......@@ -133,3 +133,74 @@ class TestCLI(object):
cli.cancel(self._log_handle, '127.0.0.1', '123', False)
assert md5_check(
self._log_handle.getvalue(), 'b6a19671cc29806d6468b84695121344')
def test_reformat_transfer_1(self):
readable_transfer = cli._reformat_transfer(
{'files': [], 'status': 'completed'})
assert readable_transfer['number_of_files'] == 0
def test_reformat_transfer_2(self):
readable_transfer = cli._reformat_transfer(
{'files': [{'status': 'uploaded'}], 'status': 'initiated'})
assert readable_transfer['uploaded'] == 1
def test_reformat_transfer_3(self):
readable_transfer = cli._reformat_transfer({
'files': [],
'status': 'completed',
'start_date': '2016-11-25 09:54:57.088350',
'end_date': '2016-11-25 09:55:57.088350'
})
assert readable_transfer['duration'] == '0:01:00'
def test_transfers_summary(self):
self._fake_reply = {
'transfers': [
{
'files': [],
'status': 'completed'
}
]
}
cli.transfers_summary(self._output_handle, '127.0.0.1', '123', False)
assert md5_check(
self._output_handle.getvalue(), '69f8fe82668ffe4f1b1d3fc47906c8d4')
def test_last_transfer_summary(self):
self._fake_reply = {
'transfers': [
{
'files': [],
'status': 'completed'
}
]
}
cli.last_transfer_summary(
self._output_handle, '127.0.0.1', '123', False)
assert md5_check(
self._output_handle.getvalue(), '3f3384fc1041333b147cdb1f46608256')
def test_transfer_summary(self):
self._fake_reply = {
'transfers': [
{
'id': '456',
'files': [],
'status': 'completed'
}
]
}
cli.transfer_summary(
self._output_handle, '127.0.0.1', '123', '456', False)
assert md5_check(
self._output_handle.getvalue(), 'c38201114fb64755abb2747bcd40e88d')
def test_check_metadata(self):
self._fake_reply = {
'type': 'object',
'properties': {
'id': {'type': 'string'}
}
}
cli.check_metadata(StringIO(
'{"id": "test"}\n'), '127.0.0.1', '123', False)
......@@ -242,7 +242,9 @@ def cancel(log_handle, server_name, user_id, ssl_check):
def _write_yaml(output_handle, data):
yaml.safe_dump(data, output_handle, width=76, default_flow_style=False)
output_handle.write(yaml.safe_dump(
data, width=76, default_flow_style=False,
allow_unicode=True).decode('utf-8'))
def _read_timestamp(timestamp):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment