Пример #1
0
    def test_actors_after_user_update(self):
        old_actors_timestamps = list(Actor.objects.all().values_list(
            'created_at', flat=True))

        noun = names.generator.get_test_name('new-new-name')

        data = linguistics_helpers.get_word_post_data(noun, prefix='name')
        data.update({
            'caption': 'new-caption',
            'rationale': 'new-rationale',
            'chronicle_on_accepted': 'chronicle-on-accepted-2',
            'place': self.place2.id
        })

        form = PlaceRenaming.UserForm(data)

        self.assertTrue(form.is_valid())
        self.bill.update(form)

        new_actors_timestamps = list(Actor.objects.all().values_list(
            'created_at', flat=True))

        self.assertFalse(
            set(old_actors_timestamps) & set(new_actors_timestamps))
        self.assertTrue(new_actors_timestamps)
Пример #2
0
    def test_update(self):
        VotePrototype.create(self.account2, self.bill, VOTE_TYPE.FOR)
        VotePrototype.create(self.account3, self.bill, VOTE_TYPE.AGAINST)
        VotePrototype.create(self.account4, self.bill, VOTE_TYPE.REFRAINED)
        self.bill.recalculate_votes()
        self.bill.approved_by_moderator = True
        self.bill.save()

        old_updated_at = self.bill.updated_at

        self.assertEqual(self.bill.votes_for, 2)
        self.assertEqual(self.bill.votes_against, 1)
        self.assertEqual(self.bill.votes_refrained, 1)
        self.assertEqual(Vote.objects.all().count(), 4)
        self.assertEqual(self.bill.caption, 'bill-1-caption')
        self.assertEqual(self.bill.rationale, 'bill-1-rationale')
        self.assertEqual(self.bill.approved_by_moderator, True)
        self.assertEqual(self.bill.data.base_name, u'new_name_1-нс,ед,им')
        self.assertEqual(self.bill.data.place_id, self.place1.id)
        self.assertEqual(Post.objects.all().count(), 1)

        new_name = names.generator.get_test_name('new-new-name')

        data = linguistics_helpers.get_word_post_data(new_name, prefix='name')
        data.update({'caption': 'new-caption',
                     'rationale': 'new-rationale',
                     'chronicle_on_accepted': 'chronicle-on-accepted-2',
                     'place': self.place2.id})

        form = PlaceRenaming.UserForm(data)

        self.assertTrue(form.is_valid())

        self.bill.update(form)

        self.bill = BillPrototype.get_by_id(self.bill.id)

        self.assertTrue(old_updated_at < self.bill.updated_at)
        self.assertTrue(self.bill.state.is_VOTING)
        self.assertEqual(self.bill.votes_for, 1)
        self.assertEqual(self.bill.votes_against, 0)
        self.assertEqual(self.bill.votes_refrained, 0)
        self.assertEqual(Vote.objects.all().count(), 1)
        self.assertEqual(self.bill.caption, 'new-caption')
        self.assertEqual(self.bill.rationale, 'new-rationale')
        self.assertEqual(self.bill.chronicle_on_accepted, 'chronicle-on-accepted-2')
        self.assertEqual(self.bill.approved_by_moderator, False)
        self.assertEqual(self.bill.data.base_name, u'new-new-name-нс,ед,им')
        self.assertEqual(self.bill.data.place_id, self.place2.id)
        self.assertEqual(Post.objects.all().count(), 2)
        self.assertEqual(Thread.objects.get(id=self.bill.forum_thread_id).caption, 'new-caption')