Exemplo n.º 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')
Exemplo n.º 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())
Exemplo n.º 3
0
 def test_from_url_should_return_source(self):
     self.assertIsInstance(Source.from_url('http://example.com/test.jpg'),
                           Source)
Exemplo n.º 4
0
 def test_from_url_should_raise_account_error(self):
     with self.assertRaises(AccountError):
         Source.from_url('http://example.com/test.jpg')
Exemplo n.º 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())
Exemplo n.º 6
0
 def test_from_url_should_return_source(self):
     self.assertIsInstance(Source.from_url('http://example.com/test.jpg'), Source)
Exemplo n.º 7
0
 def test_from_url_should_raise_account_error(self):
     with self.assertRaises(AccountError):
         Source.from_url('http://example.com/test.jpg')