From 13edc9a865cd203ddf28a3f782426a1b3b94f7a1 Mon Sep 17 00:00:00 2001 From: Sarafraj Singh Date: Fri, 5 Feb 2016 17:28:26 +0000 Subject: [PATCH] Improved test coverage of form_signature Added four new test cases to execute path of invalid arguments. This improved test coverage of file specified from 80% to 91%. Change-Id: I63c2e7bab3f01121301d78b687687208a58401c0 --- test/unit/cli/test_form_signature.py | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/unit/cli/test_form_signature.py b/test/unit/cli/test_form_signature.py index 55276bcbb2..bf2f8505a2 100644 --- a/test/unit/cli/test_form_signature.py +++ b/test/unit/cli/test_form_signature.py @@ -69,6 +69,42 @@ class TestFormSignature(unittest.TestCase): usage = 'Syntax: swift-form-signature ' self.assertTrue(usage in out.getvalue()) + def test_invalid_filesize_arg(self): + out = StringIO() + key = 'secret squirrel' + with mock.patch('sys.stdout', out): + exitcode = form_signature.main([ + '/path/to/swift-form-signature', + '/v1/a/c/o', '', '-1', '34', '3600', key]) + self.assertNotEqual(exitcode, 0) + + def test_invalid_filecount_arg(self): + out = StringIO() + key = 'secret squirrel' + with mock.patch('sys.stdout', out): + exitcode = form_signature.main([ + '/path/to/swift-form-signature', + '/v1/a/c/o', '', '12', '-34', '3600', key]) + self.assertNotEqual(exitcode, 0) + + def test_invalid_path_arg(self): + out = StringIO() + key = 'secret squirrel' + with mock.patch('sys.stdout', out): + exitcode = form_signature.main([ + '/path/to/swift-form-signature', + '/v1/a/', '', '12', '34', '3600', key]) + self.assertNotEqual(exitcode, 0) + + def test_invalid_seconds_arg(self): + out = StringIO() + key = 'secret squirrel' + with mock.patch('sys.stdout', out): + exitcode = form_signature.main([ + '/path/to/swift-form-signature', + '/v1/a/c/o', '', '12', '34', + '-922337203685477580799999999999999', key]) + self.assertNotEqual(exitcode, 0) if __name__ == '__main__': unittest.main()