Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test cases for asset bed #2532

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions care/facility/api/serializers/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.utils.timezone import now
from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from rest_framework.exceptions import PermissionDenied, ValidationError
from rest_framework.serializers import (
CharField,
JSONField,
Expand Down Expand Up @@ -174,11 +174,14 @@ def validate(self, attrs):

facilities = get_facility_queryset(user)
if not facilities.filter(id=location.facility.id).exists():
raise PermissionError
error_message = (
"You do not have permission to access this facility's asset."
)
raise PermissionDenied(error_message)
del attrs["location"]
attrs["current_location"] = location

# validate that warraty date is not in the past
# validate that warranty date is not in the past
if warranty_amc_end_of_validity := attrs.get("warranty_amc_end_of_validity"):
# pop out warranty date if it is not changed
if (
Expand Down
12 changes: 9 additions & 3 deletions care/facility/api/serializers/bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.db.models import Exists, OuterRef, Q
from django.shortcuts import get_object_or_404
from django.utils import timezone
from rest_framework.exceptions import ValidationError
from rest_framework.exceptions import PermissionDenied, ValidationError
from rest_framework.serializers import (
BooleanField,
CharField,
Expand Down Expand Up @@ -74,7 +74,10 @@ def validate(self, attrs):
if (not facilities.filter(id=location.facility.id).exists()) or (
not facilities.filter(id=facility.id).exists()
):
raise PermissionError
error_message = (
"You do not have permission to access this facility's bed."
)
raise PermissionDenied(error_message)
del attrs["location"]
attrs["location"] = location
attrs["facility"] = facility
Expand Down Expand Up @@ -110,7 +113,10 @@ def validate(self, attrs):
if (
not facilities.filter(id=asset.current_location.facility.id).exists()
) or (not facilities.filter(id=bed.facility.id).exists()):
raise PermissionError
error_message = (
"You do not have permission to access this facility's assetbed."
)
raise PermissionDenied(error_message)
if asset.asset_class not in [
AssetClasses.HL7MONITOR.name,
AssetClasses.ONVIF.name,
Expand Down
183 changes: 0 additions & 183 deletions care/facility/tests/test_asset_bed_api.py

This file was deleted.

Loading
Loading