Пример #1
0
 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')
Пример #5
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())
Пример #6
0
 def test_from_url_should_return_source(self):
     self.assertIsInstance(Source.from_url('http://example.com/test.jpg'), Source)
Пример #7
0
 def test_from_url_should_raise_account_error(self):
     with self.assertRaises(AccountError):
         Source.from_url('http://example.com/test.jpg')