@ensure_empty_collections("users", "teams")
    @clear_collections("users", "teams")
    def test_create_user_request_existing_team(self):

        tid = api.team.create_team(base_team.copy())
        assert tid, "Team was not created."

        uid = api.user.create_user_request(base_user.copy())
        assert uid == api.user.get_user(name=base_user["username"])["uid"], "Good user created unsuccessfully."

        with pytest.raises(WebException):
            api.user.create_user_request(base_user.copy())
            assert False, "Was able to register and join the team twice."

        with pytest.raises(WebException):
            invalid_team_user = base_user.copy()
            invalid_team_user["team-name-existing"] = "Totally Invalid"
            api.user.create_user_request(invalid_team_user)
            assert False, "Was able to join a team that doesn't exist."

        with pytest.raises(WebException):
            invalid_team_user = base_user.copy()
            invalid_team_user["team-password-existing"] = "Not correct"
            api.user.create_user_request(invalid_team_user)
            assert False, "Was able to join a team with an invalid password."

        team_uids = api.team.get_team_uids(tid)

        assert uid in team_uids, "User was not successfully placed into the existing team."
        assert len(team_uids) == 1, "Invalid teams were created though the tests passed."
Tests the registration of users on existing teams.
dataset/ETHPy150Open EasyCTF/easyctf-2015/api/tests/user_test.py/TestUsers.test_create_user_request_existing_team