def test_ta_views_visibility(self):
        views = (
            NavigationViewXBlock, SubmissionsViewXBlock, ResourcesViewXBlock,
            PrivateDiscussionViewXBlock, AskTAViewXBlock
        )
        switch_to_ta_grading(self.project_api_mock)
        scenario_xml = self.build_scenario([view.CATEGORY for view in views])
        self.load_scenario_xml(scenario_xml)
        scenario = self.go_to_view()
        page = GroupProjectElement(self.browser, scenario)
        project_navigator = page.project_navigator

        view_types = tuple([view.type for view in project_navigator.views])
        view_selector_types = tuple([view.type for view in project_navigator.view_selectors])

        self.assertEqual(
            view_types,
            (
                NavigationViewXBlock.type, SubmissionsViewXBlock.type, ResourcesViewXBlock.type,
                PrivateDiscussionViewXBlock.type
            )
        )
        self.assertEqual(
            view_selector_types,
            (SubmissionsViewXBlock.type, ResourcesViewXBlock.type, PrivateDiscussionViewXBlock.type)
        )
    def test_ta_views_visibility(self):
        views = (
            NavigationViewXBlock, SubmissionsViewXBlock, ResourcesViewXBlock,
            PrivateDiscussionViewXBlock, AskTAViewXBlock
        )
        switch_to_ta_grading(self.project_api_mock)
        scenario_xml = self.build_scenario([view.CATEGORY for view in views])
        self.load_scenario_xml(scenario_xml)
        scenario = self.go_to_view()
        page = GroupProjectElement(self.browser, scenario)
        project_navigator = page.project_navigator

        view_types = tuple([view.type for view in project_navigator.views])
        view_selector_types = tuple([view.type for view in project_navigator.view_selectors])

        self.assertEqual(
            view_types,
            (
                NavigationViewXBlock.type, SubmissionsViewXBlock.type, ResourcesViewXBlock.type,
                PrivateDiscussionViewXBlock.type
            )
        )
        self.assertEqual(
            view_selector_types,
            (SubmissionsViewXBlock.type, ResourcesViewXBlock.type, PrivateDiscussionViewXBlock.type)
        )
    def test_submissions_view(self, as_ta):
        student_id = 1
        if as_ta:
            switch_to_ta_grading(self.project_api_mock)
            student_id = 100
        issue_tree_loc = self.submissions['issue_tree']['document_url']
        self.project_api_mock.get_latest_workgroup_submissions_by_id.return_value = self.submissions

        self._prepare_page(student_id=student_id)

        submissions_view = self.page.project_navigator.get_view_by_type(ViewTypes.SUBMISSIONS, SubmissionsViewElement)
        self.page.project_navigator.get_view_selector_by_type(ViewTypes.SUBMISSIONS).click()

        activities = submissions_view.activities
        self.assertEqual(activities[0].activity_name, "Activity 1".upper())
        self.assertEqual(activities[1].activity_name, "Activity 2".upper())

        self.assertEqual(activities[1].submissions, [])

        activity1_submissions = activities[0].submissions
        issue_tree, marketing_pitch, budget = activity1_submissions

        def _assert_submission(submission, title, location, uploaded_by):
            self.assertEqual(submission.title, title)
            self.assertEqual(submission.file_location, location)
            self.assertEqual(submission.uploaded_by, uploaded_by)
            self.assertTrue(submission.upload_enabled)

        issue_tree_uploaded = "Uploaded by {user} on {date}".format(user=KNOWN_USERS[1].full_name, date="May 22")
        _assert_submission(issue_tree, "Issue Tree", issue_tree_loc, issue_tree_uploaded)
        _assert_submission(marketing_pitch, "Marketing Pitch", None, '')
        _assert_submission(budget, "Budget", None, '')
    def test_submissions_view(self, as_ta):
        student_id = 1
        if as_ta:
            switch_to_ta_grading(self.project_api_mock)
            student_id = 100
        issue_tree_loc = self.submissions['issue_tree']['document_url']
        self.project_api_mock.get_latest_workgroup_submissions_by_id.return_value = self.submissions

        self._prepare_page(student_id=student_id)

        submissions_view = self.page.project_navigator.get_view_by_type(ViewTypes.SUBMISSIONS, SubmissionsViewElement)
        self.page.project_navigator.get_view_selector_by_type(ViewTypes.SUBMISSIONS).click()

        activities = submissions_view.activities
        self.assertEqual(activities[0].activity_name, "Activity 1".upper())
        self.assertEqual(activities[1].activity_name, "Activity 2".upper())

        self.assertEqual(activities[1].submissions, [])

        activity1_submissions = activities[0].submissions
        issue_tree, marketing_pitch, budget = activity1_submissions

        def _assert_submission(submission, title, location, uploaded_by):
            self.assertEqual(submission.title, title)
            self.assertEqual(submission.file_location, location)
            self.assertEqual(submission.uploaded_by, uploaded_by)
            self.assertTrue(submission.upload_enabled)

        issue_tree_uploaded = "Uploaded by {user} on {date}".format(user=KNOWN_USERS[1].full_name, date="May 22")
        _assert_submission(issue_tree, "Issue Tree", issue_tree_loc, issue_tree_uploaded)
        _assert_submission(marketing_pitch, "Marketing Pitch", None, '')
        _assert_submission(budget, "Budget", None, '')