def test_user_form_validation__wrong_bill(self):
        bill_data = PlaceDescripton(place_id=self.place1.id, description='new description')
        bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted',)

        form = PlaceDescripton.ModeratorForm({'approved': True})
        self.assertTrue(form.is_valid())
        bill.update_by_moderator(form)
        self.assertTrue(bill.apply())

        form = self.bill.data.get_user_form_update(post={'caption': 'caption',
                                                         'rationale': 'rationale',
                                                         'chronicle_on_accepted': 'chronicle-on-accepted-3',
                                                         'declined_bill': bill.id})
        self.assertFalse(form.is_valid())
Пример #2
0
    def setUp(self):
        super(GetApplicableBillsTest, self).setUp()

        self.bill_data = PlaceDescripton(place_id=self.place1.id,
                                         description='description')
        self.bill_1 = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            'bill-1-rationale',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
        self.bill_2 = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            'bill-1-rationale',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')
        self.bill_3 = BillPrototype.create(
            self.account1,
            'bill-1-caption',
            'bill-1-rationale',
            self.bill_data,
            chronicle_on_accepted='chronicle-on-accepted')

        BillPrototype._model_class.objects.all().update(
            updated_at=datetime.datetime.now() -
            datetime.timedelta(seconds=bills_settings.BILL_LIVE_TIME),
            approved_by_moderator=True)

        self.bill_1.reload()
        self.bill_2.reload()
        self.bill_3.reload()
    def setUp(self):
        super(PlaceDescriptionTests, self).setUp()

        self.place = places_storage.all()[0]
        self.place.description = 'old description'
        self.place.save()

        self.place_2 = places_storage.all()[1]

        self.bill_data = PlaceDescripton(place_id=self.place.id, description='new description')
        self.bill = BillPrototype.create(self.account1, 'bill-1-caption', 'bill-1-rationale', self.bill_data, chronicle_on_accepted='chronicle-on-accepted')
    def test_has_meaning__duplicate_description(self):
        VotePrototype.create(self.account2, self.bill, False)
        VotePrototype.create(self.account3, self.bill, True)

        form = PlaceDescripton.ModeratorForm({'approved': True})
        self.assertTrue(form.is_valid())
        self.bill.update_by_moderator(form)

        self.place.description = 'new description'
        self.place.save()

        self.assertFalse(self.bill.has_meaning())
Пример #5
0
    def test_apply(self):
        VotePrototype.create(self.account2, self.bill, False)
        VotePrototype.create(self.account3, self.bill, True)

        form = PlaceDescripton.ModeratorForm({'approved': True})
        self.assertTrue(form.is_valid())
        self.bill.update_by_moderator(form)

        self.assertTrue(self.bill.apply())

        bill = BillPrototype.get_by_id(self.bill.id)
        self.assertTrue(bill.state.is_ACCEPTED)

        self.assertNotEqual(self.place.description, 'old description')
        self.assertEqual(self.place.description, 'new description')