Ejemplo n.º 1
0
    def _create_events(self):
        """Create sample events.

        This one's a bit weird. While we could generate event models ourselves,
        it seems wiser to test the event machinery as many times as possible.
        As a result, we actually create a load of *other* objects, which will
        raise signals and trigger the remainder.
        """
        # series-created
        series = create_series()
        # patch-created, patch-completed, series-completed
        patch = create_patch(series=series)
        # cover-created
        create_cover(series=series)
        # check-created
        create_check(patch=patch)
        # patch-delegated, patch-state-changed
        actor = create_maintainer(project=patch.project)
        user = create_maintainer(project=patch.project)
        state = create_state()
        patch.delegate = user
        patch.state = state
        self.assertTrue(patch.is_editable(actor))
        patch.save()

        return Event.objects.all()
Ejemplo n.º 2
0
    def test_patch_with_checks(self):
        user = create_user()
        patch = create_patch()
        check_a = create_check(
            patch=patch, user=user, context='foo', state=Check.STATE_FAIL,
            date=(dt.utcnow() - timedelta(days=1)))
        create_check(
            patch=patch, user=user, context='foo', state=Check.STATE_SUCCESS)
        check_b = create_check(
            patch=patch, user=user, context='bar', state=Check.STATE_PENDING)
        requested_url = reverse(
            'patch-detail',
            kwargs={
                'project_id': patch.project.linkname,
                'msgid': patch.url_msgid,
            },
        )
        response = self.client.get(requested_url)

        # the response should contain checks
        self.assertContains(response, '<h2>Checks</h2>')

        # and it should only show the unique checks
        self.assertEqual(
            1, response.content.decode().count(
                f'<td>{check_a.user}/{check_a.context}</td>'
            ))
        self.assertEqual(
            1, response.content.decode().count(
                f'<td>{check_b.user}/{check_b.context}</td>'
            ))
Ejemplo n.º 3
0
 def test_check_created(self):
     check = utils.create_check()
     events = _get_events(created_check=check)
     self.assertEqual(events.count(), 1)
     self.assertEqual(events[0].category, Event.CATEGORY_CHECK_CREATED)
     self.assertEqual(events[0].project, check.patch.project)
     self.assertEventFields(events[0])
Ejemplo n.º 4
0
 def test_check_created(self):
     check = utils.create_check()
     events = _get_events(created_check=check)
     self.assertEqual(events.count(), 1)
     self.assertEqual(events[0].category, Event.CATEGORY_CHECK_CREATED)
     self.assertEqual(events[0].project, check.patch.project)
     self.assertEventFields(events[0])
Ejemplo n.º 5
0
 def test_patch_check_get(self):
     patch = self.create_single()
     check = utils.create_check(patch=patch)
     result = self.rpc.patch_check_get(patch.id)
     self.assertEqual(result['total'], 1)
     self.assertEqual(result['checks'][0]['id'], check.id)
     self.assertEqual(result['checks'][0]['patch_id'], patch.id)
Ejemplo n.º 6
0
 def test_patch_check_get(self):
     patch = self.create_single()
     check = utils.create_check(patch=patch)
     result = self.rpc.patch_check_get(patch.id)
     self.assertEqual(result['total'], 1)
     self.assertEqual(result['checks'][0]['id'], check.id)
     self.assertEqual(result['checks'][0]['patch_id'], patch.id)
Ejemplo n.º 7
0
    def _create_check(self, **kwargs):
        values = {
            'patch': self.patch,
            'user': self.user,
        }
        values.update(**kwargs)

        return create_check(**values)
Ejemplo n.º 8
0
 def _create_check(self):
     values = {
         'patch': self.patch,
         'user': self.user,
     }
     return create_check(**values)
Ejemplo n.º 9
0
 def _create_check(self):
     values = {
         'patch': self.patch,
         'user': self.user,
     }
     return create_check(**values)
Ejemplo n.º 10
0
 def _create_check(self, patch=None):
     values = {
         'patch': patch if patch else self.patch,
         'user': self.user,
     }
     return create_check(**values)
Ejemplo n.º 11
0
 def _create_check(self, patch=None):
     values = {
         'patch': patch if patch else self.patch,
         'user': self.user,
     }
     return create_check(**values)