def test_get_all_when_single_user(self): # Need to start clean installation to ensure no other users with start_shinobi() as shinobi_client: user_orm = ShinobiUserOrm(shinobi_client) user = user_orm.create(*_create_email_and_password()) users = user_orm.get_all() self.assertEqual(1, len(users)) self.assertEqual(user["email"], users[0]["email"])
def test_modify_password(self): user = self._create_user() _, password = _create_email_and_password() assert user["pass"] != password changed = self.user_orm.modify(user["email"], password=password) self.assertTrue(changed is None or changed is True) self.assertRaises(ShinobiWrongPasswordError, self.api_key.get, user["email"], user["pass"]) self.assertIsNotNone(self.api_key.get(user["email"], password))
def test_create_with_multiple_users(self): user_1_orm = self.monitor_orm user_2 = self.shinobi_client.user.create(*_create_email_and_password()) user_2_orm = ShinobiMonitorOrm(self.superless_shinobi_client, user_2["email"], user_2["password"]) monitor_id = _create_monitor_id() user_1_orm.create(monitor_id, EXAMPLE_MONITOR_1_CONFIGURATION) self.assertEqual(0, len(user_2_orm.get_all()))
def test_modify_password_when_user_not_exist(self): email, password = _create_email_and_password() self.assertRaises(ShinobiUserDoesNotExistError, self.user_orm.modify, email, password=password)
def test_get_using_invalid_user_credentials(self): email, password = _create_email_and_password() self.assertRaises(ShinobiWrongPasswordError, self.superless_user_orm.get, email, password)
def test_create_when_already_exists(self): email, password = _create_email_and_password() self.user_orm.create(email, password) self.assertRaises(ShinobiUserAlreadyExistsError, self.user_orm.create, email, password)
def test_create_requires_super_user_credentials(self): email, password = _create_email_and_password() self.assertRaises(ShinobiSuperUserCredentialsRequiredError, self.superless_user_orm.create, email, password)
def test_create(self): email, password = _create_email_and_password() self.user_orm.create(email, password) user = self.user_orm.get(email) self.assertEqual(email, user["mail"]) self.assertIsNotNone(self.api_key.get(email, password))
def test_delete_when_user_not_exist(self): email, _ = _create_email_and_password() self.assertFalse(self.user_orm.delete(email))
def test_get_user(self): email, password = _create_email_and_password() self.shinobi_client.user.create(email, password) self.assertIsNotNone(self.shinobi_client.user.get(email))
def setUp(self): super().setUp() email, password = _create_email_and_password() self.user = self.shinobi_client.user.create(email, password) self.monitor_orm = ShinobiMonitorOrm(self.superless_shinobi_client, email, password)