Exemple #1
0
    def test_test_url_should_return_true_if_request_okay(self):
        transport = t.APITransport(Mock())
        transport._http = Mock()
        transport._http.head.return_value = Mock(
            status_code=requests.codes.not_found)

        self.assertFalse(transport.test_url("foo"))

        transport._http.head.return_value = Mock(status_code=requests.codes.OK)
        self.assertTrue(transport.test_url("foo"))
Exemple #2
0
    def test_complete_request(self):
        transport = t.APITransport(Mock())
        transport._http = Mock()

        http_result = Mock()
        http_result.content = b'{"stat":"ok","result":"bar"}'
        transport._http.post.return_value = http_result

        self.assertEqual("bar",
                         transport(t.APITransport.NO_ENCRYPT[0], foo="bar"))
Exemple #3
0
 def setUp(self):
     self.cryptor = Mock()
     self.transport = t.APITransport(self.cryptor)
Exemple #4
0
 def setUp(self):
     self.transport = t.APITransport(Mock())