def test_register_failed(mock_logger, mock_hospital_reg): aHospital = hospital.Hospital() aHospital.initialize(hospital_json, "certificate") aHospital.setLogger(mock_logger) mock_hospital_reg.return_value = False print(aHospital.register()) assert aHospital.register() == (False, "Registration Failed.")
def test_register(mock_hospital_reg, mock_url_for): aHospital = hospital.Hospital() aHospital.initialize(hospital_json, "certificate") aHospital.setLogger(logging.getLogger()) mock_url_for.return_value = "http://url" mock_hospital_reg.return_value = True assert aHospital.register() == (True, "http://url")
def createObject(self): try: self.logger.info("createObject logger initialized") if(self.usertype == "Hospital"): return ho.build_Hospital(ho.Hospital, self.json,self.logger, self.certificate) elif(self.usertype == "Donor or Receiver"): return us.build_User(us.User,self.json, self.logger) elif(self.usertype == "Admin"): return ao.build_Admin(ao.Admin,self.json, self.logger) else: return None except Exception as err: self.logger.error(err) return err
def test_build_hospital(mock_logger): aHospital = hospital.Hospital() aHospital.initialize(hospital_json) aHospital.setLogger(logger) assert type(hospital.build_Hospital(hospital.Hospital, hospital_json, logger)).__name__ == type(aHospital).__name__
def test_login_failed(mock_login): aHospital = hospital.Hospital() mock_login.return_value = None aHospital.setLogger(logging.getLogger()) aHospital.initialize(hospital_json, "certificate") assert aHospital.login() == (False, "Authentication Failed")
def test_login(mock_login): aHospital = hospital.Hospital() mock_login.return_value = "login ok" aHospital.setLogger(logging.getLogger()) aHospital.initialize(hospital_json, "certificate") assert aHospital.login() == ("login ok", "/hospitalHome/[email protected]")
def test_setlogger(mock_logger): aHospital = hospital.Hospital() aHospital.setLogger(mock_logger)
def test_register_exception(mock_hospital_reg): aHospital = hospital.Hospital() aHospital.initialize(hospital_json, "certificate") mock_hospital_reg.side_effect = Exception("register exception") aHospital.register()