def test_user_load_csv(self): user = Users.User() USER = '******' PASSWORD = '******' csv = f'{USER}|{PASSWORD}' user.loadCsv(csv, map=['id', 'password']) self.assertEqual(user.id, USER) self.assertEqual(user.password, PASSWORD)
def test_user_get_switch_port(self): user = Users.User() new_switch_port = 1234 user.setSwitchPort(new_switch_port) self.assertEqual(user.getSwitchPort(), new_switch_port) user.setSwitchPort('wrong_port') self.assertEqual(user.switchPort, new_switch_port)
def test_user_set_is_admin(self): user = Users.User() self.assertFalse(user.isAdmin) user.setIsAdmin(True) self.assertTrue(user.isAdmin) user.setIsAdmin(False) user.setIsAdmin('incorrect') self.assertFalse(user.isAdmin) user.setIsAdmin(True) user.setIsAdmin('incorrect') self.assertTrue(user.isAdmin)
def test_user_set_require_auth(self): user = Users.User() self.assertTrue(user.requireAuth) user.setRequireAuth(False) self.assertFalse(user.requireAuth) user.setRequireAuth(True) user.setRequireAuth('incorrect') self.assertTrue(user.requireAuth) user.setRequireAuth(False) user.setRequireAuth('incorrect') self.assertFalse(user.requireAuth)
def getValue(self): user = Users.User() user.id = self.user.getValue() user.password = self.password.getValue() return user
def test_user_load_csv_with_empty_map(self): user = Users.User() user.loadCsv("id|pwd") self.assertIsNone(user.id) self.assertIsNone(user.password)
def test_user_get_require_auth(self): user = Users.User() self.assertIs(user.getRequireAuth(), 'True', 'All users require Auth by default') user.setRequireAuth(False) self.assertIs(user.getRequireAuth(), 'False')
def test_user_get_switch_host(self): user = Users.User() new_switch_host = 'local' user.setSwitchHost(new_switch_host) self.assertEqual(user.getSwitchHost(), new_switch_host)