def test_set_account_public(self): user = User() user.set_account_public("user_1", False) user.set_account_public("user_2", True) self.assertFalse(user.is_account_public("user_1")) self.assertTrue(user.is_account_public("user_2"))
def change_account_public(event, _): """ Change the public visibility of an account :param event: event :return: 200 if the change was successful, 400 otherwise """ # Check if the user is logged in correctly username = get_logged_in_user(event) if not username: return create_response(400, "POST", "User not logged in correctly") # Get the new value of the public option new_is_public = event["body"] == "1" # Change the user public setting user = User() user.set_account_public(username, new_is_public) return create_response(200, "POST")