test: Healthcare Masters

This commit is contained in:
Rucha Mahabal 2020-03-23 12:31:13 +05:30
parent 4f9a1471e4
commit f67afe67ab
3 changed files with 57 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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()