Fix pour les tests

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-09-01 15:56:48 +02:00
parent 38ac206c74
commit 1fc2beb609
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 11 additions and 11 deletions

View File

@ -26,12 +26,12 @@ class Result:
@dataclass @dataclass
class Vaccination(Result): class Vaccination(Result):
vaccine: str # vp
medical_product: str # mp
manufacturer: str # ma
dose_number: int # dn dose_number: int # dn
total_series_of_doses: int # sd total_series_of_doses: int # sd
date_of_vaccination: str # dt date_of_vaccination: str # dt
vaccine: Optional[str] = None # vp
medical_product: Optional[str] = None # mp
manufacturer: Optional[str] = None # ma
def check(self) -> bool: def check(self) -> bool:
# Toutes les doses ont bien été injectées # Toutes les doses ont bien été injectées
@ -68,13 +68,13 @@ class Test(Result):
POSITIVE = '260373001' POSITIVE = '260373001'
NEGATIVE = '260415000' NEGATIVE = '260415000'
type_of_test: str # tt
test_name: str # nm
manufacturer: str # ma
date: str # sc date: str # sc
result_date: str # dr
result: TestResult # tr result: TestResult # tr
center: str # tc type_of_test: Optional[str] = None # tt
test_name: Optional[str] = None # nm
manufacturer: Optional[str] = None # ma
result_date: Optional[str] = None # dr
center: Optional[str] = None # tc
@staticmethod @staticmethod
def deserialize(payload) -> "Test": def deserialize(payload) -> "Test":
@ -94,8 +94,8 @@ class Test(Result):
return Test(**{translation[k]: v for k, v in payload.items()}) return Test(**{translation[k]: v for k, v in payload.items()})
def check(self) -> bool: def check(self) -> bool:
valid = self.result == TestResult.NEGATIVE valid = self.result == Test.TestResult.NEGATIVE
test_date = datetime.datetime.fromisoformat(self.result_date) test_date = datetime.datetime.fromisoformat(self.date)
tzinfo = test_date.tzinfo tzinfo = test_date.tzinfo
delta = datetime.datetime.now(tzinfo) - test_date delta = datetime.datetime.now(tzinfo) - test_date
valid = valid and delta.days < 3 # 72h de validité valid = valid and delta.days < 3 # 72h de validité

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = pscheck name = pscheck
version = 1.1 version = 1.1.1
long_description = file: README.rst long_description = file: README.rst
long_description_content_type = text/markdown long_description_content_type = text/markdown
description = Vérificateur de pass sanitaire description = Vérificateur de pass sanitaire