示例#1
0
 def test_mixin(self):
     create_fixtures(self)
     form = DummyModelForm()
     result = form.country_crowdsourced_values()
     self.assertEqual(
         result,
         '["Germany", "Singapore"]',
         msg=
         ('Should add ``fieldname_crowdsourced_values`` methods to the form'
          " and these methods should return all values for that fields's"
          " item type"))
 def test_mixin(self):
     create_fixtures(self)
     form = DummyModelForm()
     result = form.country_crowdsourced_values()
     self.assertEqual(
         result,
         '["Germany", "Singapore"]',
         msg=(
             "Should add ``fieldname_crowdsourced_values`` methods to the form"
             " and these methods should return all values for that fields's"
             " item type"
         ),
     )
    def test_action(self):
        create_fixtures(self)
        user_generated_items = CrowdsourcedItem.objects.filter(
            is_user_generated=True)
        self.assertEqual(user_generated_items.count(), 3, msg=(
            'We assume that our fixtures have two user generated items'))
        queryset = CrowdsourcedItem.objects.filter(pk__in=[
            user_generated_items[0].pk, user_generated_items[1].pk])

        approve_items(None, None, queryset)
        user_generated_items = CrowdsourcedItem.objects.filter(
            is_user_generated=True)
        self.assertEqual(user_generated_items.count(), 1, msg=(
            'Should set `is_user_generated` to `False` for all selected'
            ' items'))
示例#4
0
    def test_action(self):
        create_fixtures(self)
        user_generated_items = CrowdsourcedItem.objects.filter(
            is_user_generated=True)
        self.assertEqual(
            user_generated_items.count(),
            3,
            msg=('We assume that our fixtures have two user generated items'))
        queryset = CrowdsourcedItem.objects.filter(
            pk__in=[user_generated_items[0].pk, user_generated_items[1].pk])

        approve_items(None, None, queryset)
        user_generated_items = CrowdsourcedItem.objects.filter(
            is_user_generated=True)
        self.assertEqual(
            user_generated_items.count(),
            1,
            msg=('Should set `is_user_generated` to `False` for all selected'
                 ' items'))
 def test_initial_value(self):
     create_fixtures(self)
     self.dummy.country = "GERMANY"
     self.dummy.save()
     form = DummyModelForm(instance=self.dummy)
     self.assertEqual(form.initial["country"], self.item.value)
示例#6
0
 def test_initial_value(self):
     create_fixtures(self)
     self.dummy.country = 'GERMANY'
     self.dummy.save()
     form = DummyModelForm(instance=self.dummy)
     self.assertEqual(form.initial['country'], self.item.value)