create package and separate code
This commit is contained in:
parent
3c96defea3
commit
a17f09e04b
3
setup.py
Normal file
3
setup.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
setup(name='transcendence_api', version='1.0', packages=find_packages())
|
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
@ -1,7 +1,9 @@
|
|||||||
import urls
|
from src import urls
|
||||||
|
|
||||||
from requests import Response
|
from requests import Response
|
||||||
|
|
||||||
class Account:
|
|
||||||
|
class Accounts:
|
||||||
|
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
self._client = client
|
self._client = client
|
@ -1,18 +1,17 @@
|
|||||||
import requests
|
import requests
|
||||||
from requests import Response, Request, Session
|
from requests import Response, Request, Session
|
||||||
|
|
||||||
import Profiles
|
from src.profiles import Profiles
|
||||||
import Accounts
|
from src.accounts import Accounts
|
||||||
|
from src import urls
|
||||||
import urls
|
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
def __init__(self, url: str):
|
def __init__(self, url: str):
|
||||||
self.url: str = url
|
self.url: str = url
|
||||||
self.token: str = None
|
self.token: str = None
|
||||||
self.session: Session = Session()
|
self.session: Session = Session()
|
||||||
self.accounts: Account = Accounts.Account(self)
|
self.accounts: Accounts = Accounts(self)
|
||||||
self.profiles = Profiles.Profiles(self)
|
self.profiles: Profiles = Profiles(self)
|
||||||
|
|
||||||
def is_authentificate(self):
|
def is_authentificate(self):
|
||||||
return (not self.token is None)
|
return (not self.token is None)
|
@ -1,8 +1,9 @@
|
|||||||
import urls
|
from src import urls
|
||||||
import Client
|
|
||||||
|
from src.profile import Profile
|
||||||
|
|
||||||
|
|
||||||
from requests import Response
|
from requests import Response
|
||||||
import Profile
|
|
||||||
|
|
||||||
class Profiles:
|
class Profiles:
|
||||||
|
|
||||||
@ -14,4 +15,4 @@ class Profiles:
|
|||||||
if response.status_code == 404:
|
if response.status_code == 404:
|
||||||
return None
|
return None
|
||||||
content: dict = eval(response.content)
|
content: dict = eval(response.content)
|
||||||
return Profile.Profile(data = content)
|
return Profile(data = content)
|
@ -1,6 +1,11 @@
|
|||||||
import Client
|
import os
|
||||||
import Profile
|
import sys
|
||||||
from urls import *
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) # Add parent directory to system path
|
||||||
|
|
||||||
|
from src.client import Client
|
||||||
|
from src.profiles import Profiles
|
||||||
|
from src.profile import Profile
|
||||||
|
from src import urls
|
||||||
|
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
import os
|
import os
|
||||||
@ -42,7 +47,7 @@ def test_profile_get(client):
|
|||||||
|
|
||||||
print ("GET")
|
print ("GET")
|
||||||
|
|
||||||
test(client.profiles.get(1), Profile.Profile(username="997e13f5-474d-4fea-b55a-ad8a27b9534b", title=""), "normal")
|
test(client.profiles.get(1), Profile(username="997e13f5-474d-4fea-b55a-ad8a27b9534b", title=""), "normal")
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
@ -51,7 +56,7 @@ def tests():
|
|||||||
username = uuid4()
|
username = uuid4()
|
||||||
password = uuid4()
|
password = uuid4()
|
||||||
|
|
||||||
client = Client.Client("http://0.0.0.0:8000/")
|
client = Client("http://0.0.0.0:8000/")
|
||||||
|
|
||||||
print("ACCOUNTS".center(os.get_terminal_size()[0], '-'))
|
print("ACCOUNTS".center(os.get_terminal_size()[0], '-'))
|
||||||
test_accounts_register(client, username, password)
|
test_accounts_register(client, username, password)
|
Loading…
Reference in New Issue
Block a user