Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
uploadfiles unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
escapewindow committed Jul 6, 2016
1 parent 8fb05ce commit 053fa77
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_signing_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,26 @@ def test_cached_fn_nss():
m.assert_called_once_with('echo "%s"' % target, shell=True)
with open(target, "r") as fh:
assert fh.read().rstrip() == CACHE[0]


# uploadfile {{{1
def test_uploadfile():
m = mock.MagicMock()
with cache_dir() as tmpdir:
tmpfile = os.path.join(tmpdir, "src")
sclient.uploadfile("baseurl", tmpfile, "format", "token", "nonce", "cert", method=m)
assert len(m.call_args_list) == 1
args, kwargs = m.call_args
assert args == ("baseurl/sign/format", )
assert kwargs['files']['filedata'].read() == b'cached\n'
assert list(kwargs['files'].keys()) == ['filedata', ]
del(kwargs['files'])
assert kwargs == {
'data': {
'sha1': CACHE[1],
'filename': "src",
'token': 'token',
'nonce': 'nonce',
},
'verify': 'cert',
}

0 comments on commit 053fa77

Please sign in to comment.