Skip to content

Commit 386ab1d

Browse files
committed
Rename transcode to convert
1 parent 7d596e1 commit 386ab1d

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

test/integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_should_preserve_metadata(self):
8686

8787
def test_should_transcode_image(self):
8888
with create_named_tmpfile() as tmp:
89-
a = self.optimized.transcode("image/webp").to_file(tmp)
89+
a = self.optimized.convert(type=["image/webp"]).to_file(tmp)
9090
with open(tmp, 'rb') as f:
9191
content = f.read()
9292

test/tinify_source_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def return_file(request, uri, headers):
5656
response = b'copyrighted file'
5757
elif 'resize' in data:
5858
response = b'small file'
59-
elif 'type' in data:
60-
response = b'transcoded file'
59+
elif 'convert' in data:
60+
response = b'converted file'
6161
elif 'transform' in data:
6262
response = b'transformed file'
6363
else:
@@ -137,13 +137,13 @@ def test_transform_should_return_source_with_data(self):
137137
self.assertEqual(b'transformed file', Source.from_buffer('png file').transform(background='black').to_buffer())
138138
self.assertJsonEqual('{"transform":{"background":"black"}}', httpretty.last_request().body.decode('utf-8'))
139139

140-
def test_transcode_should_return_source(self):
141-
self.assertIsInstance(Source.from_buffer('png file').resize(width=400).transcode(['image/webp']), Source)
140+
def test_convert_should_return_source(self):
141+
self.assertIsInstance(Source.from_buffer('png file').resize(width=400).convert(type=['image/webp']), Source)
142142
self.assertEqual(b'png file', httpretty.last_request().body)
143143

144-
def test_transcode_should_return_source_with_data(self):
145-
self.assertEqual(b'transcoded file', Source.from_buffer('png file').transcode('image/jpg').to_buffer())
146-
self.assertJsonEqual('{"type": "image/jpg"}', httpretty.last_request().body.decode('utf-8'))
144+
def test_convert_should_return_source_with_data(self):
145+
self.assertEqual(b'converted file', Source.from_buffer('png file').convert(type='image/jpg').to_buffer())
146+
self.assertJsonEqual('{"convert": {"type": "image/jpg"}}', httpretty.last_request().body.decode('utf-8'))
147147

148148
def test_store_should_return_result_meta(self):
149149
self.assertIsInstance(Source.from_buffer('png file').store(service='s3'), ResultMeta)
@@ -176,9 +176,9 @@ def test_to_file_with_file_object_should_store_image_data(self):
176176
def test_all_options_together(self):
177177
self.assertEqual('https://bucket.s3-region.amazonaws.com/some/location',
178178
Source.from_buffer('png file').resize(width=400)\
179-
.transcode(['image/webp', 'image/png'])\
179+
.convert(type=['image/webp', 'image/png'])\
180180
.transform(background="black")\
181181
.preserve("copyright", "location")\
182182
.store(service='s3').location)
183-
self.assertJsonEqual('{"store":{"service":"s3"},"resize":{"width":400},"preserve": ["copyright", "location"], "transform": {"background": "black"}, "type": ["image/webp", "image/png"]}', httpretty.last_request().body.decode('utf-8'))
183+
self.assertJsonEqual('{"store":{"service":"s3"},"resize":{"width":400},"preserve": ["copyright", "location"], "transform": {"background": "black"}, "convert": {"type": ["image/webp", "image/png"]}}', httpretty.last_request().body.decode('utf-8'))
184184

tinify/source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def preserve(self, *options):
3636
def resize(self, **options):
3737
return type(self)(self.url, **self._merge_commands(resize=options))
3838

39-
def transcode(self, types):
40-
return type(self)(self.url, **self._merge_commands(type=types))
39+
def convert(self, **options):
40+
return type(self)(self.url, **self._merge_commands(convert=options))
4141

4242
def transform(self, **options):
4343
return type(self)(self.url, **self._merge_commands(transform=options))

0 commit comments

Comments
 (0)