Esempio n. 1
0
    def test_deserialize_value(self):
        """Testing ConditionValueMultipleModelField.deserialize_value"""
        field = ConditionValueMultipleModelField(queryset=Site.objects.all())

        site = Site.objects.get_current()
        result = field.deserialize_value([site.pk])

        self.assertEqual(len(result), 1)
        self.assertEqual(result[0], site)
Esempio n. 2
0
    def test_deserialize_value(self):
        """Testing ConditionValueMultipleModelField.deserialize_value"""
        field = ConditionValueMultipleModelField(queryset=Site.objects.all())

        site = Site.objects.get_current()
        result = field.deserialize_value([site.pk])

        self.assertEqual(len(result), 1)
        self.assertEqual(result[0], site)
Esempio n. 3
0
    def test_init_with_queryset(self):
        """Testing ConditionValueMultipleModelField initialization with
        QuerySet
        """
        field = ConditionValueMultipleModelField(queryset=Site.objects.all())

        self.assertTrue(isinstance(field.field.queryset, QuerySet))
Esempio n. 4
0
    def default_value_field(self, **kwargs):
        """Return the default value field for this choice.

        This will call out to :py:meth:`get_queryset` before returning the
        field, allowing subclasses to simply set :py:attr:`queryset` or to
        perform more dynamic queries before constructing the form field.

        Args:
            **kwargs (dict):
                Extra keyword arguments for this function, for future
                expansion.

        Returns:
            djblets.conditions.values.ConditionValueMultipleModelField:
            The form field for the value.
        """
        return ConditionValueMultipleModelField(queryset=self.get_queryset)
Esempio n. 5
0
    def test_serialize_value(self):
        """Testing ConditionValueMultipleModelField.serialize_value"""
        field = ConditionValueMultipleModelField(queryset=Site.objects.all())

        site = Site.objects.get_current()
        self.assertEqual(field.serialize_value([site]), [site.pk])
Esempio n. 6
0
    def test_serialize_value(self):
        """Testing ConditionValueMultipleModelField.serialize_value"""
        field = ConditionValueMultipleModelField(queryset=Site.objects.all())

        site = Site.objects.get_current()
        self.assertEqual(field.serialize_value([site]), [site.pk])