def setUp(self):
        # login first
        login_helpers.login(self.client)

        # Create 2 coordinators
        first_name = names.get_first_name()
        last_name = names.get_last_name()
        coordinator_1_details = {
            "first_name": first_name, "last_name": last_name, "email": first_name + last_name + "@gmail.com"
        }
        object_creation_helpers.createUser(
            Roles.coordinator, coordinator_1_details)
        first_name = names.get_first_name()
        last_name = names.get_last_name()
        coordinator_2_details = {
            "first_name": first_name, "last_name": last_name, "email": first_name + last_name + "@gmail.com"
        }
        object_creation_helpers.createUser(
            Roles.coordinator, coordinator_2_details)

        # Create subjects and assign each coordinator to one of the two subjects
        coordinator_1_id = User.objects.get(
            email=coordinator_1_details["email"]).user_id
        coordinator_2_id = User.objects.get(
            email=coordinator_2_details["email"]).user_id
        object_creation_helpers.createSubject(
            "SWEN90013", "Master Advanced Software Project", coordinator_1_id)
        object_creation_helpers.createSubject(
            "SWEN90014", "Master Software Engineering Project", coordinator_2_id)
    def test_get_team_members_success(self):
        """
        Tests the success scenario for function get_team_members
        for the API: Get 'team/<int:id>'
        """
        session = self.client.session
        # Set up supervisor
        first_name = names.get_first_name()
        last_name = names.get_last_name()
        session["supervisor_1_details"] = {
            "first_name": first_name,
            "last_name": last_name,
            "email": first_name + last_name + "gmail.com"
        }
        session.save()
        object_creation_helpers.createUser(Roles.supervisor, session["supervisor_1_details"])

        # Set up secondary supervisor
        first_name = names.get_first_name()
        last_name = names.get_last_name()
        session["supervisor_2_details"] = {
            "first_name": first_name,
            "last_name": last_name,
            "email": first_name + last_name + "gmail.com"
        }
        session.save()
        object_creation_helpers.createUser(Roles.supervisor, session["supervisor_2_details"])

        response = self.client.get('/api/v1/team/1')
        expected_data = {
            'supervisor': {
                'supervisor_id': 2,
                'supervisor_first_name': session["supervisor_1_details"]["first_name"],
                'supervisor_last_name': session["supervisor_1_details"]["last_name"],
                'email': session["supervisor_1_details"]["email"]
            },
            'secondary_supervisor': {
                'secondary_supervisor_id': 3,
                'secondary_supervisor_first_name': session["supervisor_2_details"]["first_name"],
                'secondary_supervisor_last_name': session["supervisor_2_details"]["last_name"],
                'email': session["supervisor_2_details"]["email"]
            },
            'team_members': [
                {
                    'student_id': self.members[0]["student_id"],
                    'fullname': self.students[0]["fullname"],
                    'email': self.students[0]["email"]
                },
                {
                    'student_id': self.members[1]["student_id"],
                    'fullname': self.students[1]["fullname"],
                    'email': self.students[1]["email"]
                }
            ]
        }
        self.assertEqual(response.json()["data"], expected_data, 'Get team members data is not as expected.')
 def setUp(self):
     login_helpers.login(self.client)
     # Create a coordinator
     first_name = names.get_first_name()
     last_name = names.get_last_name()
     session = self.client.session
     session["coordinator_1_details"] = {
         "first_name": first_name, "last_name": last_name, "email": first_name + last_name + "@gmail.com"
     }
     session.save()
     object_creation_helpers.createUser(Roles.coordinator, session["coordinator_1_details"])
Exemplo n.º 4
0
 def setUp(self):
     login_helpers.login(self.client)
     # Create a coordinator
     first_name = names.get_first_name()
     last_name = names.get_last_name()
     session = self.client.session
     session["coordinator_1_details"] = {
         "first_name": first_name,
         "last_name": last_name,
         "email": first_name + last_name + "@gmail.com"
     }
     session.save()
     object_creation_helpers.createUser(Roles.coordinator,
                                        session["coordinator_1_details"])
     coordinator_1_id = User.objects.get(
         email=session["coordinator_1_details"]["email"]).user_id
     object_creation_helpers.createSubject(
         "SWEN90013", "Master Advanced Software Project", coordinator_1_id)
    def setUp(self):
        # login first
        login_helpers.login(self.client)

        # Create 3 supervisors
        self.supervisors_names = {}
        # Note each supervisors' id offfset by 1 as there is an existing user before any of the supervisors -> admin
        for i in range(3):
            first_name = names.get_first_name()
            last_name = names.get_last_name()
            email = first_name + "@gmail.com"
            userDetails = {
                'first_name': first_name,
                'last_name': last_name,
                'email': email
            }
            self.supervisors_names[str(i + 2)] = {
                'first_name': first_name,
                'last_name': last_name,
                'full_name': first_name + ' ' + last_name
            }
            object_creation_helpers.createUser(Roles.supervisor, userDetails)
Exemplo n.º 6
0
    def setUpTestData(cls):
        # set up an admin
        object_creation_helpers.createGenericAdmin()

        # set up a coordinator
        object_creation_helpers.createUser(Roles.coordinator, object_creation_helpers.generateUserDetails())

        # set up a supervisor
        object_creation_helpers.createUser(Roles.supervisor, object_creation_helpers.generateUserDetails())

        # set up a second primary supervisor
        object_creation_helpers.createUser(Roles.supervisor, object_creation_helpers.generateUserDetails())

        # set up a secondary supervisor
        object_creation_helpers.createUser(Roles.supervisor, object_creation_helpers.generateUserDetails())

        # set up a subject
        object_creation_helpers.createSubject('123', 'test_subject', 2)

        # set up three teams
        team_data = {
            "name": "team_1",
            "subject_code": '123',
            "supervisor_id": 3,
            "secondary_supervisor_id": 5,
            "year": "2020",
            "create_date": "01012020",
            "project_name": "test_project_1",
            "sprint_start_0": "1",
            "sprint_end_0": "1",
            "sprint_start_1": "1",
            "sprint_end_1": "1",
            "sprint_start_2": "1",
            "sprint_end_2": "1",
            "sprint_start_3": "1",
            "sprint_end_3": "1",
            "sprint_start_4": "1",
            "sprint_end_4": "1",
        }
        team = Team(name=team_data["name"],
                    subject_code=team_data["subject_code"],
                    supervisor_id=team_data["supervisor_id"],
                    secondary_supervisor_id=team_data["secondary_supervisor_id"],
                    year=team_data["year"],
                    create_date=team_data["create_date"],
                    project_name=team_data["project_name"],
                    sprint_start_0=team_data["sprint_start_0"],
                    sprint_end_0=team_data["sprint_end_0"],
                    sprint_start_1=team_data["sprint_start_1"],
                    sprint_end_1=team_data["sprint_end_1"],
                    sprint_start_2=team_data["sprint_start_2"],
                    sprint_end_2=team_data["sprint_end_2"],
                    sprint_start_3=team_data["sprint_start_3"],
                    sprint_end_3=team_data["sprint_end_3"],
                    sprint_start_4=team_data["sprint_start_4"],
                    sprint_end_4=team_data["sprint_end_4"],
                    )
        team.save()
        team_data = {
            "name": "team_2",
            "subject_code": '123',
            "supervisor_id": 3,
            "secondary_supervisor_id": 5,
            "year": "2020",
            "create_date": "01012020",
            "project_name": "test_project_2",
            "sprint_start_0": "1",
            "sprint_end_0": "1",
            "sprint_start_1": "1",
            "sprint_end_1": "1",
            "sprint_start_2": "1",
            "sprint_end_2": "1",
            "sprint_start_3": "1",
            "sprint_end_3": "1",
            "sprint_start_4": "1",
            "sprint_end_4": "1",
        }
        team = Team(name=team_data["name"],
                    subject_code=team_data["subject_code"],
                    supervisor_id=team_data["supervisor_id"],
                    secondary_supervisor_id=team_data["secondary_supervisor_id"],
                    year=team_data["year"],
                    create_date=team_data["create_date"],
                    project_name=team_data["project_name"],
                    sprint_start_0=team_data["sprint_start_0"],
                    sprint_end_0=team_data["sprint_end_0"],
                    sprint_start_1=team_data["sprint_start_1"],
                    sprint_end_1=team_data["sprint_end_1"],
                    sprint_start_2=team_data["sprint_start_2"],
                    sprint_end_2=team_data["sprint_end_2"],
                    sprint_start_3=team_data["sprint_start_3"],
                    sprint_end_3=team_data["sprint_end_3"],
                    sprint_start_4=team_data["sprint_start_4"],
                    sprint_end_4=team_data["sprint_end_4"],
                    )
        team.save()
        team_data = {
            "name": "team_3",
            "subject_code": '123',
            "supervisor_id": 4,
            "secondary_supervisor_id": 5,
            "year": "2020",
            "create_date": "01012020",
            "project_name": "test_project_3",
            "sprint_start_0": "1",
            "sprint_end_0": "1",
            "sprint_start_1": "1",
            "sprint_end_1": "1",
            "sprint_start_2": "1",
            "sprint_end_2": "1",
            "sprint_start_3": "1",
            "sprint_end_3": "1",
            "sprint_start_4": "1",
            "sprint_end_4": "1",
        }
        team = Team(name=team_data["name"],
                    subject_code=team_data["subject_code"],
                    supervisor_id=team_data["supervisor_id"],
                    secondary_supervisor_id=team_data["secondary_supervisor_id"],
                    year=team_data["year"],
                    create_date=team_data["create_date"],
                    project_name=team_data["project_name"],
                    sprint_start_0=team_data["sprint_start_0"],
                    sprint_end_0=team_data["sprint_end_0"],
                    sprint_start_1=team_data["sprint_start_1"],
                    sprint_end_1=team_data["sprint_end_1"],
                    sprint_start_2=team_data["sprint_start_2"],
                    sprint_end_2=team_data["sprint_end_2"],
                    sprint_start_3=team_data["sprint_start_3"],
                    sprint_end_3=team_data["sprint_end_3"],
                    sprint_start_4=team_data["sprint_start_4"],
                    sprint_end_4=team_data["sprint_end_4"],
                    )
        team.save()