Skip to content

Commit

Permalink
Merge 10570c2 into ed549f4
Browse files Browse the repository at this point in the history
  • Loading branch information
bameda committed Feb 11, 2016
2 parents ed549f4 + 10570c2 commit 420ae50
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 21 deletions.
55 changes: 42 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
language: python

python:
- "2.7"
- "3.5"
- "3.4"
- "3.3"
- "2.7"

env:
- DJANGO="django==1.9.2"
- DJANGO="django==1.8.9"
- DJANGO="django==1.7.10"
- DJANGO="django==1.6.11"
- DJANGO="django==1.5.12"
- DJANGO="django==1.4.22"

matrix:
exclude:
- python: "3.5"
env: DJANGO="django==1.7.10"
- python: "3.5"
env: DJANGO="django==1.6.11"
- python: "3.5"
env: DJANGO="django==1.5.12"
- python: "3.5"
env: DJANGO="django==1.4.22"

- python: "3.4"
env: DJANGO="django==1.4.22"

- python: "3.3"
env: DJANGO="django==1.9.2"
- python: "3.3"
env: DJANGO="django==1.4.22"

install:
- pip install -e . --use-mirrors
- pip install nose . --use-mirrors
- pip install django-nose . --use-mirrors
- pip install pillow . --use-mirrors
- pip install coveralls --use-mirrors
- travis_retry pip install $DJANGO
- travis_retry pip install six
- travis_retry pip install sampledata
- travis_retry pip install nose
- travis_retry pip install django-nose
- travis_retry pip install pillow
- travis_retry pip install coveralls

script:
- coverage run --source=sampledatahelper setup.py test
notifications:
email:
recipients:
- jespinog@gmail.com
on_success: change
on_failure: change

after_success:
- coveralls
- travis_retry coveralls
14 changes: 14 additions & 0 deletions sampledatahelper/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-


# get model
get_model = None
try:
# django < 1.9
from django.db.models import loading
get_model = loading.get_model
except ImportError:
# django >= 1.9
from django.apps import apps
get_model = apps.get_model

2 changes: 1 addition & 1 deletion sampledatahelper/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from django.conf import settings
from django.core.files.base import ContentFile
from django.core.files.images import ImageFile
from django.db.models.loading import get_model

from sampledata.helper import SampleData
from sampledata.exceptions import NotChoicesFound, ParameterError

from sampledatahelper.compat import get_model

class SampleDataHelper(SampleData):
def __init__(self, seed=None):
Expand Down
2 changes: 1 addition & 1 deletion sampledatahelper/management/commands/sampledatafiller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.core.management.base import BaseCommand
from django.db.models.loading import get_model
from django.conf import settings

from sampledatahelper.compat import get_model
from sampledatahelper.model_helper import ModelDataHelper

class Command(BaseCommand):
Expand Down
13 changes: 10 additions & 3 deletions tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,25 @@ class TestModel(models.Model):
ip = models.GenericIPAddressField()
generic_ip = models.GenericIPAddressField()

foreing_key = models.ForeignKey('tests.TestRelatedModel', related_name="test_related_1")
one_to_one = models.OneToOneField(TestRelatedModel, related_name="test_related_2")
many_to_many = models.ManyToManyField(TestRelatedModel, related_name="test_related_3")
foreing_key = models.ForeignKey('tests.TestRelatedModel',
related_name="test_related_1",
on_delete=models.CASCADE)
one_to_one = models.OneToOneField(TestRelatedModel,
related_name="test_related_2",
on_delete=models.CASCADE)
many_to_many = models.ManyToManyField(TestRelatedModel,
related_name="test_related_3")

# With choices
integer_choices = models.IntegerField(choices=INTEGER_CHOICES)
char_choices = models.CharField(max_length=30, choices=CHAR_CHOICES)
foreing_key_choices = models.ForeignKey('tests.TestRelatedModel',
related_name="test_related_4",
on_delete=models.CASCADE,
limit_choices_to={'id__gt': 0})
one_to_one_key_choices = models.OneToOneField('tests.TestRelatedModel',
related_name="test_related_5",
on_delete=models.CASCADE,
limit_choices_to={'id__gt': 0})

class Meta:
Expand Down
8 changes: 5 additions & 3 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
from sampledata.mixins import image_mixin
from sampledata.exceptions import ParameterError, NotChoicesFound

from . import models

if django.VERSION >= (1, 7):
django.setup()
call_command('syncdb', interactive=False)
call_command('migrate', run_syncdb=True, interactive=False)
else:
call_command('syncdb', interactive=False)

from . import models


class TestNumberHelpers(unittest.TestCase):
Expand Down

0 comments on commit 420ae50

Please sign in to comment.