0

New to the coding world- I am trying to use unittest to test the class MuseData with functions EEG, HeartRate, and RespirationRate Measurement. When I run this unittest, it results in 0 tests run in 0 seconds. I am looking for user input for the user's name and these measurements and I want the output to tell the user whether their measurement is normal or abnormal.

name=input('Please enter your first and last name.')
print(name)
st=''

class MuseData():
    def __init__(self, EEG, Heart, Resp): 
        self.EEG = EEG
        self.Heart= Heart
        self.Resp= Resp
    #Reviewing Session Data in order to decide whether there are abnormal values. If so, an abnormal value alert is created.
    def EEGMeasurement():
        for EEGMeasurement in range(11,101) :
            EEG=int(input('Please enter EEG Measurement(mV).'))
            print(EEG)
            if EEG in range (11,101):
                st='EEG Measurement is normal.'
                print(st)
                break
            else:
                from datetime import datetime
                from datetime import date
                today = date.today()
                st='EEG Measurement is abnormal. Your provider will contact you shortly.'
                print (st)
    #how do I send an abnormal value alert to Provider via an EMR system?
                print("Abnormal Value Alert to EMR:", name, "'s MUSE EEG session on", today, "shows abnormal results. Please review and consult with the patient.")
                break
                #send alert to provider
        return(st)

    #send EEGMeasurement to EMR
    #Provider will receive alert in EMR if abnormal   

    def HeartRateMeasurement():
        for HeartRateMeasurement in range(61,101) :
            Heart=int(input('Please enter Heart Rate Measurement(beats/minute).'))
            print(Heart)
            if Heart in range (61,101):
                st='Heart Rate is normal.'
                print(st)
                break
            else:
                from datetime import datetime
                from datetime import date
                today = date.today()
                st='Heart Rate is abnormal. Your provider will contact you shortly.'
                print(st)
                #send alert to provider
                print("Abnormal Value Alert to EMR:", name, "'s MUSE Heart Rate session on", today, "shows abnormal results. Please review and consult with the patient.")
                break
        return(st)
    #send HeartRate to EMR
    #Provider will receive alert in EMR if abnormal   

    def RespirationRateMeasurement():
        for RespirationRateMeasurement in range(13,21) :
            Resp=int(input('Please enter Respiration Rate Measurement (breaths/minute).'))
            print(Resp)
            if Resp in range (13,21):
                st='Respiration Rate is normal.'
                print(st)
                break
            else:
                from datetime import datetime
                from datetime import date
                today = date.today()
                st='Respiration Rate is abnormal. Your provider will contact you shortly.'
                print(st)
                #send alert to provider
                print("Abnormal Value Alert to EMR: Patient's MUSE Respiration Rate session on", today, "shows abnormal results. Please review and consult with the patient.")
                break  
        return(st)
MuseData.EEGMeasurement()
MuseData.HeartRateMeasurement()
MuseData.RespirationRateMeasurement()
import unittest 

class Test_Measurement(unittest.TestCase):
    def Test_EEGMeasurement(self):
        m= MuseData(80,95,100) 
        self.assertEqual(m.EEGMeasurement(), 'EEG Measurement is normal.' ) 
    def Test_HeartRateMeasurement(self):
        m= MuseData(63,87,91) 
        self.assertEqual(m.HeartRateMeasurement(), 'Heart Rate is normal.' ) 
    def Test_RespirationRateMeasurement(self):
        m= MuseData(18,19,20) 
        self.assertEqual(m.RespirationRateMeasurement(), 'Respiration Rate is normal.' ) 


if __name__ == '__main__':
    unittest.main(argv=['first-arg-is-ignored'], exit=False)

There isn't an specific error that shows when the unittest is run, so I am not sure where the issue lies.

NicM2020
  • 9
  • 2
  • Your test function should start with a lowercase `test`, otherwise they are nor recognized as tests by the unitttest test discovery. – MrBean Bremen May 01 '20 at 13:34
  • @MrBeanBremen Thanks! Yes, it runs now but I get the 'TypeError: EEGMeasurement() takes 0 positional arguments but 1 was given' for all the measurement functions. I see that others' solution was to add 'self' but I have them in there already. – NicM2020 May 01 '20 at 14:05
  • Well, you always need a `self` argument in non-static methods - you may read up on Python classes and methods. If you still have problems with your function, please write a new question with another subject, and the really used code. – MrBean Bremen May 01 '20 at 14:36

0 Answers0