def test_login(self): from evista.models.vista_user import VistaUser from efms.constants import TEST_USERS user = VistaUser() access_code = TEST_USERS['Doctor']['access_code'] verify_code = TEST_USERS['Doctor']['verify_code'] context = 'OR CPRS GUI CHART' greeting = user.login(self.cxn, access_code, verify_code, context, [14,4]) self.assertEqual(access_code, user.access_code) self.assertEqual(verify_code, user.verify_code) self.assertEqual(context, user.context) self.assertEqual('31', user.duz) self.assertTrue(greeting.find(TEST_USERS['Doctor']['name']))
def test_login_failed(self): self.cxn.connect() self.assertTrue(self.cxn.is_connected) user = VistaUser() access_code = '1programmer' verify_code = 'programmer1.' context = 'OR CPRS GUI CHART' try: greeting = user.login(self.cxn, access_code, verify_code, context) self.fail('Expected exception, got greeting: %s' % greeting) except VistaException, e: self.assertEquals('Not a valid ACCESS CODE/VERIFY CODE pair.', str(e))
def test_login_valid(self): self.cxn.connect() self.assertTrue(self.cxn.is_connected) user = VistaUser() access_code = TEST_USERS['Doctor']['access_code'] verify_code = TEST_USERS['Doctor']['verify_code'] context = 'OR CPRS GUI CHART' greeting = user.login(self.cxn, access_code, verify_code, context) self.assertEqual(access_code, user.access_code) self.assertEqual(verify_code, user.verify_code) self.assertEqual(context, user.context) self.assertEqual('31', user.duz) self.assertTrue(greeting.find(TEST_USERS['Doctor']['name']))
def test_login_change_verify_code(self): self.cxn.connect() self.assertTrue(self.cxn.is_connected) user = VistaUser() # access_code = TEST_USERS['Nurse']['access_code'] # verify_code = TEST_USERS['Nurse']['verify_code'] access_code = TEST_USERS['Sysadmin']['access_code'] verify_code = TEST_USERS['Sysadmin']['verify_code'] context = 'OR CPRS GUI CHART' try: greeting = user.login(self.cxn, access_code, verify_code, context) self.fail('Expected exception, got greeting: %s' % greeting) except VistaException, e: self.assertEquals('VERIFY CODE must be changed before continued use.', str(e))