Esempio n. 1
0
    def test_cloud_connection_detail_another_error(self):
        httpretty.register_uri(httpretty.POST, "http://localhost/device/device1/request/firewall/acls/list?access_token=token", body=json.dumps(dict(err="error message")), status=201)

        cc = LinewizeApiClient("http://localhost", "key_id", "key_secret")
        sphirewall_client = cc.sphirewall("device1").firewall()

        self.assertRaises(TransportProviderException, sphirewall_client.acls)
Esempio n. 2
0
    def test_cloud_connection_detail(self):
        httpretty.register_uri(httpretty.POST, "http://localhost/device/device1/request/firewall/acls/list", body=json.dumps(dict(response=dict(normal="dude"), code=0)), status=200)

        cc = LinewizeApiClient("http://localhost", "key_id", "key_secret")
        assert cc.sphirewall("device1").firewall().acls() == "dude"
Esempio n. 3
0
    def test_invalid_permissions_error_throws_exception(self):
        httpretty.register_uri(httpretty.GET, "http://localhost/blah", body=json.dumps(dict(errcode=1)), status=403)

        service = LinewizeApiClient("http://localhost", None, None)
        self.assertRaises(DevicePermissionException, service.get_json, "/blah")
Esempio n. 4
0
    def test_valid_request_returns_dict_response(self):
        httpretty.register_uri(httpretty.GET, "http://localhost/blah", body=json.dumps(dict(result="cool, that worked")), status=200)

        service = LinewizeApiClient("http://localhost", None, None)
        assert service.get_json("/blah") == {"result": "cool, that worked"}
Esempio n. 5
0
    def test_general_error_throws_exception(self):
        httpretty.register_uri(httpretty.GET, "http://localhost/blah", body=json.dumps(dict(err="an error message")), status=500)

        service = LinewizeApiClient("http://localhost", None, None)
        self.assertRaises(InterApplicationException, service.get_json, "/blah")