qyrusai 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qyrusai-0.0.1/PKG-INFO +85 -0
- qyrusai-0.0.1/README.md +71 -0
- qyrusai-0.0.1/qyrusai/__init__.py +3 -0
- qyrusai-0.0.1/qyrusai/_clients.py +29 -0
- qyrusai-0.0.1/qyrusai/_exceptions.py +24 -0
- qyrusai-0.0.1/qyrusai/_rest.py +77 -0
- qyrusai-0.0.1/qyrusai/_types.py +48 -0
- qyrusai-0.0.1/qyrusai/api_assertions/__init__.py +22 -0
- qyrusai-0.0.1/qyrusai/api_assertions/all_assertions.py +99 -0
- qyrusai-0.0.1/qyrusai/api_assertions/headers.py +96 -0
- qyrusai-0.0.1/qyrusai/api_assertions/json_body.py +97 -0
- qyrusai-0.0.1/qyrusai/api_assertions/json_path.py +96 -0
- qyrusai-0.0.1/qyrusai/api_assertions/json_schema.py +97 -0
- qyrusai-0.0.1/qyrusai/api_builder/__init__.py +11 -0
- qyrusai-0.0.1/qyrusai/api_builder/api_builder.py +94 -0
- qyrusai-0.0.1/qyrusai/base/__init__.py +0 -0
- qyrusai-0.0.1/qyrusai/base/base.py +9 -0
- qyrusai-0.0.1/qyrusai/configs.py +48 -0
- qyrusai-0.0.1/qyrusai/data_amplifier/__init__.py +11 -0
- qyrusai-0.0.1/qyrusai/data_amplifier/data_amplifier.py +100 -0
- qyrusai-0.0.1/qyrusai/nova/__init__.py +17 -0
- qyrusai-0.0.1/qyrusai/nova/nova.py +202 -0
- qyrusai-0.0.1/qyrusai/vision_nova/__init__.py +13 -0
- qyrusai-0.0.1/qyrusai/vision_nova/vision_nova.py +181 -0
- qyrusai-0.0.1/qyrusai.egg-info/PKG-INFO +85 -0
- qyrusai-0.0.1/qyrusai.egg-info/SOURCES.txt +34 -0
- qyrusai-0.0.1/qyrusai.egg-info/dependency_links.txt +1 -0
- qyrusai-0.0.1/qyrusai.egg-info/requires.txt +2 -0
- qyrusai-0.0.1/qyrusai.egg-info/top_level.txt +2 -0
- qyrusai-0.0.1/setup.cfg +4 -0
- qyrusai-0.0.1/setup.py +13 -0
- qyrusai-0.0.1/tests/__init__.py +0 -0
- qyrusai-0.0.1/tests/test_all_services.py +557 -0
- qyrusai-0.0.1/tests/test_api_builder.py +164 -0
- qyrusai-0.0.1/tests/test_data_amplifier.py +99 -0
- qyrusai-0.0.1/tests/test_functions.py +46 -0
qyrusai-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: qyrusai
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Qyrus AI SDK
|
|
5
|
+
Home-page: UNKNOWN
|
|
6
|
+
Author: Qyrus Inc
|
|
7
|
+
Author-email: support@qyrus.com
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# QyrusAI Python SDK
|
|
14
|
+
|
|
15
|
+
The **QyrusAI Python SDK** provides a _Python client_ to access our **_SOTA Single Use testing Agents_** for _test case generation_, _test data generation_, _API test case generation_, and many more.
|
|
16
|
+
|
|
17
|
+
## Key Features
|
|
18
|
+
|
|
19
|
+
- **Nova:** Nova provides a quick and easy way to generate test scenarios and test cases using JIRA tickets and User story documents.
|
|
20
|
+
- **Nova API Assertions:** Nova API Assertions provide a quick way to create assertions to test API responses. These assertions include _header, schema, JSON Path, and JSON Body_ test cases.
|
|
21
|
+
- **API Builder**: API builder helps in visualizing virtualized APIs and provide a well planned Swagger documentation with APIs for the provided use case description.
|
|
22
|
+
- **Vision Nova**: Vision Nova helps in creating functional tests from Figma design frames.
|
|
23
|
+
- **Data Amplification**: Data Amplification helps create highly realistic context specific data for testing needs.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
You can install `qyrusai` from the source as of now.
|
|
28
|
+
|
|
29
|
+
### From Source
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
pip install git+https://github.com/QQyrus/qyrusai-sdk.git
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
The following is a basic example of how one can create test scenarios using **NOVA** using `qyrusai` SDK.
|
|
38
|
+
|
|
39
|
+
### Create Tests for JIRA Ticket
|
|
40
|
+
|
|
41
|
+
```py
|
|
42
|
+
from qyrusai import AsyncQyrusAI
|
|
43
|
+
|
|
44
|
+
async def jira():
|
|
45
|
+
at = "your_api_key"
|
|
46
|
+
client = AsyncQyrusAI(api_key=at)
|
|
47
|
+
jira_endpoint = "your jira endpoint"
|
|
48
|
+
jira_api_token = "your jira token"
|
|
49
|
+
jira_username = "your jira email"
|
|
50
|
+
jira_id = "your jira ticket id"
|
|
51
|
+
op = await client.nova.from_jira.create(
|
|
52
|
+
jira_api_token=jira_api_token,
|
|
53
|
+
jira_endpoint=jira_endpoint,
|
|
54
|
+
jira_username=jira_username,
|
|
55
|
+
jira_id=jira_id)
|
|
56
|
+
return op
|
|
57
|
+
|
|
58
|
+
if __name__ == "__main__":
|
|
59
|
+
import asyncio
|
|
60
|
+
print(asyncio.run(main_test()))
|
|
61
|
+
```
|
|
62
|
+
> Note : In the above example, `at` is supposed to store your secret key (api_key). In case you do not have it use the custom access token instead.
|
|
63
|
+
|
|
64
|
+
### Create Test via User Document
|
|
65
|
+
|
|
66
|
+
```py
|
|
67
|
+
from qyrusai import AsyncQyrusAI
|
|
68
|
+
|
|
69
|
+
async def main_test():
|
|
70
|
+
at = "your_api_key"
|
|
71
|
+
client = AsyncQyrusAI(api_key=at)
|
|
72
|
+
op = await client.nova.from_description.create(
|
|
73
|
+
"Create tests for login page")
|
|
74
|
+
return op
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
if __name__ == "__main__":
|
|
78
|
+
import asyncio
|
|
79
|
+
print(asyncio.run(main_test()))
|
|
80
|
+
```
|
|
81
|
+
> Note : In the above example, `at` is supposed to store your secret key (api_key). In case you do not have it use the custom access token instead.
|
|
82
|
+
|
|
83
|
+
> Note : Both Asynchronous and Synchronous interactions are available now.
|
|
84
|
+
|
|
85
|
+
|
qyrusai-0.0.1/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# QyrusAI Python SDK
|
|
2
|
+
|
|
3
|
+
The **QyrusAI Python SDK** provides a _Python client_ to access our **_SOTA Single Use testing Agents_** for _test case generation_, _test data generation_, _API test case generation_, and many more.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
- **Nova:** Nova provides a quick and easy way to generate test scenarios and test cases using JIRA tickets and User story documents.
|
|
8
|
+
- **Nova API Assertions:** Nova API Assertions provide a quick way to create assertions to test API responses. These assertions include _header, schema, JSON Path, and JSON Body_ test cases.
|
|
9
|
+
- **API Builder**: API builder helps in visualizing virtualized APIs and provide a well planned Swagger documentation with APIs for the provided use case description.
|
|
10
|
+
- **Vision Nova**: Vision Nova helps in creating functional tests from Figma design frames.
|
|
11
|
+
- **Data Amplification**: Data Amplification helps create highly realistic context specific data for testing needs.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
You can install `qyrusai` from the source as of now.
|
|
16
|
+
|
|
17
|
+
### From Source
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
pip install git+https://github.com/QQyrus/qyrusai-sdk.git
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
The following is a basic example of how one can create test scenarios using **NOVA** using `qyrusai` SDK.
|
|
26
|
+
|
|
27
|
+
### Create Tests for JIRA Ticket
|
|
28
|
+
|
|
29
|
+
```py
|
|
30
|
+
from qyrusai import AsyncQyrusAI
|
|
31
|
+
|
|
32
|
+
async def jira():
|
|
33
|
+
at = "your_api_key"
|
|
34
|
+
client = AsyncQyrusAI(api_key=at)
|
|
35
|
+
jira_endpoint = "your jira endpoint"
|
|
36
|
+
jira_api_token = "your jira token"
|
|
37
|
+
jira_username = "your jira email"
|
|
38
|
+
jira_id = "your jira ticket id"
|
|
39
|
+
op = await client.nova.from_jira.create(
|
|
40
|
+
jira_api_token=jira_api_token,
|
|
41
|
+
jira_endpoint=jira_endpoint,
|
|
42
|
+
jira_username=jira_username,
|
|
43
|
+
jira_id=jira_id)
|
|
44
|
+
return op
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
import asyncio
|
|
48
|
+
print(asyncio.run(main_test()))
|
|
49
|
+
```
|
|
50
|
+
> Note : In the above example, `at` is supposed to store your secret key (api_key). In case you do not have it use the custom access token instead.
|
|
51
|
+
|
|
52
|
+
### Create Test via User Document
|
|
53
|
+
|
|
54
|
+
```py
|
|
55
|
+
from qyrusai import AsyncQyrusAI
|
|
56
|
+
|
|
57
|
+
async def main_test():
|
|
58
|
+
at = "your_api_key"
|
|
59
|
+
client = AsyncQyrusAI(api_key=at)
|
|
60
|
+
op = await client.nova.from_description.create(
|
|
61
|
+
"Create tests for login page")
|
|
62
|
+
return op
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if __name__ == "__main__":
|
|
66
|
+
import asyncio
|
|
67
|
+
print(asyncio.run(main_test()))
|
|
68
|
+
```
|
|
69
|
+
> Note : In the above example, `at` is supposed to store your secret key (api_key). In case you do not have it use the custom access token instead.
|
|
70
|
+
|
|
71
|
+
> Note : Both Asynchronous and Synchronous interactions are available now.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# from nova import AsyncNova
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from .nova import AsyncNova, SyncNova
|
|
4
|
+
from .api_builder.api_builder import AsyncApiBuilder,SyncApiBuilder
|
|
5
|
+
from .data_amplifier.data_amplifier import AsyncDataAmplifier, SyncDataAmplifier
|
|
6
|
+
from .api_assertions import AsyncAssertions, SyncAssertions
|
|
7
|
+
from .vision_nova import Async_Vision_Nova, Sync_Vision_Nova
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AsyncQyrusAI:
|
|
11
|
+
|
|
12
|
+
# def __init__(self, api_key: str, base_url: Optional[str] = None) -> None:
|
|
13
|
+
def __init__(self, api_key: str) -> None:
|
|
14
|
+
self.nova = AsyncNova(api_key)
|
|
15
|
+
self.api_builder = AsyncApiBuilder(api_key)
|
|
16
|
+
self.data_amplifier = AsyncDataAmplifier(api_key)
|
|
17
|
+
self.api_assertions = AsyncAssertions(api_key)
|
|
18
|
+
self.vision_nova = Async_Vision_Nova(api_key)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class SyncQyrusAI:
|
|
22
|
+
|
|
23
|
+
# def __init__(self, api_key: str, base_url: Optional[str] = None) -> None:
|
|
24
|
+
def __init__(self, api_key: str) -> None:
|
|
25
|
+
self.nova = SyncNova(api_key)
|
|
26
|
+
self.api_builder = SyncApiBuilder(api_key)
|
|
27
|
+
self.data_amplifier = SyncDataAmplifier(api_key)
|
|
28
|
+
self.api_assertions = SyncAssertions(api_key)
|
|
29
|
+
self.vision_nova = Sync_Vision_Nova(api_key)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# exceptions.py
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CustomException(Exception):
|
|
5
|
+
|
|
6
|
+
def __init__(self, exce_msg):
|
|
7
|
+
super().__init__(exce_msg)
|
|
8
|
+
self.message = exce_msg
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AuthorizationException(CustomException):
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class RequestException(CustomException):
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ErrorException(CustomException):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class EntityException(CustomException):
|
|
24
|
+
pass
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import httpx
|
|
2
|
+
import asyncio
|
|
3
|
+
from ._exceptions import AuthorizationException, RequestException, ErrorException, EntityException
|
|
4
|
+
from fastapi.responses import JSONResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AsyncHTTPClient:
|
|
8
|
+
|
|
9
|
+
async def post(self, url, data, headers=None):
|
|
10
|
+
# print("\nURL (ASYNC) : ", url)
|
|
11
|
+
# print("\nDATA for Service Call (ASYNC) : ", data)
|
|
12
|
+
async with httpx.AsyncClient(timeout=600) as client:
|
|
13
|
+
try:
|
|
14
|
+
response = await client.post(url, json=data, headers=headers)
|
|
15
|
+
print(f"Response status code: {response.status_code}")
|
|
16
|
+
if response.status_code == 200:
|
|
17
|
+
return response.json()
|
|
18
|
+
elif response.status_code == 401:
|
|
19
|
+
raise AuthorizationException(
|
|
20
|
+
"Unauthorized: Access is denied due to invalid credentials. Please provide valid authentication details to access this resource."
|
|
21
|
+
)
|
|
22
|
+
elif response.status_code == 500:
|
|
23
|
+
raise RequestException(
|
|
24
|
+
"Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request."
|
|
25
|
+
)
|
|
26
|
+
elif response.status_code in [422, 400]:
|
|
27
|
+
raise EntityException(
|
|
28
|
+
"Bad Request: The server could not understand the request due to invalid syntax or incorrect input data."
|
|
29
|
+
)
|
|
30
|
+
else:
|
|
31
|
+
raise ErrorException("An unexpected error occurred")
|
|
32
|
+
# except httpx.HTTPStatusError as e:
|
|
33
|
+
# # print(f"HTTPStatusError: {e}")
|
|
34
|
+
except httpx.RequestError as e:
|
|
35
|
+
print(f"RequestError: {e}")
|
|
36
|
+
raise
|
|
37
|
+
except asyncio.TimeoutError:
|
|
38
|
+
print("Request timed out")
|
|
39
|
+
raise
|
|
40
|
+
except Exception as e:
|
|
41
|
+
print(f"An unexpected error occurred: {e}")
|
|
42
|
+
raise
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class SyncHTTPClient:
|
|
46
|
+
|
|
47
|
+
def post(self, url, data, headers=None):
|
|
48
|
+
# print("\nURL (SYNC) : ", url)
|
|
49
|
+
# print("\nDATA for Service Call (SYNC) : ", data)
|
|
50
|
+
with httpx.Client(timeout=600) as client:
|
|
51
|
+
try:
|
|
52
|
+
response = client.post(url, json=data, headers=headers)
|
|
53
|
+
if response.status_code == 200:
|
|
54
|
+
return response.json()
|
|
55
|
+
elif response.status_code == 401:
|
|
56
|
+
raise AuthorizationException(
|
|
57
|
+
"Unauthorized: Access is denied due to invalid credentials. Please provide valid authentication details to access this resource."
|
|
58
|
+
)
|
|
59
|
+
elif response.status_code == 500:
|
|
60
|
+
raise RequestException(
|
|
61
|
+
"Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request."
|
|
62
|
+
)
|
|
63
|
+
elif response.status_code in [422, 400]:
|
|
64
|
+
raise EntityException(
|
|
65
|
+
"Bad Request: The server could not understand the request due to invalid syntax or incorrect input data."
|
|
66
|
+
)
|
|
67
|
+
else:
|
|
68
|
+
raise ErrorException("An unexpected error occurred")
|
|
69
|
+
except httpx.RequestError as e:
|
|
70
|
+
print(f"RequestError: {e}")
|
|
71
|
+
raise
|
|
72
|
+
except asyncio.TimeoutError:
|
|
73
|
+
print("Request timed out")
|
|
74
|
+
raise
|
|
75
|
+
except Exception as e:
|
|
76
|
+
print(f"An unexpected error occurred: {e}")
|
|
77
|
+
raise
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List, Optional, Dict, Union
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# Pydantic for Input and Response
|
|
6
|
+
class Scenario(BaseModel):
|
|
7
|
+
test_script_name: str
|
|
8
|
+
test_script_objective: str
|
|
9
|
+
reason_to_test: str
|
|
10
|
+
criticality_description: str
|
|
11
|
+
criticality_score: int
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CreateScenariosResponse(BaseModel):
|
|
15
|
+
ok: bool
|
|
16
|
+
message: str
|
|
17
|
+
scenarios: Optional[List[Scenario]] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class JiraDetails(BaseModel):
|
|
21
|
+
jira_endpoint: str
|
|
22
|
+
jira_api_token: str
|
|
23
|
+
jira_username: str
|
|
24
|
+
jira_id: str
|
|
25
|
+
|
|
26
|
+
class UserDescription(BaseModel):
|
|
27
|
+
user_description: str
|
|
28
|
+
|
|
29
|
+
class ApiBuilderResponse(BaseModel):
|
|
30
|
+
swagger_dictionary: dict
|
|
31
|
+
|
|
32
|
+
class DataAmplifierResponse(BaseModel):
|
|
33
|
+
data: Optional[Dict] = None
|
|
34
|
+
status: bool
|
|
35
|
+
message: str
|
|
36
|
+
|
|
37
|
+
class AssertionHeaderRequest(BaseModel):
|
|
38
|
+
headers: Union[List, Dict, str]
|
|
39
|
+
|
|
40
|
+
# class AssertionHeaderResponse(BaseModel):
|
|
41
|
+
# assertions: Union[List, Dict, str]
|
|
42
|
+
class AssertionResponseRequest(BaseModel):
|
|
43
|
+
response: Union[List, Dict, str]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class AssertionAllRequest(BaseModel):
|
|
47
|
+
headers: Union[List, Dict, str]
|
|
48
|
+
response: Union[List, Dict, str]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from .headers import AsyncHeaderAssertions,SyncHeaderAssertions
|
|
3
|
+
from .json_body import AsyncJSONBodyAssertions,SyncJSONBodyAssertions
|
|
4
|
+
from .json_path import AsyncJSONPathAssertions,SyncJSONPathAssertions
|
|
5
|
+
from .json_schema import AsyncJSONSchemaAssertions,SyncJSONSchemaAssertions
|
|
6
|
+
from .all_assertions import AsyncAllAssertions,SyncAllAssertions
|
|
7
|
+
|
|
8
|
+
class AsyncAssertions:
|
|
9
|
+
def __init__(self, api_key: str) -> None:
|
|
10
|
+
self.headers = AsyncHeaderAssertions(api_key)
|
|
11
|
+
self.jsonbody = AsyncJSONBodyAssertions(api_key)
|
|
12
|
+
self.jsonpath = AsyncJSONPathAssertions(api_key)
|
|
13
|
+
self.jsonschema = AsyncJSONSchemaAssertions(api_key)
|
|
14
|
+
self.all_assertions = AsyncAllAssertions(api_key)
|
|
15
|
+
|
|
16
|
+
class SyncAssertions:
|
|
17
|
+
def __init__(self, api_key: str) -> None:
|
|
18
|
+
self.headers = SyncHeaderAssertions(api_key)
|
|
19
|
+
self.jsonbody = SyncJSONBodyAssertions(api_key)
|
|
20
|
+
self.jsonpath = SyncJSONPathAssertions(api_key)
|
|
21
|
+
self.jsonschema = SyncJSONSchemaAssertions(api_key)
|
|
22
|
+
self.all_assertions = SyncAllAssertions(api_key)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
|
|
2
|
+
from qyrusai.configs import Configurations
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from urllib.parse import urljoin
|
|
5
|
+
from qyrusai._rest import AsyncHTTPClient,SyncHTTPClient
|
|
6
|
+
from qyrusai._types import AssertionAllRequest
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsyncAllAssertions:
|
|
10
|
+
def __init__(self, api_key: str):
|
|
11
|
+
self.api_key = api_key
|
|
12
|
+
# token_valid = asyncio.run(Configurations.verifyToken(api_key)) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
13
|
+
token_valid = Configurations.verifyToken(api_key) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
14
|
+
if not token_valid:
|
|
15
|
+
raise Exception("401")
|
|
16
|
+
gatewayDetails = Configurations.getDefaultGateway(api_key)
|
|
17
|
+
# gatewayDetails = asyncio.run(Configurations.getDefaultGateway(api_key))
|
|
18
|
+
self.base_url = gatewayDetails.get("gatewayUrl")
|
|
19
|
+
self.gateway_token = gatewayDetails.get("gatewayToken")
|
|
20
|
+
|
|
21
|
+
async def create(self, headers:str, response:str):
|
|
22
|
+
"""Generate Header, JSON Assertions.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
response (AssertionResponseRequest): response
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
_type_: Returns the list of JSON key ,value and desriptions.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
url = urljoin(self.base_url,Configurations.getAPIAssertions("all"))
|
|
32
|
+
|
|
33
|
+
data = {
|
|
34
|
+
"headers": headers,
|
|
35
|
+
"response": response
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
headers = {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
'Authorization': "Bearer "+self.gateway_token,
|
|
41
|
+
'Custom': self.api_key
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async_client = AsyncHTTPClient()
|
|
45
|
+
response_data = await async_client.post(url, data, headers)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# print(f"response_data [ASYNC] (ALL Assertions) : {response_data}")
|
|
49
|
+
# print(
|
|
50
|
+
# f"response_data [ASYNC] (ALL Assertions) TYPE == >> : {type(response_data)}"
|
|
51
|
+
# )
|
|
52
|
+
|
|
53
|
+
return response_data
|
|
54
|
+
|
|
55
|
+
class SyncAllAssertions:
|
|
56
|
+
def __init__(self, api_key: str):
|
|
57
|
+
self.api_key = api_key
|
|
58
|
+
# token_valid = asyncio.run(Configurations.verifyToken(api_key)) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
59
|
+
token_valid = Configurations.verifyToken(api_key) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
60
|
+
if not token_valid:
|
|
61
|
+
raise Exception("401")
|
|
62
|
+
gatewayDetails = Configurations.getDefaultGateway(api_key)
|
|
63
|
+
# gatewayDetails = asyncio.run(Configurations.getDefaultGateway(api_key))
|
|
64
|
+
self.base_url = gatewayDetails.get("gatewayUrl")
|
|
65
|
+
self.gateway_token = gatewayDetails.get("gatewayToken")
|
|
66
|
+
|
|
67
|
+
def create(self, headers:str, response:str):
|
|
68
|
+
"""Generate Header, JSON Assertions.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
response (AssertionResponseRequest): response
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
_type_: Returns the list of header and JSON assertions
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
url = urljoin(self.base_url,Configurations.getAPIAssertions("all"))
|
|
78
|
+
|
|
79
|
+
data = {
|
|
80
|
+
"headers": headers,
|
|
81
|
+
"response": response
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
headers = {
|
|
85
|
+
'Content-Type': 'application/json',
|
|
86
|
+
'Authorization': "Bearer "+self.gateway_token,
|
|
87
|
+
'Custom': self.api_key
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
sync_client = SyncHTTPClient()
|
|
91
|
+
response_data = sync_client.post(url, data, headers)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# print(f"response_data [SYNC] (ALL Assertions) : {response_data}")
|
|
95
|
+
# print(
|
|
96
|
+
# f"response_data [SYNC] (ALL Assertions) TYPE == >> : {type(response_data)}"
|
|
97
|
+
# )
|
|
98
|
+
|
|
99
|
+
return response_data
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from qyrusai.configs import Configurations
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from urllib.parse import urljoin
|
|
4
|
+
from qyrusai._rest import AsyncHTTPClient,SyncHTTPClient
|
|
5
|
+
from qyrusai._types import AssertionHeaderRequest
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AsyncHeaderAssertions:
|
|
9
|
+
def __init__(self, api_key: str):
|
|
10
|
+
self.api_key = api_key
|
|
11
|
+
# token_valid = asyncio.run(Configurations.verifyToken(api_key)) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
12
|
+
token_valid = Configurations.verifyToken(api_key) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
13
|
+
if not token_valid:
|
|
14
|
+
raise Exception("401")
|
|
15
|
+
gatewayDetails = Configurations.getDefaultGateway(api_key)
|
|
16
|
+
# gatewayDetails = asyncio.run(Configurations.getDefaultGateway(api_key))
|
|
17
|
+
self.base_url = gatewayDetails.get("gatewayUrl")
|
|
18
|
+
self.gateway_token = gatewayDetails.get("gatewayToken")
|
|
19
|
+
|
|
20
|
+
async def create(self, headers: AssertionHeaderRequest):
|
|
21
|
+
"""Generate Header Assertions.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
headers (AssertionHeaderRequest): headers
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
_type_: Returns the list of header's key ,value and desriptions.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
url = urljoin(self.base_url,Configurations.getAPIAssertions("headers"))
|
|
31
|
+
|
|
32
|
+
data = {
|
|
33
|
+
"headers": headers
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
headers = {
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
'Authorization': "Bearer "+self.gateway_token,
|
|
39
|
+
'Custom': self.api_key
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async_client = AsyncHTTPClient()
|
|
43
|
+
response_data = await async_client.post(url, data, headers)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# print(f"response_data [ASYNC] (Header Assertions) : {response_data}")
|
|
47
|
+
# print(
|
|
48
|
+
# f"response_data [ASYNC] (Header Assertions) TYPE == >> : {type(response_data)}"
|
|
49
|
+
# )
|
|
50
|
+
|
|
51
|
+
return response_data
|
|
52
|
+
|
|
53
|
+
class SyncHeaderAssertions:
|
|
54
|
+
def __init__(self, api_key: str):
|
|
55
|
+
self.api_key = api_key
|
|
56
|
+
# token_valid = asyncio.run(Configurations.verifyToken(api_key)) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
57
|
+
token_valid = Configurations.verifyToken(api_key) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
58
|
+
if not token_valid:
|
|
59
|
+
raise Exception("401")
|
|
60
|
+
gatewayDetails = Configurations.getDefaultGateway(api_key)
|
|
61
|
+
# gatewayDetails = asyncio.run(Configurations.getDefaultGateway(api_key))
|
|
62
|
+
self.base_url = gatewayDetails.get("gatewayUrl")
|
|
63
|
+
self.gateway_token = gatewayDetails.get("gatewayToken")
|
|
64
|
+
|
|
65
|
+
def create(self, headers: AssertionHeaderRequest):
|
|
66
|
+
"""Generate Header Assertions.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
headers (AssertionHeaderRequest): headers
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
_type_: Returns the list of header's key ,value and desriptions.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
url = urljoin(self.base_url,Configurations.getAPIAssertions("headers"))
|
|
76
|
+
|
|
77
|
+
data = {
|
|
78
|
+
"headers": headers
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
headers = {
|
|
82
|
+
'Content-Type': 'application/json',
|
|
83
|
+
'Authorization': "Bearer "+self.gateway_token,
|
|
84
|
+
'Custom': self.api_key
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
sync_client = SyncHTTPClient()
|
|
88
|
+
response_data = sync_client.post(url, data, headers)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# print(f"response_data [SYNC] (Header Assertions) : {response_data}")
|
|
92
|
+
# print(
|
|
93
|
+
# f"response_data [SYNC] (Header Assertions) TYPE == >> : {type(response_data)}"
|
|
94
|
+
# )
|
|
95
|
+
|
|
96
|
+
return response_data
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
from qyrusai.configs import Configurations
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from urllib.parse import urljoin
|
|
5
|
+
from qyrusai._rest import AsyncHTTPClient,SyncHTTPClient
|
|
6
|
+
from qyrusai._types import AssertionResponseRequest
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsyncJSONBodyAssertions:
|
|
10
|
+
def __init__(self, api_key: str):
|
|
11
|
+
self.api_key = api_key
|
|
12
|
+
# token_valid = asyncio.run(Configurations.verifyToken(api_key)) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
13
|
+
token_valid = Configurations.verifyToken(api_key) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
14
|
+
if not token_valid:
|
|
15
|
+
raise Exception("401")
|
|
16
|
+
gatewayDetails = Configurations.getDefaultGateway(api_key)
|
|
17
|
+
# gatewayDetails = asyncio.run(Configurations.getDefaultGateway(api_key))
|
|
18
|
+
self.base_url = gatewayDetails.get("gatewayUrl")
|
|
19
|
+
self.gateway_token = gatewayDetails.get("gatewayToken")
|
|
20
|
+
|
|
21
|
+
async def create(self, response: AssertionResponseRequest):
|
|
22
|
+
"""Generate JSONBODY Assertions.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
response (AssertionResponseRequest): response
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
_type_: Returns the list of header's key ,value and desriptions.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
url = urljoin(self.base_url,Configurations.getAPIAssertions("jsonbody"))
|
|
32
|
+
|
|
33
|
+
data = {
|
|
34
|
+
"response": response
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
headers = {
|
|
38
|
+
'Content-Type': 'application/json',
|
|
39
|
+
'Authorization': "Bearer "+self.gateway_token,
|
|
40
|
+
'Custom': self.api_key
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async_client = AsyncHTTPClient()
|
|
44
|
+
response_data = await async_client.post(url, data, headers)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# print(f"response_data [ASYNC] (JSON Body Assertions) : {response_data}")
|
|
48
|
+
# print(
|
|
49
|
+
# f"response_data [ASYNC] (JSON Body Assertions) TYPE == >> : {type(response_data)}"
|
|
50
|
+
# )
|
|
51
|
+
|
|
52
|
+
return response_data
|
|
53
|
+
|
|
54
|
+
class SyncJSONBodyAssertions:
|
|
55
|
+
def __init__(self, api_key: str):
|
|
56
|
+
self.api_key = api_key
|
|
57
|
+
# token_valid = asyncio.run(Configurations.verifyToken(api_key)) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
58
|
+
token_valid = Configurations.verifyToken(api_key) # If True is stored, well and good otherwise an Exception will have been raised already if something goes wrong.
|
|
59
|
+
if not token_valid:
|
|
60
|
+
raise Exception("401")
|
|
61
|
+
gatewayDetails = Configurations.getDefaultGateway(api_key)
|
|
62
|
+
# gatewayDetails = asyncio.run(Configurations.getDefaultGateway(api_key))
|
|
63
|
+
self.base_url = gatewayDetails.get("gatewayUrl")
|
|
64
|
+
self.gateway_token = gatewayDetails.get("gatewayToken")
|
|
65
|
+
|
|
66
|
+
def create(self, response: AssertionResponseRequest):
|
|
67
|
+
"""Generate JSONBODY Assertions.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
response (AssertionResponseRequest): response
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
_type_: Returns the list of header's key ,value and desriptions.
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
url = urljoin(self.base_url,Configurations.getAPIAssertions("jsonbody"))
|
|
77
|
+
|
|
78
|
+
data = {
|
|
79
|
+
"response": response
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
headers = {
|
|
83
|
+
'Content-Type': 'application/json',
|
|
84
|
+
'Authorization': "Bearer "+self.gateway_token,
|
|
85
|
+
'Custom': self.api_key
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
sync_client = SyncHTTPClient()
|
|
89
|
+
response_data = sync_client.post(url, data, headers)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# print(f"response_data [SYNC] (JSON Body Assertions) : {response_data}")
|
|
93
|
+
# print(
|
|
94
|
+
# f"response_data [SYNC] (JSON Body Assertions) TYPE == >> : {type(response_data)}"
|
|
95
|
+
# )
|
|
96
|
+
|
|
97
|
+
return response_data
|