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

Merge Develop To Staging v24.48.0 #2606

Merged
merged 7 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 27 additions & 0 deletions .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches: # Specify your branches here
- develop

jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2024.2
with:
pr-mode: false
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_1210838162 }}
QODANA_ENDPOINT: 'https://qodana.cloud'
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 @@ -46,13 +46,13 @@
id = UUIDField(source="external_id", read_only=True)
location_type = ChoiceField(choices=AssetLocation.RoomTypeChoices)

def validate_middleware_address(self, value):

Check notice on line 49 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `validate_middleware_address` may be 'static'

Check notice on line 49 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `validate_middleware_address` may be 'static'
value = (value or "").strip()
if not value:
return value

# Check if the address is valid
MiddlewareDomainAddressValidator()(value)

Check warning on line 55 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Attempt to call a non-callable object

'MiddlewareDomainAddressValidator' object is not callable

Check warning on line 55 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Attempt to call a non-callable object

'MiddlewareDomainAddressValidator' object is not callable
return value

def validate(self, data):
Expand Down Expand Up @@ -174,11 +174,14 @@

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 Expand Up @@ -391,10 +394,10 @@
model = AvailabilityRecord
fields = ("status", "timestamp", "linked_id", "linked_model")

def get_linked_id(self, obj):

Check notice on line 397 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `get_linked_id` may be 'static'

Check notice on line 397 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `get_linked_id` may be 'static'
return obj.object_external_id

def get_linked_model(self, obj):

Check notice on line 400 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `get_linked_model` may be 'static'

Check notice on line 400 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `get_linked_model` may be 'static'
return obj.content_type.model


Expand All @@ -407,7 +410,7 @@


class AssetActionSerializer(Serializer):
def action_choices():

Check notice on line 413 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `action_choices` may be 'static'

Check failure on line 413 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Improper first parameter

Method must have a first parameter, usually called 'self'

Check notice on line 413 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `action_choices` may be 'static'

Check failure on line 413 in care/facility/api/serializers/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Improper first parameter

Method must have a first parameter, usually called 'self'
actions = [
OnvifAsset.OnvifActions,
HL7MonitorAsset.HL7MonitorActions,
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 @@ -46,10 +46,10 @@

number_of_beds = IntegerField(required=False, default=1, write_only=True)

def validate_name(self, value):

Check notice on line 49 in care/facility/api/serializers/bed.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `validate_name` may be 'static'

Check notice on line 49 in care/facility/api/serializers/bed.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `validate_name` may be 'static'
return value.strip() if value else value

def validate_number_of_beds(self, value):

Check notice on line 52 in care/facility/api/serializers/bed.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `validate_number_of_beds` may be 'static'

Check notice on line 52 in care/facility/api/serializers/bed.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `validate_number_of_beds` may be 'static'
max_beds = 100
if value > max_beds:
msg = f"Cannot create more than {max_beds} beds at once."
Expand All @@ -74,7 +74,10 @@
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 @@
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 AssetBed.objects.filter(asset=asset, bed=bed).exists():
raise ValidationError(
{"non_field_errors": "Asset is already linked to bed"}
Expand Down Expand Up @@ -149,7 +155,7 @@
bed = BedSerializer(read_only=True)
patient = SerializerMethodField()

def get_patient(self, obj):

Check notice on line 158 in care/facility/api/serializers/bed.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `get_patient` may be 'static'

Check notice on line 158 in care/facility/api/serializers/bed.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `get_patient` may be 'static'
from care.facility.api.serializers.patient import PatientListSerializer

patient = PatientRegistration.objects.filter(
Expand Down
4 changes: 2 additions & 2 deletions care/facility/api/viewsets/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from care.facility.models.bed import AssetBed, ConsultationBed
from care.users.models import User
from care.utils.assetintegration.asset_classes import AssetClasses
from care.utils.assetintegration.base import BaseAssetIntegration
from care.utils.cache.cache_allowed_facilities import get_accessible_facilities
from care.utils.filters.choicefilter import CareChoiceFilter, inverse_choices
from care.utils.queryset.asset_bed import get_asset_queryset
Expand Down Expand Up @@ -88,7 +89,7 @@
class AssetLocationFilter(filters.FilterSet):
bed_is_occupied = filters.BooleanFilter(method="filter_bed_is_occupied")

def filter_bed_is_occupied(self, queryset, name, value):

Check notice on line 92 in care/facility/api/viewsets/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_bed_is_occupied` may be 'static'

Check notice on line 92 in care/facility/api/viewsets/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_bed_is_occupied` may be 'static'
asset_locations = (
AssetBed.objects.select_related("asset", "bed")
.filter(asset__asset_class=AssetClasses.HL7MONITOR.name)
Expand Down Expand Up @@ -134,7 +135,7 @@
return context

def get_queryset(self):
user = self.request.user

Check notice on line 138 in care/facility/api/viewsets/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code

Check notice on line 138 in care/facility/api/viewsets/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code
queryset = self.queryset
if user.is_superuser:
pass
Expand Down Expand Up @@ -185,7 +186,7 @@
is_permanent = filters.BooleanFilter(method="filter_is_permanent")
warranty_amc_end_of_validity = filters.DateFromToRangeFilter()

def filter_in_use_by_consultation(self, queryset, _, value):

Check notice on line 189 in care/facility/api/viewsets/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_in_use_by_consultation` may be 'static'

Check notice on line 189 in care/facility/api/viewsets/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_in_use_by_consultation` may be 'static'
if value not in EMPTY_VALUES:
queryset = queryset.annotate(
is_in_use=Exists(
Expand All @@ -199,7 +200,7 @@
queryset = queryset.filter(is_in_use=value)
return queryset.distinct()

def filter_is_permanent(self, queryset, _, value):

Check notice on line 203 in care/facility/api/viewsets/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_is_permanent` may be 'static'

Check notice on line 203 in care/facility/api/viewsets/asset.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_is_permanent` may be 'static'
if value not in EMPTY_VALUES:
if value:
queryset = queryset.filter(
Expand Down Expand Up @@ -389,7 +390,6 @@
This API is used to operate assets. API accepts the asset_id and action as parameters.
"""
try:
action = request.data["action"]
asset: Asset = self.get_object()
middleware_hostname = (
asset.meta.get(
Expand All @@ -405,7 +405,7 @@
"middleware_hostname": middleware_hostname,
}
)
result = asset_class.handle_action(action)
result = asset_class.handle_action(**request.data["action"])
return Response({"result": result}, status=status.HTTP_200_OK)

except ValidationError as e:
Expand Down
2 changes: 1 addition & 1 deletion care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
)
ration_card_category = filters.ChoiceFilter(choices=RationCardCategory.choices)

def filter_by_category(self, queryset, name, value):

Check notice on line 129 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_by_category` may be 'static'

Check notice on line 129 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_by_category` may be 'static'
if value:
queryset = queryset.filter(
(
Expand Down Expand Up @@ -234,13 +234,13 @@
# Other Filters
has_bed = filters.BooleanFilter(field_name="has_bed", method="filter_bed_not_null")

def filter_bed_not_null(self, queryset, name, value):

Check notice on line 237 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_bed_not_null` may be 'static'

Check notice on line 237 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_bed_not_null` may be 'static'
return queryset.filter(
last_consultation__bed_number__isnull=value,
last_consultation__discharge_date__isnull=True,
)

def filter_by_review_missed(self, queryset, name, value):

Check notice on line 243 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_by_review_missed` may be 'static'

Check notice on line 243 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_by_review_missed` may be 'static'
if isinstance(value, bool):
if value:
queryset = queryset.filter(
Expand All @@ -261,7 +261,7 @@
diagnoses_differential = MultiSelectFilter(method="filter_by_diagnoses")
diagnoses_confirmed = MultiSelectFilter(method="filter_by_diagnoses")

def filter_by_diagnoses(self, queryset, name, value):

Check notice on line 264 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_by_diagnoses` may be 'static'

Check notice on line 264 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_by_diagnoses` may be 'static'
if not value:
return queryset
filter_q = Q(last_consultation__diagnoses__diagnosis_id__in=value.split(","))
Expand All @@ -285,7 +285,7 @@
method="filter_by_has_consents"
)

def filter_by_has_consents(self, queryset, name, value: str):

Check notice on line 288 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_by_has_consents` may be 'static'

Check notice on line 288 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_by_has_consents` may be 'static'
if not value:
return queryset

Expand Down Expand Up @@ -337,7 +337,7 @@
queryset = queryset.filter(q_filters)
return queryset

def filter_list_queryset(self, request, queryset, view):

Check notice on line 340 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_list_queryset` may be 'static'

Check notice on line 340 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_list_queryset` may be 'static'
try:
show_without_facility = json.loads(
request.query_params.get("without_facility")
Expand All @@ -351,7 +351,7 @@


class PatientCustomOrderingFilter(BaseFilterBackend):
def filter_queryset(self, request, queryset, view):

Check notice on line 354 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_queryset` may be 'static'

Check notice on line 354 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Method is not declared static

Method `filter_queryset` may be 'static'
ordering = request.query_params.get("ordering", "")

if ordering in ("category_severity", "-category_severity"):
Expand Down Expand Up @@ -589,7 +589,7 @@
@action(detail=True, methods=["POST"])
def transfer(self, request, *args, **kwargs):
patient = PatientRegistration.objects.get(external_id=kwargs["external_id"])
facility = Facility.objects.get(external_id=request.data["facility"])
facility = get_object_or_404(Facility, external_id=request.data["facility"])

if patient.is_expired:
return Response(
Expand Down Expand Up @@ -954,7 +954,7 @@
patient_note__external_id=self.kwargs.get("notes_external_id")
)

if user.is_superuser:

Check notice on line 957 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code

Check notice on line 957 in care/facility/api/viewsets/patient.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code
return queryset
if user.user_type >= User.TYPE_VALUE_MAP["StateLabAdmin"]:
queryset = queryset.filter(
Expand Down
141 changes: 141 additions & 0 deletions care/facility/tests/test_asset_api.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
from django.utils.timezone import now, timedelta
from rest_framework import status
from rest_framework.exceptions import ValidationError
from rest_framework.test import APITestCase

from care.facility.models import Asset, Bed
from care.users.models import User
from care.utils.assetintegration.asset_classes import AssetClasses
from care.utils.assetintegration.hl7monitor import HL7MonitorAsset
from care.utils.assetintegration.onvif import OnvifAsset
from care.utils.assetintegration.ventilator import VentilatorAsset
from care.utils.tests.test_utils import TestUtils


class AssetViewSetTestCase(TestUtils, APITestCase):
@classmethod
def setUpTestData(cls) -> None:

Check notice on line 17 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 naming convention violation

Function name should be lowercase
cls.state = cls.create_state()

Check notice on line 18 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code

Check notice on line 18 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code
cls.district = cls.create_district(cls.state)
cls.local_body = cls.create_local_body(cls.district)
cls.super_user = cls.create_super_user("su", cls.district)
Expand All @@ -29,8 +33,145 @@

def setUp(self) -> None:
super().setUp()
self.asset = self.create_asset(self.asset_location)

Check notice on line 36 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute asset defined outside __init__

Check notice on line 36 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

An instance attribute is defined outside `__init__`

Instance attribute asset defined outside __init__

def validate_invalid_meta(self, asset_class, meta):
with self.assertRaises(ValidationError):
asset_class(meta)

def test_meta_validations_for_onvif_asset(self):
valid_meta = {
"local_ip_address": "192.168.0.1",
"camera_access_key": "username:password:access_key",
"middleware_hostname": "middleware.local",
"insecure_connection": True,
}
onvif_asset = OnvifAsset(valid_meta)
self.assertEqual(onvif_asset.middleware_hostname, "middleware.local")
self.assertEqual(onvif_asset.host, "192.168.0.1")
self.assertEqual(onvif_asset.username, "username")
self.assertEqual(onvif_asset.password, "password")
self.assertEqual(onvif_asset.access_key, "access_key")
self.assertTrue(onvif_asset.insecure_connection)

invalid_meta_cases = [
# Invalid format for camera_access_key
{
"id": "123",
"local_ip_address": "192.168.0.1",
"middleware_hostname": "middleware.local",
"camera_access_key": "invalid_format",
},
# Missing username/password in camera_access_key
{
"local_ip_address": "192.168.0.1",
"middleware_hostname": "middleware.local",
"camera_access_key": "invalid_format",
},
# Missing middleware_hostname
{
"local_ip_address": "192.168.0.1",
"camera_access_key": "username:password:access_key",
},
# Missing local_ip_address
{
"middleware_hostname": "middleware.local",
"camera_access_key": "username:password:access_key",
},
# Invalid value for insecure_connection
{
"local_ip_address": "192.168.0.1",
"camera_access_key": "username:password:access_key",
"middleware_hostname": "middleware.local",
"insecure_connection": "invalid_value",
},
]
for meta in invalid_meta_cases:
self.validate_invalid_meta(OnvifAsset, meta)

def test_meta_validations_for_ventilator_asset(self):
valid_meta = {
"id": "123",
"local_ip_address": "192.168.0.1",
"middleware_hostname": "middleware.local",
"insecure_connection": True,
}
ventilator_asset = VentilatorAsset(valid_meta)
self.assertEqual(ventilator_asset.middleware_hostname, "middleware.local")
self.assertEqual(ventilator_asset.host, "192.168.0.1")
self.assertTrue(ventilator_asset.insecure_connection)

invalid_meta_cases = [
# Missing id
{
"local_ip_address": "192.168.0.1",
"middleware_hostname": "middleware.local",
},
# Missing middleware_hostname
{"id": "123", "local_ip_address": "192.168.0.1"},
# Missing local_ip_address
{"id": "123", "middleware_hostname": "middleware.local"},
# Invalid insecure_connection
{
"id": "123",
"local_ip_address": "192.168.0.1",
"middleware_hostname": "middleware.local",
"insecure_connection": "invalid_value",
},
# Camera access key not required for ventilator, invalid meta
{
"id": "21",
"local_ip_address": "192.168.0.1",
"camera_access_key": "username:password:access_key",
"middleware_hostname": "middleware.local",
"insecure_connection": True,
},
]
for meta in invalid_meta_cases:
self.validate_invalid_meta(VentilatorAsset, meta)

def test_meta_validations_for_hl7monitor_asset(self):
valid_meta = {
"id": "123",
"local_ip_address": "192.168.0.1",
"middleware_hostname": "middleware.local",
"insecure_connection": True,
}
hl7monitor_asset = HL7MonitorAsset(valid_meta)
self.assertEqual(hl7monitor_asset.middleware_hostname, "middleware.local")
self.assertEqual(hl7monitor_asset.host, "192.168.0.1")
self.assertEqual(hl7monitor_asset.id, "123")
self.assertTrue(hl7monitor_asset.insecure_connection)

invalid_meta_cases = [
# Missing id
{
"local_ip_address": "192.168.0.1",
"middleware_hostname": "middleware.local",
},
# Missing middleware_hostname
{"id": "123", "local_ip_address": "192.168.0.1"},
# Missing local_ip_address
{"id": "123", "middleware_hostname": "middleware.local"},
# Invalid insecure_connection
{
"id": "123",
"local_ip_address": "192.168.0.1",
"middleware_hostname": "middleware.local",
"insecure_connection": "invalid_value",
},
# Camera access key not required for HL7Monitor, invalid meta
{
"id": "123",
"local_ip_address": "192.168.0.1",
"camera_access_key": "username:password:access_key",
"middleware_hostname": "middleware.local",
"insecure_connection": True,
},
]
for meta in invalid_meta_cases:
self.validate_invalid_meta(HL7MonitorAsset, meta)

def test_list_assets(self):
response = self.client.get("/api/v1/asset/")
self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand Down Expand Up @@ -184,8 +325,8 @@

class AssetConfigValidationTestCase(TestUtils, APITestCase):
@classmethod
def setUpTestData(cls) -> None:

Check notice on line 328 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 naming convention violation

Function name should be lowercase
cls.state = cls.create_state()

Check notice on line 329 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code

Check notice on line 329 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code
cls.district = cls.create_district(cls.state)
cls.local_body = cls.create_local_body(cls.district)
cls.super_user = cls.create_super_user("su", cls.district)
Expand All @@ -200,7 +341,7 @@
cls.user = cls.create_user("staff", cls.district, home_facility=cls.facility)

def test_create_asset_with_unique_ip(self):
sample_data = {

Check notice on line 344 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code

Check notice on line 344 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code
"name": "Test Asset",
"asset_type": 50,
"location": self.asset_location.external_id,
Expand All @@ -217,7 +358,7 @@
asset_class=AssetClasses.HL7MONITOR.name,
meta={"local_ip_address": "192.168.1.14"},
)
sample_data = {

Check notice on line 361 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code

Check notice on line 361 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code
"name": "Test Asset",
"asset_type": 50,
"location": self.asset_location.external_id,
Expand All @@ -238,7 +379,7 @@
asset_class=AssetClasses.HL7MONITOR.name,
meta={"local_ip_address": "192.168.1.14"},
)
sample_data = {

Check notice on line 382 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code

Check notice on line 382 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code

Check notice on line 382 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code

Check notice on line 382 in care/facility/tests/test_asset_api.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

Duplicated code fragment

Duplicated code
"name": "Test Asset",
"asset_type": 50,
"location": test_location.external_id,
Expand Down
Loading
Loading