Esempio n. 1
0
    def test_patch_dependencies_out_of_order(self):
        series = utils.create_series()
        series_patch_3 = utils.create_series_patch(series=series, number=3)
        series_patch_2 = utils.create_series_patch(series=series, number=2)

        # This should only raise the CATEGORY_PATCH_CREATED event for
        # both patches as they are both missing dependencies
        for series_patch in [series_patch_2, series_patch_3]:
            events = _get_events(patch=series_patch.patch)
            self.assertEqual(events.count(), 1)
            self.assertEqual(events[0].category, Event.CATEGORY_PATCH_CREATED)
            self.assertEventFields(events[0])

        series_patch_1 = utils.create_series_patch(series=series, number=1)

        # We should now see the CATEGORY_PATCH_COMPLETED event for all patches
        # as the dependencies for all have been met
        for series_patch in [series_patch_1, series_patch_2, series_patch_3]:
            events = _get_events(patch=series_patch.patch)
            self.assertEqual(events.count(), 2)
            self.assertEqual(events[0].category, Event.CATEGORY_PATCH_CREATED)
            self.assertEqual(events[1].category,
                             Event.CATEGORY_PATCH_COMPLETED)
            self.assertEventFields(events[0])
            self.assertEventFields(events[1])
Esempio n. 2
0
    def test_patch_dependencies_out_of_order(self):
        series = utils.create_series()
        series_patch_3 = utils.create_series_patch(series=series, number=3)
        series_patch_2 = utils.create_series_patch(series=series, number=2)

        # This should only raise the CATEGORY_PATCH_CREATED event for
        # both patches as they are both missing dependencies
        for series_patch in [series_patch_2, series_patch_3]:
            events = _get_events(patch=series_patch.patch)
            self.assertEqual(events.count(), 1)
            self.assertEqual(events[0].category, Event.CATEGORY_PATCH_CREATED)
            self.assertEventFields(events[0])

        series_patch_1 = utils.create_series_patch(series=series, number=1)

        # We should now see the CATEGORY_PATCH_COMPLETED event for all patches
        # as the dependencies for all have been met
        for series_patch in [series_patch_1, series_patch_2, series_patch_3]:
            events = _get_events(patch=series_patch.patch)
            self.assertEqual(events.count(), 2)
            self.assertEqual(events[0].category, Event.CATEGORY_PATCH_CREATED)
            self.assertEqual(events[1].category,
                             Event.CATEGORY_PATCH_COMPLETED)
            self.assertEventFields(events[0])
            self.assertEventFields(events[1])
Esempio n. 3
0
    def test_patch_with_dependencies(self):
        patch_a = create_series_patch()
        patch_b = create_series_patch(series=patch_a.series)

        response = self.client.get(
            '%s?series=*' % reverse('patch-mbox', args=[patch_b.patch.id]))

        self.assertContains(response, patch_a.patch.content)
        self.assertContains(response, patch_b.patch.content)
Esempio n. 4
0
    def test_patch_dependencies_missing(self):
        series_patch = utils.create_series_patch(number=2)

        # This should only raise the CATEGORY_PATCH_CREATED event as
        # there is a missing dependency (patch 1)
        events = _get_events(patch=series_patch.patch)
        self.assertEqual(events.count(), 1)
        self.assertEqual(events[0].category, Event.CATEGORY_PATCH_CREATED)
        self.assertEventFields(events[0])
Esempio n. 5
0
    def test_patch_dependencies_missing(self):
        series_patch = utils.create_series_patch(number=2)

        # This should only raise the CATEGORY_PATCH_CREATED event as
        # there is a missing dependency (patch 1)
        events = _get_events(patch=series_patch.patch)
        self.assertEqual(events.count(), 1)
        self.assertEqual(events[0].category, Event.CATEGORY_PATCH_CREATED)
        self.assertEventFields(events[0])
Esempio n. 6
0
    def test_list(self):
        """Validate we can list series."""
        resp = self.client.get(self.api_url())
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(0, len(resp.data))

        project_obj = create_project(linkname='myproject')
        person_obj = create_person(email='*****@*****.**')
        cover_obj = create_cover()
        series_obj = create_series(project=project_obj, submitter=person_obj)
        series_obj.add_cover_letter(cover_obj)
        create_series_patch(series=series_obj)

        # anonymous users
        resp = self.client.get(self.api_url())
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(1, len(resp.data))
        series_rsp = resp.data[0]
        self.assertSerialized(series_obj, series_rsp)

        # authenticated user
        user = create_user()
        self.client.force_authenticate(user=user)
        resp = self.client.get(self.api_url())
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(1, len(resp.data))
        series_rsp = resp.data[0]
        self.assertSerialized(series_obj, series_rsp)

        # test filtering by project
        resp = self.client.get(self.api_url(), {'project': 'myproject'})
        self.assertEqual([series_obj.id], [x['id'] for x in resp.data])
        resp = self.client.get(self.api_url(), {'project': 'invalidproject'})
        self.assertEqual(0, len(resp.data))

        # test filtering by owner, both ID and email
        resp = self.client.get(self.api_url(), {'submitter': person_obj.id})
        self.assertEqual([series_obj.id], [x['id'] for x in resp.data])
        resp = self.client.get(self.api_url(),
                               {'submitter': '*****@*****.**'})
        self.assertEqual([series_obj.id], [x['id'] for x in resp.data])
        resp = self.client.get(self.api_url(),
                               {'submitter': '*****@*****.**'})
        self.assertEqual(0, len(resp.data))
Esempio n. 7
0
    def test_patch_dependencies_present_series(self):
        """Patch dependencies already exist."""
        series_patch = utils.create_series_patch()

        # This should raise both the CATEGORY_PATCH_CREATED and
        # CATEGORY_PATCH_COMPLETED events
        events = _get_events(patch=series_patch.patch)
        self.assertEqual(events.count(), 2)
        self.assertEqual(events[0].category, Event.CATEGORY_PATCH_CREATED)
        self.assertEqual(events[0].project, series_patch.patch.project)
        self.assertEqual(events[1].category, Event.CATEGORY_PATCH_COMPLETED)
        self.assertEqual(events[1].project, series_patch.patch.project)
        self.assertEventFields(events[0])
        self.assertEventFields(events[1])
Esempio n. 8
0
    def test_patch_dependencies_present_series(self):
        """Patch dependencies already exist."""
        series_patch = utils.create_series_patch()

        # This should raise both the CATEGORY_PATCH_CREATED and
        # CATEGORY_PATCH_COMPLETED events
        events = _get_events(patch=series_patch.patch)
        self.assertEqual(events.count(), 2)
        self.assertEqual(events[0].category, Event.CATEGORY_PATCH_CREATED)
        self.assertEqual(events[0].project, series_patch.patch.project)
        self.assertEqual(events[1].category, Event.CATEGORY_PATCH_COMPLETED)
        self.assertEqual(events[1].project, series_patch.patch.project)
        self.assertEventFields(events[0])
        self.assertEventFields(events[1])