Skip to content

Commit

Permalink
Merge pull request #103 from openimis/feature/hotfix-async
Browse files Browse the repository at this point in the history
Feature/OP-1920
  • Loading branch information
delcroip committed Apr 9, 2024
1 parent 248b41d commit 09317a1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
4 changes: 3 additions & 1 deletion policy/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def __init__(self, user):
self.user = user

@register_service_signal('policy_service.create_or_update')
def update_or_create(self, data, user):
def update_or_create(self, data, user):
if isinstance(data['enroll_date'], str):
data['enroll_date'] = py_date.strptime(data['enroll_date'], "%Y-%m-%d")
policy_uuid = data.get('uuid', None)
if 'enroll_date' in data and data['enroll_date'] > py_date.today():
raise ValidationError("policy.enroll_date_in_the_future")
Expand Down
33 changes: 31 additions & 2 deletions policy/tests_gql.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass
from core.utils import filter_validity
from core.models import User
from core.test_helpers import create_test_interactive_user
from core.test_helpers import create_test_interactive_user, AssertMutation
from django.conf import settings
from medical.models import Service
from graphene_django.utils.testing import GraphQLTestCase
Expand Down Expand Up @@ -38,7 +38,7 @@ class PolicyGraphQLTestCase(GraphQLTestCase):
# is shown as an error in the IDE, so leaving it as True.
GRAPHQL_SCHEMA = True
admin_user = None

@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -317,3 +317,32 @@ def test_insuree_policy_query(self):
# Add some more asserts if you like
...

def test_mutation_simple(self):
muuid = "203327cd-501e-41e1-a026-ed742e360081"
response = self.query(
f'''
mutation {{
createPolicy(
input: {{
clientMutationId: "{muuid}"
clientMutationLabel: "Création de la police ttttt eeeee (123123123) - 2024-06-01 : 2025-05-31"
enrollDate: "2024-04-07"
startDate: "2024-06-01"
expiryDate: "2025-05-31"
value: "10000.00"
productId: {self.product.id}
familyId: {self.insuree.family.id}
officerId: 1
}}
) {{
clientMutationId
internalId
}}
}}
''',
headers={"HTTP_AUTHORIZATION": f"Bearer {self.admin_token}"},
variables={'chfid': self.insuree.chf_id, 'activeOrLastExpiredOnly':True}
)
content = AssertMutation(self,muuid,self.admin_token)

0 comments on commit 09317a1

Please sign in to comment.