def setUp(self):
        self.request_factory = RequestFactory()

        # Pre-populate a user with a project and a ticket
        self.user = test_helpers.create_bob_user()
        self.teal_project = test_helpers.create_teal_project(self.user)
        self.ticket = test_helpers.create_project_ticket(
            self.teal_project, self.user)
示例#2
0
    def test_get_projects_list_returns_projects_user_has_assigned_tickets_for_first_when_logged_in(
            self):
        teal_project = test_helpers.create_teal_project(self.user)
        rainbow_project = test_helpers.create_rainbow_project(self.user)
        user_assigned_ticket = test_helpers.create_project_ticket(
            teal_project, self.user, [self.user])
        request = self.request_factory.get('/projects')
        request.user = self.user

        res = project_list_view(request)

        self.assertEqual(len(res.context_data['projects']), 2)
        self.assertEqual(res.context_data['projects'][0].pk,
                         user_assigned_ticket.project_id)
示例#3
0
    def test_get_projects_list_returns_projects_in_alphabetical_order_when_user_not_logged_in(
            self):
        teal_project = test_helpers.create_teal_project(self.user)
        rainbow_project = test_helpers.create_rainbow_project(self.user)
        user_assigned_ticket = test_helpers.create_project_ticket(
            teal_project, self.user, [self.user])
        request = self.request_factory.get('/projects')
        request.user = AnonymousUser()

        res = project_list_view(request)

        self.assertEqual(len(res.context_data['projects']), 2)
        self.assertEqual(res.context_data['projects'][0].pk,
                         rainbow_project.pk)
    def setUp(self):
        self.request_factory = RequestFactory()

        # Pre-populate a user with a project
        self.user = test_helpers.create_bob_user()
        self.teal_project = test_helpers.create_teal_project(self.user)

        # Data to use for the create request
        self.new_title = 'A new title'
        self.new_description = 'A new description'
        self.form_data = {
            'title': self.new_title,
            'description': self.new_description,
            'assignees': [self.user.id]
        }
    def test_my_ticket_view_returns_users_tickets(self):
        bob_user = test_helpers.create_bob_user()
        reginald_user = test_helpers.create_reginald_user()
        teal_project = test_helpers.create_teal_project(bob_user)
        bob_assigned_ticket = test_helpers.create_project_ticket(
            teal_project, bob_user, [bob_user, reginald_user])
        non_bob_assigned_ticket = test_helpers.create_project_ticket(
            teal_project, reginald_user, [reginald_user])
        request = self.request_factory.get('/')
        request.user = bob_user

        res = my_tickets_view(request)

        self.assertEqual(len(res.context_data['tickets']), 1)
        self.assertEqual(res.context_data['tickets'][0].id,
                         bob_assigned_ticket.id)