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
|
||||
|
||||
class Account:
|
||||
|
||||
class Accounts:
|
||||
|
||||
def __init__(self, client):
|
||||
self._client = client
|
@ -1,18 +1,17 @@
|
||||
import requests
|
||||
from requests import Response, Request, Session
|
||||
|
||||
import Profiles
|
||||
import Accounts
|
||||
|
||||
import urls
|
||||
from src.profiles import Profiles
|
||||
from src.accounts import Accounts
|
||||
from src import urls
|
||||
|
||||
class Client:
|
||||
def __init__(self, url: str):
|
||||
self.url: str = url
|
||||
self.token: str = None
|
||||
self.session: Session = Session()
|
||||
self.accounts: Account = Accounts.Account(self)
|
||||
self.profiles = Profiles.Profiles(self)
|
||||
self.accounts: Accounts = Accounts(self)
|
||||
self.profiles: Profiles = Profiles(self)
|
||||
|
||||
def is_authentificate(self):
|
||||
return (not self.token is None)
|
@ -1,8 +1,9 @@
|
||||
import urls
|
||||
import Client
|
||||
from src import urls
|
||||
|
||||
from src.profile import Profile
|
||||
|
||||
|
||||
from requests import Response
|
||||
import Profile
|
||||
|
||||
class Profiles:
|
||||
|
||||
@ -14,4 +15,4 @@ class Profiles:
|
||||
if response.status_code == 404:
|
||||
return None
|
||||
content: dict = eval(response.content)
|
||||
return Profile.Profile(data = content)
|
||||
return Profile(data = content)
|
@ -1,6 +1,11 @@
|
||||
import Client
|
||||
import Profile
|
||||
from urls import *
|
||||
import os
|
||||
import sys
|
||||
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
|
||||
import os
|
||||
@ -42,7 +47,7 @@ def test_profile_get(client):
|
||||
|
||||
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()
|
||||
|
||||
@ -51,7 +56,7 @@ def tests():
|
||||
username = 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], '-'))
|
||||
test_accounts_register(client, username, password)
|
Loading…
Reference in New Issue
Block a user