Exemplo 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)
Exemplo 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)
Exemplo 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))
Exemplo 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)
Exemplo 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])
Exemplo 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])