- with self.assertRaises(EngineException, msg="Accepted wrong project-role mappings") as e:
- self.topic.edit(self.fake_session, uid, {"username": new_name, "project_role_mappings": new_prms})
- self.assertEqual(e.exception.http_code, HTTPStatus.UNPROCESSABLE_ENTITY, "Wrong HTTP status code")
- self.assertIn("format error at '{}' '{}'"
- .format("project_role_mappings:{}", "'{}' is a required property").format(0, "project"),
- norm(str(e.exception)), "Wrong exception text")
+ with self.assertRaises(
+ EngineException, msg="Accepted wrong project-role mappings"
+ ) as e:
+ self.topic.edit(
+ self.fake_session,
+ uid,
+ {"username": new_name, "project_role_mappings": new_prms},
+ )
+ self.assertEqual(
+ e.exception.http_code,
+ HTTPStatus.UNPROCESSABLE_ENTITY,
+ "Wrong HTTP status code",
+ )
+ self.assertIn(
+ "format error at '{}' '{}'".format(
+ "project_role_mappings:{}", "'{}' is a required property"
+ ).format(0, "project"),
+ norm(str(e.exception)),
+ "Wrong exception text",
+ )
+ with self.subTest(i=3):
+ self.auth.get_user_list.side_effect = [[user], []]
+ self.auth.get_user.return_value = user
+ old_password = self.test_name
+ new_pasw = "new-password"
+ self.topic.edit(
+ self.fake_session,
+ uid,
+ {
+ "old_password": old_password,
+ "password": new_pasw,
+ },
+ )
+ content = self.auth.update_user.call_args[0][0]
+ self.assertEqual(content["old_password"], old_password, "Wrong old password")
+ self.assertEqual(content["password"], new_pasw, "Wrong user password")