def test_filename(self): variation = ImageVariation(color='blue', locale='en-us') variation.banner_id = 7 variation.image = Mock(width=250, height=140) variation.get_media_subdirectory = Mock(return_value='uploads/test') with patch('affiliates.banners.models.hashlib.sha1') as sha1: sha1.return_value.hexdigest.return_value = 'somehash' filename = variation._filename('test_file.png') # Filename should take the path from get_media_subdirectory and # the hash from sha1.hexdigest, which should've been given a # string with data unique to this variation. eq_(filename, 'uploads/test/somehash.png') sha1.assert_called_with('7_250_140_blue_en-us')
def test_size(self): variation = ImageVariation() variation.image = Mock(width=250, height=140) eq_(variation.size, '250 × 140')