def test_get_bucket_creates_bucket_connection(self, Config): config = Mock() Config.return_value = config mock_bucket = Mock() truck = ImageTruck(None, None, None) truck._stored_bucket = mock_bucket bucket = truck._bucket() eq_(bucket, mock_bucket) eq_(config.table.call_count, 0)
def test_save__uploads_image(self, calculate_filename): bucket = Mock() key = Mock() bucket.new_key.return_value = key calculate_filename.return_value = 'I am the keymaster' truck = ImageTruck('Are you the gatekeeper?', 'image/gif', None) truck._stored_bucket = bucket truck.upload() bucket.new_key.assert_called_with('I am the keymaster') key.set_contents_from_string.assert_called_with( 'Are you the gatekeeper?') key.set_metadata.assert_called_with('Content-Type', 'image/gif') key.make_public.assert_called_with()