def test_from_url_should_raise_error_when_server_doesnt_return_a_success(self):
     httpretty.register_uri(httpretty.POST, 'https://api.tinify.com/shrink',
         body='{"error":"Source not found","message":"Cannot parse URL"}',
         status=400,
     )
     with self.assertRaises(ClientError):
         Source.from_url('file://wrong')
示例#2
0
 def test_from_url_should_return_source_with_data(self):
     self.assertEqual(
         b'compressed file',
         Source.from_url('http://example.com/test.jpg').to_buffer())
示例#3
0
 def test_from_url_should_return_source(self):
     self.assertIsInstance(Source.from_url('http://example.com/test.jpg'),
                           Source)
示例#4
0
 def test_from_url_should_raise_account_error(self):
     with self.assertRaises(AccountError):
         Source.from_url('http://example.com/test.jpg')
 def test_from_url_should_return_source_with_data(self):
     self.assertEqual(b'compressed file', Source.from_url('http://example.com/test.jpg').to_buffer())
 def test_from_url_should_return_source(self):
     self.assertIsInstance(Source.from_url('http://example.com/test.jpg'), Source)
 def test_from_url_should_raise_account_error(self):
     with self.assertRaises(AccountError):
         Source.from_url('http://example.com/test.jpg')