refactoring tests to avoid mocking private method

This commit is contained in:
Victor Torres 2019-02-13 19:44:50 -02:00
parent b4d132b9f0
commit dc0b643832
1 changed files with 9 additions and 12 deletions

View File

@ -248,12 +248,9 @@ class S3FeedStorageTest(unittest.TestCase):
self.assertEqual(storage.secret_key, 'secret_key')
self.assertEqual(storage.acl, None)
with mock.patch('botocore.client.BaseClient._make_api_call') as m:
yield storage.store(BytesIO(b'test file'))
operation_name, api_params = m.call_args[0]
self.assertEqual(operation_name, 'PutObject')
self.assertNotIn('ACL', api_params)
storage.s3_client = mock.MagicMock()
yield storage.store(BytesIO(b'test file'))
self.assertNotIn('ACL', storage.s3_client.put_object.call_args[1])
@defer.inlineCallbacks
def test_store_botocore_with_acl(self):
@ -267,12 +264,12 @@ class S3FeedStorageTest(unittest.TestCase):
self.assertEqual(storage.secret_key, 'secret_key')
self.assertEqual(storage.acl, 'custom-acl')
with mock.patch('botocore.client.BaseClient._make_api_call') as m:
yield storage.store(BytesIO(b'test file'))
operation_name, api_params = m.call_args[0]
self.assertEqual(operation_name, 'PutObject')
self.assertEqual(api_params.get('ACL'), 'custom-acl')
storage.s3_client = mock.MagicMock()
yield storage.store(BytesIO(b'test file'))
self.assertEqual(
storage.s3_client.put_object.call_args[1].get('ACL'),
'custom-acl'
)
@defer.inlineCallbacks
def test_store_not_botocore_without_acl(self):