예제 #1
0
    def test_5_pushes_no_fallback(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        pushes_data = view.annotated_pushes(self.locale,
                                            self.av,
                                            actions=actions,
                                            flags=flags,
                                            count=1)
        pushes = pushes_data['pushes']
        # there are more pushes than this but it gets limited
        # by `count` instead because there is no fallback
        self.assertEqual(len(pushes), 1)
        self.assertEqual(pushes_data['pushes_left'], 4)

        # equally...
        # the `count` is what determines how many we get back
        pushes_data = view.annotated_pushes(self.locale,
                                            self.av,
                                            actions=actions,
                                            flags=flags,
                                            count=3)
        pushes = pushes_data['pushes']
        self.assertEqual(len(pushes), 3)
        self.assertEqual(pushes_data['pushes_left'], 2)
예제 #2
0
    def test_5_pushes_1st_pending(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # make a pending signoff on the 1st push
        signoff = Signoff.objects.create(
            push=self.pushes[0],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.PENDING,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes_data = view.annotated_pushes(self.locale,
                                            self.av,
                                            actions=actions,
                                            flags=flags,
                                            fallback=None,
                                            count=1)
        pushes = pushes_data['pushes']
        self.assertEqual(len(pushes), 5)
        self.assertEqual(pushes_data['pushes_left'], 0)

        # the last (aka. first) one should have a signoff with an
        # action on that is rejected
        self.assertEqual(pushes[-1]['signoffs'][0]['action'].flag,
                         Action.PENDING)
예제 #3
0
    def test_signoff_annotated_pushes(self):
        view = SignoffView()
        locale = Locale.objects.get(code='de')

        real_av, flags = (api.flags4appversions(
            [self.av],
            locales=[locale.id]).get(self.av, {}).get(locale.code, [None, {}]))
        actions = list(
            Action.objects.filter(id__in=flags.values()).select_related(
                'signoff__push__repository', 'author'))
        fallback, = actions
        assert fallback.flag == Action.ACCEPTED, fallback.flag
        pushes_data = view.annotated_pushes(
            locale,
            self.av,
            actions=actions,
            flags=flags,
            fallback=fallback,
        )
        suggested_signoff = pushes_data['suggested_signoff']
        self.assertIsNone(suggested_signoff)
        pushes = pushes_data['pushes']
        changesets = [c for p in pushes for c in p['changes']]
        revisions = [x.revision for x in changesets]
        # only `de` changes in the right order
        self.assertListEqual(revisions, ['l10n de 0003', 'l10n de 0002'])
예제 #4
0
    def test_5_pushes_no_fallback(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            count=1
        )
        pushes = pushes_data['pushes']
        # there are more pushes than this but it gets limited
        # by `count` instead because there is no fallback
        eq_(len(pushes), 1)
        eq_(pushes_data['pushes_left'], 4)

        # equally...
        # the `count` is what determines how many we get back
        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            count=3
        )
        pushes = pushes_data['pushes']
        eq_(len(pushes), 3)
        eq_(pushes_data['pushes_left'], 2)
예제 #5
0
    def test_signoff_annotated_pushes(self):
        view = SignoffView()
        locale = Locale.objects.get(code='de')

        real_av, flags = (api.flags4appversions(
            locales={'id': locale.id},
            appversions={'id': self.av.id})
                          .get(self.av, {})
                          .get(locale.code, [None, {}]))
        actions = list(Action.objects.filter(id__in=flags.values())
                       .select_related('signoff__push__repository', 'author'))
        fallback, = actions
        assert fallback.flag == Action.ACCEPTED, fallback.flag
        pushes, suggested_signoff = view.annotated_pushes(
            actions,
            flags,
            fallback,
            locale,
            self.av
        )
        eq_(suggested_signoff, None)
        changesets = [c for p in pushes for c in p['changes']]
        revisions = [x.revision for x in changesets]
        # only `de` changes in the right order
        eq_(revisions, [u'l10n de 0003', u'l10n de 0002'])
예제 #6
0
    def test_5_pushes_2nd_accepted(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # Let's make an accepted signoff on the 2nd push
        push = self.pushes[1]
        signoff = Signoff.objects.create(
            push=push,
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.ACCEPTED,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes, suggested_signoff = view.annotated_pushes(
            actions,
            flags,
            None,  # notice, no fallback
            self.locale,
            self.av,
            count=1)
        eq_(len(pushes), 4)
        # the last (aka. first) one should have a signoff with an
        # action on that is accepting
        eq_(pushes[-1]['signoffs'][0]['action'].flag, Action.ACCEPTED)
예제 #7
0
    def test_5_pushes_1st_pending(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # make a pending signoff on the 1st push
        signoff = Signoff.objects.create(
            push=self.pushes[0],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.PENDING,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes, suggested_signoff = view.annotated_pushes(
            actions,
            flags,
            None,  # notice, no fallback
            self.locale,
            self.av,
            count=1)
        eq_(len(pushes), 5)

        # the last (aka. first) one should have a signoff with an
        # action on that is rejected
        eq_(pushes[-1]['signoffs'][0]['action'].flag, Action.PENDING)
예제 #8
0
    def test_5_pushes_2nd_accepted(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # Let's make an accepted signoff on the 2nd push
        push = self.pushes[1]
        signoff = Signoff.objects.create(
            push=push,
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.ACCEPTED,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes, suggested_signoff = view.annotated_pushes(
            actions,
            flags,
            None,  # notice, no fallback
            self.locale,
            self.av,
            count=1
        )
        eq_(len(pushes), 4)
        # the last (aka. first) one should have a signoff with an
        # action on that is accepting
        eq_(pushes[-1]['signoffs'][0]['action'].flag, Action.ACCEPTED)
예제 #9
0
    def test_5_pushes_no_fallback(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        pushes, suggested_signoff = view.annotated_pushes(
            actions,
            flags,
            None,
            self.locale,
            self.av,
            count=1
        )
        # there are more pushes than this but it gets limited
        # by `count` instead because there is no fallback
        eq_(len(pushes), 1)

        # equally...
        # the `count` is what determines how many we get back
        pushes, suggested_signoff = view.annotated_pushes(
            actions,
            flags,
            None,
            self.locale,
            self.av,
            count=3
        )
        eq_(len(pushes), 3)
예제 #10
0
파일: test_signoff.py 프로젝트: Pike/elmo
    def test_5_pushes_1st_pending(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # make a pending signoff on the 1st push
        signoff = Signoff.objects.create(
            push=self.pushes[0],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.PENDING,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            fallback=None,
            count=1
        )
        pushes = pushes_data['pushes']
        self.assertEqual(len(pushes), 5)
        self.assertEqual(pushes_data['pushes_left'], 0)

        # the last (aka. first) one should have a signoff with an
        # action on that is rejected
        self.assertEqual(
            pushes[-1]['signoffs'][0]['action'].flag,
            Action.PENDING)
예제 #11
0
파일: test_signoff.py 프로젝트: Pike/elmo
    def test_5_pushes_2nd_accepted(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # Let's make an accepted signoff on the 2nd push
        push = self.pushes[1]
        signoff = Signoff.objects.create(
            push=push,
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.ACCEPTED,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            count=1
        )
        pushes = pushes_data['pushes']
        self.assertEqual(len(pushes), 4)
        self.assertEqual(pushes_data['pushes_left'], 1)
        # the last (aka. first) one should have a signoff with an
        # action on that is accepting
        self.assertEqual(
            pushes[-1]['signoffs'][0]['action'].flag,
            Action.ACCEPTED)
예제 #12
0
파일: test_signoff.py 프로젝트: Pike/elmo
    def test_signoff_annotated_pushes(self):
        view = SignoffView()
        locale = Locale.objects.get(code='de')

        real_av, flags = (
            api.flags4appversions([self.av], locales=[locale.id])
            .get(self.av, {})
            .get(locale.code, [None, {}]))
        actions = list(Action.objects.filter(id__in=flags.values())
                       .select_related('signoff__push__repository', 'author'))
        fallback, = actions
        assert fallback.flag == Action.ACCEPTED, fallback.flag
        pushes_data = view.annotated_pushes(
            locale,
            self.av,
            actions=actions,
            flags=flags,
            fallback=fallback,
        )
        suggested_signoff = pushes_data['suggested_signoff']
        self.assertIsNone(suggested_signoff)
        pushes = pushes_data['pushes']
        changesets = [c for p in pushes for c in p['changes']]
        revisions = [x.revision for x in changesets]
        # only `de` changes in the right order
        self.assertListEqual(revisions, ['l10n de 0003', 'l10n de 0002'])
예제 #13
0
    def test_5_pushes_2nd_accepted(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # Let's make an accepted signoff on the 2nd push
        push = self.pushes[1]
        signoff = Signoff.objects.create(
            push=push,
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.ACCEPTED,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes_data = view.annotated_pushes(self.locale,
                                            self.av,
                                            actions=actions,
                                            flags=flags,
                                            count=1)
        pushes = pushes_data['pushes']
        self.assertEqual(len(pushes), 4)
        self.assertEqual(pushes_data['pushes_left'], 1)
        # the last (aka. first) one should have a signoff with an
        # action on that is accepting
        self.assertEqual(pushes[-1]['signoffs'][0]['action'].flag,
                         Action.ACCEPTED)
예제 #14
0
    def test_5_pushes_1st_pending(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # make a pending signoff on the 1st push
        signoff = Signoff.objects.create(
            push=self.pushes[0],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.PENDING,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes, suggested_signoff = view.annotated_pushes(
            actions,
            flags,
            None,  # notice, no fallback
            self.locale,
            self.av,
            count=1
        )
        eq_(len(pushes), 5)

        # the last (aka. first) one should have a signoff with an
        # action on that is rejected
        eq_(pushes[-1]['signoffs'][0]['action'].flag, Action.PENDING)
예제 #15
0
    def test_5_pushes_2nd_accepted_3rd_rejected_4th_pending(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # make an accepted signoff on the 2nd push
        signoff = Signoff.objects.create(
            push=self.pushes[1],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.ACCEPTED,
            author=self.peter,
        )

        # make a rejected signoff on the 3rd push
        signoff = Signoff.objects.create(
            push=self.pushes[2],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.REJECTED,
            author=self.peter,
        )

        # make a pending signoff on the 4th push
        signoff = Signoff.objects.create(
            push=self.pushes[3],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.PENDING,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            count=1
        )
        pushes = pushes_data['pushes']
        eq_(len(pushes), 4)
        eq_(pushes_data['pushes_left'], 1)
        # the last (aka. first) one should have a signoff with an
        # action on that is accepting
        eq_(pushes[-1]['signoffs'][0]['action'].flag, Action.ACCEPTED)
예제 #16
0
    def test_5_pushes_2nd_accepted_3rd_rejected_4th_pending(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        # make an accepted signoff on the 2nd push
        signoff = Signoff.objects.create(
            push=self.pushes[1],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.ACCEPTED,
            author=self.peter,
        )

        # make a rejected signoff on the 3rd push
        signoff = Signoff.objects.create(
            push=self.pushes[2],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.REJECTED,
            author=self.peter,
        )

        # make a pending signoff on the 4th push
        signoff = Signoff.objects.create(
            push=self.pushes[3],
            appversion=self.av,
            author=self.axel,
            locale=self.locale,
        )
        Action.objects.create(
            signoff=signoff,
            flag=Action.PENDING,
            author=self.peter,
        )

        flags, actions = self._get_flags_and_actions()
        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            count=1
        )
        pushes = pushes_data['pushes']
        eq_(len(pushes), 4)
        eq_(pushes_data['pushes_left'], 1)
        # the last (aka. first) one should have a signoff with an
        # action on that is accepting
        eq_(pushes[-1]['signoffs'][0]['action'].flag, Action.ACCEPTED)
예제 #17
0
    def test_next_push_date(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            fallback=None,
            count=2
        )
        pushes = pushes_data['pushes']
        # there are more pushes than this but it gets limited
        # by `count` instead because there is no fallback
        eq_(len(pushes), 2)
        # because there are 5 in this fixture, we can expect...
        eq_(pushes_data['pushes_left'], 3)

        p1, p2, p3, p4, p5 = Push.objects.all().order_by('push_date')
        eq_(p4.push_date, pushes_data['next_push_date'])

        # get the next two
        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            fallback=None,
            count=2,
            next_push_date=pushes_data['next_push_date']
        )
        pushes = pushes_data['pushes']
        eq_(len(pushes), 2)
        eq_(pushes_data['pushes_left'], 1)

        eq_(p2.push_date, pushes_data['next_push_date'])

        # and get the last remaining one
        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            fallback=None,
            count=2,
            next_push_date=pushes_data['next_push_date']
        )
        pushes = pushes_data['pushes']
        eq_(len(pushes), 1)
        eq_(pushes_data['pushes_left'], 0)

        eq_(p1.push_date, pushes_data['next_push_date'])
예제 #18
0
    def test_next_push_date(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            fallback=None,
            count=2
        )
        pushes = pushes_data['pushes']
        # there are more pushes than this but it gets limited
        # by `count` instead because there is no fallback
        eq_(len(pushes), 2)
        # because there are 5 in this fixture, we can expect...
        eq_(pushes_data['pushes_left'], 3)

        p1, p2, p3, p4, p5 = Push.objects.all().order_by('push_date')
        eq_(p4.push_date, pushes_data['next_push_date'])

        # get the next two
        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            fallback=None,
            count=2,
            next_push_date=pushes_data['next_push_date']
        )
        pushes = pushes_data['pushes']
        eq_(len(pushes), 2)
        eq_(pushes_data['pushes_left'], 1)

        eq_(p2.push_date, pushes_data['next_push_date'])

        # and get the last remaining one
        pushes_data = view.annotated_pushes(
            self.locale,
            self.av,
            actions=actions,
            flags=flags,
            fallback=None,
            count=2,
            next_push_date=pushes_data['next_push_date']
        )
        pushes = pushes_data['pushes']
        eq_(len(pushes), 1)
        eq_(pushes_data['pushes_left'], 0)

        eq_(p1.push_date, pushes_data['next_push_date'])
예제 #19
0
    def test_signoff_annotated_pushes(self):
        view = SignoffView()
        locale = Locale.objects.get(code='de')

        real_av, flags = (api.flags4appversions(locales={
            'id': locale.id
        },
                                                appversions={
                                                    'id': self.av.id
                                                }).get(self.av, {}).get(
                                                    locale.code, [None, {}]))
        actions = list(
            Action.objects.filter(id__in=flags.values()).select_related(
                'signoff__push__repository', 'author'))
        fallback, = actions
        assert fallback.flag == Action.ACCEPTED, fallback.flag
        pushes, suggested_signoff = view.annotated_pushes(
            actions, flags, fallback, locale, self.av)
        eq_(suggested_signoff, None)
        changesets = [c for p in pushes for c in p['changes']]
        revisions = [x.revision for x in changesets]
        # only `de` changes in the right order
        eq_(revisions, [u'l10n de 0003', u'l10n de 0002'])
예제 #20
0
    def test_5_pushes_no_fallback(self):
        view = SignoffView()
        flags, actions = self._get_flags_and_actions()

        pushes, suggested_signoff = view.annotated_pushes(actions,
                                                          flags,
                                                          None,
                                                          self.locale,
                                                          self.av,
                                                          count=1)
        # there are more pushes than this but it gets limited
        # by `count` instead because there is no fallback
        eq_(len(pushes), 1)

        # equally...
        # the `count` is what determines how many we get back
        pushes, suggested_signoff = view.annotated_pushes(actions,
                                                          flags,
                                                          None,
                                                          self.locale,
                                                          self.av,
                                                          count=3)
        eq_(len(pushes), 3)