From f67afe67ab4778dd05aaaf426aa339579e1af630 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Mon, 23 Mar 2020 12:31:13 +0530 Subject: [PATCH] test: Healthcare Masters --- .../test_healthcare_service_unit_type.py | 31 ++++++++++++++++++- .../inpatient_record/test_inpatient_record.py | 1 + .../doctype/patient/test_patient.py | 29 +++++++++++++++-- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/test_healthcare_service_unit_type.py b/erpnext/healthcare/doctype/healthcare_service_unit_type/test_healthcare_service_unit_type.py index 3c5b64fd93..2f019df02a 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit_type/test_healthcare_service_unit_type.py +++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/test_healthcare_service_unit_type.py @@ -3,6 +3,35 @@ # See license.txt from __future__ import unicode_literals import unittest +import frappe class TestHealthcareServiceUnitType(unittest.TestCase): - pass + def setUp(self): + frappe.db.sql("""delete from `tabHealthcare Service Unit Type`""") + frappe.db.sql("""delete from `tabItem`""") + + def test_item_creation(self): + unit_type = get_unit_type() + self.assertTrue(frappe.db.exists('Item', unit_type.item)) + + # check item disabled + unit_type.disabled = 1 + unit_type.save() + self.assertEqual(frappe.db.get_value('Item', unit_type.item, 'disabled'), 1) + + +def get_unit_type(): + if frappe.db.exists('Healthcare Service Unit Type', 'Inpatient Rooms'): + return frappe.get_doc('Healthcare Service Unit Type', 'Inpatient Rooms') + + unit_type = frappe.new_doc('Healthcare Service Unit Type') + unit_type.service_unit_type = 'Inpatient Rooms' + unit_type.inpatient_occupancy = 1 + unit_type.is_billable = 1 + unit_type.item_code = 'Inpatient Rooms' + unit_type.item_group = 'Services' + unit_type.uom = 'Hour' + unit_type.no_of_hours = 1 + unit_type.rate = 4000 + unit_type.save() + return unit_type \ No newline at end of file diff --git a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py index 1683492f64..6154a745de 100644 --- a/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/test_inpatient_record.py @@ -81,6 +81,7 @@ def get_patient(): patient = frappe.new_doc("Patient") patient.first_name = "_Test Patient" patient.sex = "Male" + patient.mobile = 9876345675 patient.save(ignore_permissions=True) return patient.name return patient diff --git a/erpnext/healthcare/doctype/patient/test_patient.py b/erpnext/healthcare/doctype/patient/test_patient.py index aebaa6b989..23695e7467 100644 --- a/erpnext/healthcare/doctype/patient/test_patient.py +++ b/erpnext/healthcare/doctype/patient/test_patient.py @@ -4,8 +4,31 @@ from __future__ import unicode_literals import unittest - -# test_records = frappe.get_test_records('Patient') +import frappe +from erpnext.healthcare.doctype.inpatient_record.test_inpatient_record import get_patient class TestPatient(unittest.TestCase): - pass + def test_customer_created(self): + frappe.db.sql("""delete from `tabPatient`""") + frappe.db.set_value('Healthcare Settings', None, 'link_customer_to_patient', 1) + patient = get_patient() + self.assertTrue(frappe.db.get_value('Patient', patient, 'customer')) + + def test_patient_registration(self): + frappe.db.sql("""delete from `tabPatient`""") + settings = frappe.get_single('Healthcare Settings') + settings.collect_registration_fee = 1 + settings.registration_fee = 500 + settings.save() + + patient = get_patient() + patient = frappe.get_doc('Patient', patient) + self.assertEqual(patient.status, 'Disabled') + + # check sales invoice and patient status + result = patient.invoice_patient_registration() + self.assertTrue(frappe.db.exists('Sales Invoice', result.get('invoice'))) + self.assertTrue(patient.status, 'Active') + + settings.collect_registration_fee = 0 + settings.save()