core_test.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import os
  2. from time import sleep
  3. os.chdir(os.path.dirname(__file__))
  4. import sys
  5. sys.path.append("..")
  6. sys.path.append("..\\Sources")
  7. from Sources.Modules.Inventory.inventory import * #altered
  8. import Sources.main as main_func
  9. import Sources.Model.model_manager as model_manager
  10. import requests
  11. from werkzeug.security import generate_password_hash
  12. import Sources.View.view_manager as view
  13. item_id_to_delete = 0
  14. import threading
  15. import pytest
  16. from pytest import Module, Session
  17. @pytest.fixture(autouse=True,scope='session')
  18. def fixture2():
  19. def run() :
  20. main_func.init()
  21. persistence.wipeout_database()
  22. persistence.init()
  23. model_manager.init()
  24. main_func.main()
  25. t1 = threading.Thread(target=run)
  26. t1.start()
  27. while(not main_func.isRunning()) :
  28. sleep(1)
  29. yield
  30. main_func.stop()
  31. t1.join()
  32. # Perform cleanup on the data when the test function exits
  33. def test_login() :
  34. r = requests.post("http://192.168.1.86:8000/api/login",json={'username' : 'admin','password': 'aseqzdwxc'})
  35. print(r.__dict__)
  36. assert r.status_code == 200