def test_export(self): FILENAME = 'conf/users.conf' self.assertFalse(os.path.exists(FILENAME)) Users.export() self.assertTrue(os.path.exists(FILENAME))
def test_first_user(self): first_user = Users.first() self.assertEqual(first_user.id, _DEFAULT_USER) self.assertEqual(first_user.password, _DEFAULT_PASSWORD) Users.users = {} self.assertIsNone(Users.first())
def test_auth_negative(self): self.assertEqual(Users.auth(_DEFAULT_USER, 'wrong_pwd', _DEFAULT_HOST), None) self.assertEqual(Users.auth('wrong_user', _DEFAULT_PASSWORD, _DEFAULT_HOST), None)
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)
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 initThread(app): nut.scan() app.refresh() if Config.autolaunchBrowser: webbrowser.open_new_tab('http://' + urllib.parse.quote_plus(Users.first().id) + ':' + urllib.parse.quote_plus(Users.first().password) + '@' + getIpAddress() + ':' + str(Config.server.port))
def test_save(self): # pylint: disable = no-self-use Users.save()
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_serialize(self): user = Users.first() serialized = user.serialize() self.assertEqual(serialized, "guest|guest")
def getValue(self): user = Users.User() user.id = self.user.getValue() user.password = self.password.getValue() return user