put bbase asset creation in a special file
This commit is contained in:
parent
34201b928d
commit
0dda3aceb8
45
tests/assets/filldb.py
Normal file
45
tests/assets/filldb.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
from ITPlanning import db
|
||||||
|
|
||||||
|
|
||||||
|
class filldatabase:
|
||||||
|
@staticmethod
|
||||||
|
def create_Customer():
|
||||||
|
return db.Customer(
|
||||||
|
first_name="john",
|
||||||
|
last_name="DOE",
|
||||||
|
email="john@doe.fr",
|
||||||
|
localisation="batiment 1",
|
||||||
|
mobile_number="0602020020",
|
||||||
|
phone_number="0321323432",
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_service_category():
|
||||||
|
return db.Service_category(
|
||||||
|
name="install",
|
||||||
|
duration=45,
|
||||||
|
free_order=False,
|
||||||
|
description="test Service_category",
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_service():
|
||||||
|
service_category = filldatabase.create_service_category()
|
||||||
|
return db.Service(
|
||||||
|
name="install", max_appointement=1, service_category=service_category
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_planning():
|
||||||
|
return db.Planning(
|
||||||
|
name="refresh1",
|
||||||
|
working_plan='{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:k20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]}',
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_ticket():
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_Planner():
|
||||||
|
pass
|
@ -4,6 +4,7 @@ from datetime import datetime
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from pony.orm import db_session
|
from pony.orm import db_session
|
||||||
from ITPlanning import db
|
from ITPlanning import db
|
||||||
|
from tests.assets.filldb import filldatabase
|
||||||
|
|
||||||
DATE_REGEX = r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$"
|
DATE_REGEX = r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$"
|
||||||
|
|
||||||
@ -15,49 +16,14 @@ class DbTestCase(unittest.TestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
db.release_database()
|
db.release_database()
|
||||||
|
|
||||||
def create_Customer(self):
|
|
||||||
return db.Customer(
|
|
||||||
first_name="john",
|
|
||||||
last_name="DOE",
|
|
||||||
email="john@doe.fr",
|
|
||||||
localisation="batiment 1",
|
|
||||||
mobile_number="0602020020",
|
|
||||||
phone_number="0321323432",
|
|
||||||
)
|
|
||||||
|
|
||||||
def create_service_category(self):
|
|
||||||
return db.Service_category(
|
|
||||||
name="install",
|
|
||||||
duration=45,
|
|
||||||
free_order=False,
|
|
||||||
description="test Service_category",
|
|
||||||
)
|
|
||||||
|
|
||||||
def create_service(self):
|
|
||||||
service_category = self.create_service_category()
|
|
||||||
return db.Service(
|
|
||||||
name="install", max_appointement=1, service_category=service_category
|
|
||||||
)
|
|
||||||
|
|
||||||
def create_planning(self):
|
|
||||||
return db.Planning(
|
|
||||||
name="refresh1",
|
|
||||||
working_plan='{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:k20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]}',
|
|
||||||
)
|
|
||||||
|
|
||||||
def create_ticket(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def create_Planner(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@db_session
|
@db_session
|
||||||
def test_appointement(self):
|
def test_appointement(self):
|
||||||
current_date = datetime.now()
|
current_date = datetime.now()
|
||||||
customer = self.create_Customer()
|
customer = filldatabase.create_Customer()
|
||||||
service = self.create_service()
|
service = filldatabase.create_service()
|
||||||
planning = self.create_planning()
|
planning = filldatabase.create_planning()
|
||||||
planning.services.add(service)
|
planning.services.add(service)
|
||||||
|
|
||||||
end_datetime = current_date + timedelta(
|
end_datetime = current_date + timedelta(
|
||||||
minutes=service.service_category.duration
|
minutes=service.service_category.duration
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user