Exemplo n.º 1
0
    def test_call_api(self, mock_requests):
        mock_requests.return_value.status_code = 200
        mock_requests.return_value.json.return_value = data_mocks.accounts

        o_api = api.JsonRpcApi(url="http://syspass.org/api.php",
                               auth_token="syspass")
        data = o_api.call_api(method="method/action", params={})

        self.assertEqual(data, data_mocks.accounts)
Exemplo n.º 2
0
    def test_call_api_error_data(self, mock_requests):
        mock_requests.return_value.status_code = 200
        mock_requests.return_value.json.return_value = data_mocks.error_request

        o_api = api.JsonRpcApi(url="http://syspass.org/api.php",
                               auth_token="syspass")

        with self.assertRaises(api.ApiError):
            o_api.call_api(method="method/action", params={})
 def setUp(self) -> None:
     self.user_group = user_group.UserGroup(
         api.JsonRpcApi(url="http://syspass.org/api.php",
                        auth_token="syspass"))
Exemplo n.º 4
0
    def test_call_api_error_request(self):
        o_api = api.JsonRpcApi(url="http://example.com/api.php",
                               auth_token="syspass")

        with self.assertRaises(requests.exceptions.HTTPError):
            o_api.call_api(method="method/action", params={})
Exemplo n.º 5
0
 def test_call_api_no_url(self):
     with self.assertRaises(api.ApiError):
         api.JsonRpcApi() \
             .call_api(method="method/action", params={})
Exemplo n.º 6
0
 def test_call_api_no_token(self):
     with self.assertRaises(api.ApiError):
         api.JsonRpcApi(url="http://syspass.org/api.php") \
             .call_api(method="method/action", params={})
Exemplo n.º 7
0
 def setUp(self) -> None:
     self.client = client.Client(
         api.JsonRpcApi(url="http://syspass.org/api.php",
                        auth_token="syspass"))
Exemplo n.º 8
0
 def setUp(self) -> None:
     self.category = category.Category(api.JsonRpcApi(url="http://syspass.org/api.php", auth_token="syspass"))
Exemplo n.º 9
0
 def setUp(self) -> None:
     self.tag = tag.Tag(api.JsonRpcApi(url="http://syspass.org/api.php", auth_token="syspass"))
 def setUp(self) -> None:
     self.config = config.Config(
         api.JsonRpcApi(url="http://syspass.org/api.php",
                        auth_token="syspass"))
Exemplo n.º 11
0
 def setUp(self) -> None:
     self.account = account.Account(
         api.JsonRpcApi(url="http://syspass.org/api.php",
                        auth_token="syspass"))