def test_add_default_field_mapping_is_deprecated(self):
        class UnregisteredCustomishField(CustomishField):
            """Just to get deprecation warning when registered."""

        add_default_field_mapping(UnregisteredCustomishField, just(u"a"))
        with self.assertRaises(InvalidArgument):
            # Double-registering is an error, and registry is shared.
            register_field_strategy(UnregisteredCustomishField, just(u"a"))
Пример #2
0
    def test_add_default_field_mapping_is_deprecated(self):
        class UnregisteredCustomishField(CustomishField):
            """Just to get deprecation warning when registered."""

        add_default_field_mapping(UnregisteredCustomishField, just(u"a"))
        with self.assertRaises(InvalidArgument):
            # Double-registering is an error, and registry is shared.
            register_field_strategy(UnregisteredCustomishField, just(u"a"))
Пример #3
0
# obtain one at http://mozilla.org/MPL/2.0/.

# END HEADER

from __future__ import division, print_function, absolute_import

from hypothesis import given, assume
from hypothesis.errors import InvalidArgument
from hypothesis.strategies import just, lists
from hypothesis.extra.django import TestCase, TransactionTestCase
from tests.django.toystore.models import Store, Company, Customer, \
    ManyInts, SelfLoop, Customish, CustomishField, CouldBeCharming
from hypothesis.extra.django.models import models, \
    add_default_field_mapping

add_default_field_mapping(CustomishField, just(u'a'))


class TestGetsBasicModels(TestCase):

    @given(models(Company))
    def test_is_company(self, company):
        self.assertIsInstance(company, Company)
        self.assertIsNotNone(company.pk)

    @given(models(Store, company=models(Company)))
    def test_can_get_a_store(self, store):
        assert store.company.pk

    @given(lists(models(Company)))
    def test_can_get_multiple_models_with_unique_field(self, companies):
Пример #4
0
from hypothesis import HealthCheck, given, assume, settings
from hypothesis.errors import InvalidArgument, HypothesisException
from hypothesis.control import reject
from hypothesis.strategies import just, lists, binary
from hypothesis.extra.django import TestCase, TransactionTestCase
from hypothesis.internal.compat import text_type
from tests.django.toystore.models import Store, Company, Customer, \
    SelfLoop, Customish, ManyTimes, OddFields, ManyNumerics, \
    CustomishField, CouldBeCharming, CompanyExtension, CustomishDefault, \
    RestrictedFields, MandatoryComputed
from hypothesis.extra.django.models import models, default_value, \
    add_default_field_mapping
from hypothesis.internal.conjecture.data import ConjectureData

add_default_field_mapping(CustomishField, just(u'a'))


class TestGetsBasicModels(TestCase):
    @given(models(Company))
    def test_is_company(self, company):
        self.assertIsInstance(company, Company)
        self.assertIsNotNone(company.pk)

    @given(models(Store, company=models(Company)))
    def test_can_get_a_store(self, store):
        assert store.company.pk

    @given(lists(models(Company)))
    def test_can_get_multiple_models_with_unique_field(self, companies):
        assume(len(companies) > 1)
Пример #5
0
# obtain one at http://mozilla.org/MPL/2.0/.

# END HEADER

from __future__ import division, print_function, absolute_import, \
    unicode_literals

from hypothesis.errors import InvalidArgument
from hypothesis.extra.django import TestCase, TransactionTestCase
from hypothesis.extra.django.models import models, add_default_field_mapping
from hypothesis import given, assume
from toystore.models import Company, Customer, CouldBeCharming, Store, \
    SelfLoop, ManyInts, CustomishField, Customish
from hypothesis.strategies import lists, just

add_default_field_mapping(CustomishField, just("a"))


class TestGetsBasicModels(TestCase):
    @given(models(Company))
    def test_is_company(self, company):
        self.assertIsInstance(company, Company)
        self.assertIsNotNone(company.pk)

    @given(models(Store, company=models(Company)))
    def test_can_get_a_store(self, store):
        assert store.company.pk

    @given(lists(models(Company)))
    def test_can_get_multiple_models_with_unique_field(self, companies):
        assume(len(companies) > 1)
Пример #6
0
from django.db import transaction

from .models import Dog, DogPhoto, KeyPoints, Status

from hypothesis.extra.django.models import models
from hypothesis.extra.django.models import add_default_field_mapping
from hypothesis.strategies import text
from hypothesis.extra.datetime import datetimes
from hypothesis import given

from ckeditor_uploader.fields import RichTextUploadingField as RichTextField
from django_extensions.db import fields

import mock

add_default_field_mapping(RichTextField, text())
add_default_field_mapping(fields.AutoSlugField, text())
add_default_field_mapping(fields.CreationDateTimeField, datetimes())
add_default_field_mapping(fields.ModificationDateTimeField, datetimes())


class DogTests(TestCase):
    STATUS_TITLE = "test status"

    @staticmethod
    def get_dog(name, dob="2015-01-01", arrival="2025-01-01", status_arrival=False):
        test_status = Status(title="test status", body="test body", show_arrival_date=status_arrival)
        test_status.save()

        return Dog(
            name=name,
Пример #7
0
# obtain one at http://mozilla.org/MPL/2.0/.

# END HEADER

from __future__ import division, print_function, absolute_import, \
    unicode_literals

from hypothesis.errors import InvalidArgument
from hypothesis.extra.django import TestCase, TransactionTestCase
from hypothesis.extra.django.models import models, add_default_field_mapping
from hypothesis import given, assume
from toystore.models import Company, Customer, CouldBeCharming, Store, \
    SelfLoop, ManyInts, CustomishField, Customish
from hypothesis.strategies import lists, just

add_default_field_mapping(CustomishField, just("a"))


class TestGetsBasicModels(TestCase):
    @given(models(Company))
    def test_is_company(self, company):
        self.assertIsInstance(company, Company)
        self.assertIsNotNone(company.pk)

    @given(models(Store, company=models(Company)))
    def test_can_get_a_store(self, store):
        assert store.company.pk

    @given(lists(models(Company)))
    def test_can_get_multiple_models_with_unique_field(self, companies):
        assume(len(companies) > 1)