123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import os
- from time import sleep
- os.chdir(os.path.dirname(__file__))
- import sys
- sys.path.append("..")
- sys.path.append("..\\Sources")
- from Sources.Modules.Inventory.inventory import * #altered
- import Sources.main as main_func
- import Sources.Model.model_manager as model_manager
- import requests
- from werkzeug.security import generate_password_hash
- import Sources.View.view_manager as view
- item_id_to_delete = 0
- import threading
- import pytest
- @pytest.fixture(autouse=True,scope='session')
- def fixture2():
- def run() :
- main_func.init()
- persistence.wipeout_database()
- persistence.init()
- model_manager.init()
- main_func.main()
- t1 = threading.Thread(target=run)
- t1.start()
- while(not main_func.isRunning()) :
- sleep(1)
- yield
- main_func.stop()
- t1.join()
- # Perform cleanup on the data when the test function exits
- def test_api() :
- sleep(2)
- s = requests.Session()
- print("CREATE")
- r = s.post("http://127.0.0.1:8000/api/login",json={'username' : 'admin','password': 'aseqzdwxc'})
- print(r.__dict__)
- assert r.status_code == 200
- print("CREATE")
- r = s.get("http://127.0.0.1:8000/tab")
- print(r.__dict__)
- assert r.status_code == 200
- print("CREATE")
- r = s.post("http://127.0.0.1:8000/api/inventory/item",json={"assign_date_epoch": 5000, "assigned": True, "brand": "Mikrotik", "name": "RB2011", "note": "saline 2 RT 2, chez ashvin", "owned": True, "serial_number": "12345678", "tags": "#router #mikrotik #saline", "type": "router", "wear_score": 100})
- print(r.__dict__)
- assert r.status_code == 200
- print("CREATE")
- r = s.post("http://127.0.0.1:8000/api/inventory/item",json={"assign_date_epoch": 10000, "assigned": True, "brand": "Mikrotik", "name": "HEX S 1", "note": "saline 2 RT 3, chez ashvin", "owned": True, "serial_number": "12345678", "tags": "#router #mikrotik #saline", "type": "router", "wear_score": 100})
- print(r.__dict__)
- assert r.status_code == 200
- print("CREATE")
- r = s.post("http://127.0.0.1:8000/api/inventory/item",json={"assign_date_epoch": 10000, "assigned": True, "brand": "Mikrotik", "name": "HEX S 1", "note": "saline 2 RT 3, chez ashvin", "owned": True, "serial_number": "12345678", "tags": "#router #mikrotik #saline", "type": "router", "wear_score": 100})
- print(r.__dict__)
- assert r.status_code == 200
- print("CREATE")
- r = s.post("http://127.0.0.1:8000/api/inventory/item",json={"assign_date_epoch": 10000, "assigned": True, "brand": "Mikrotik", "name": "HEX S 1", "note": "saline 2 RT 3, chez ashvin", "owned": True, "serial_number": "12345678", "tags": "#router #mikrotik #saline", "type": "router", "wear_score": 100})
- print(r.__dict__)
- assert r.status_code == 200
- print("GET")
- r = s.get("http://127.0.0.1:8000/api/inventory/items")
- print(r.__dict__)
- assert r.status_code == 200
- print("DELETE")
- r = s.delete("http://127.0.0.1:8000/api/inventory/item/2")
- print(r.__dict__)
- assert r.status_code == 200
- print("CREATE SITE")
- r = s.post("http://127.0.0.1:8000/api/inventory/site",json={"assign_date_epoch": 5000, "assigned": True, "brand": "Mikrotik", "name": "RB2011", "note": "saline 2 RT 2, chez ashvin", "owned": True, "serial_number": "12345678", "tags": "#router #mikrotik #saline", "type": "router", "wear_score": 100})
- print(r.__dict__)
- assert r.status_code == 200
|