Пример #1
0
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.")
Пример #2
0
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")
Пример #3
0
 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
Пример #4
0
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__
Пример #5
0
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")
Пример #6
0
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]")
Пример #7
0
def test_setlogger(mock_logger):
  aHospital = hospital.Hospital()
  aHospital.setLogger(mock_logger)
Пример #8
0
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()