Skip to content

Commit

Permalink
added tests for migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
darius BERNARD committed Nov 23, 2016
1 parent 4869b33 commit cdc44c2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import sys

if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testsettings")

from django.core.management import execute_from_command_line
Expand Down
14 changes: 14 additions & 0 deletions rest_models/tests/test_routers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import, print_function


from django.test import TestCase

from django.core.management import call_command


class TestMigrationRouter(TestCase):

def test_make_migration(self):
call_command('makemigrations', app_label='testapi', interactive=False, dry_run=True)
call_command('makemigrations', app_label='testapp', interactive=False, dry_run=True)
6 changes: 3 additions & 3 deletions testapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class Menu(models.Model):
name = models.CharField(max_length=135)
code = models.CharField(max_length=3)

def __str__(self):
def __str__(self): # pragma: no cover
return self.name


class Topping(models.Model):
name = models.CharField(max_length=125)
cost = models.FloatField()

def __str__(self):
def __str__(self): # pragma: no cover
return self.name


Expand All @@ -44,5 +44,5 @@ class Pizza(models.Model):
toppings = models.ManyToManyField(Topping, related_name='pizzas')
menu = models.ForeignKey(Menu, null=True, related_name='pizzas')

def __str__(self):
def __str__(self): # pragma: no cover
return self.name
10 changes: 9 additions & 1 deletion testapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@


from __future__ import unicode_literals, print_function, absolute_import

from django.conf import settings
from django.db import models


Expand All @@ -29,7 +31,7 @@ class Pizza(models.Model):
from_date = models.DateField(auto_now_add=True)
to_date = models.DateTimeField()

# creator is removed from hier but is in the serializer
# creator is removed from here but is in the serializer

# creator = models.ForeignKey(settings.AUTH_USER_MODEL)
toppings = models.ManyToManyField(Topping, related_name='pizzas')
Expand All @@ -40,3 +42,9 @@ class Pizza(models.Model):

class APIMeta:
db_name = 'api'


class Bookmark(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
pizza = models.ForeignKey(Pizza)
date = models.DateTimeField(auto_now_add=True)

0 comments on commit cdc44c2

Please sign in to comment.