Skip to content

Commit 972dff4

Browse files
author
Dhruva Shaw
committed
Some update [Majorly restructring]
1 parent 19cfb5b commit 972dff4

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

fluxpoint/paths/test.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from typing import Union, Dict
2+
import io
3+
4+
from enum import Enum
5+
from fluxpoint.vars import RequestTypes, TestImageType
6+
from fluxpoint.http import BaseHTTP
7+
8+
class Tests(BaseHTTP):
9+
"""Test endpoint documented in https://docs.fluxpoint.dev/api/endpoints/test"""
10+
11+
def __init__(self, *args, **kwargs) -> None:
12+
self.__baseurl = '/test'
13+
super().__init__(*args, **kwargs)
14+
15+
def __str__(self) -> str:
16+
return '<Tests>'
17+
18+
async def home(self) -> Enum:
19+
"""
20+
Tests if the api is working
21+
22+
:return: Tests Class
23+
:rtype: Enum
24+
"""
25+
return Enum('Color', (await self.request(RequestTypes.GET, '',)))
26+
27+
async def imagen(self, imgtype: TestImageType = TestImageType.jpeg) -> Union[Dict, io.IOBase]:
28+
"""Test the image generator
29+
30+
:returns: The response from the server
31+
:rtype: Union[Dict, io.IOBase]
32+
"""
33+
return await self.request(
34+
RequestTypes.GET,
35+
f'{self.__baseurl}/image' if imgtype is TestImageType.jpeg else f'{self.__baseurl}/image?type={imgtype.value}',
36+
return_bytes=True,
37+
return_json=False
38+
)
39+
40+
async def gallery(self) -> Dict:
41+
""" Test the gallery
42+
43+
:returns: The response from the server
44+
:rtype: Dict
45+
"""
46+
return await self.request(
47+
RequestTypes.GET,
48+
f'{self.__baseurl}/gallery',
49+
)
50+
51+
async def error(self) -> Dict:
52+
""" Test the error
53+
54+
:returns: The response from the server
55+
:rtype: Dict
56+
"""
57+
return await self.request(RequestTypes.GET, f'{self.__baseurl}/error')
58+
59+
async def json(self) -> Dict:
60+
"""Test the JSON response
61+
62+
:returns: The response from the server
63+
:rtype: Dict
64+
"""
65+
return await self.request(RequestTypes.GET, f'{self.__baseurl}/json')

0 commit comments

Comments
 (0)