Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
fix: migrations test added.
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairshakoorarbisoft committed Sep 25, 2023
1 parent f977082 commit e4c7674
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions analytics_data_api/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import datetime
from io import StringIO

from django.contrib.auth.models import User
from django.core.management import CommandError, call_command
from django.test import TestCase
from django.test.utils import override_settings
from django_dynamic_fixture import G
from rest_framework.authtoken.models import Token

Expand Down Expand Up @@ -121,6 +123,30 @@ def test_general_range(self):
])


class MigrationTests(TestCase):
"""
Tests for migrations.
"""

@override_settings(MIGRATION_MODULES={})
def test_migrations_are_in_sync(self):
"""
Tests that the migration files are in sync with the models.
If this fails, you needs to run the Django command makemigrations.
The test is set up to override MIGRATION_MODULES to ensure migrations are
enabled for purposes of this test regardless of the overall test settings.
TODO: Find a general way of handling the case where if we're trying to
make a migrationless release that'll require a separate migration
release afterwards, this test doesn't fail.
"""
out = StringIO()
call_command("makemigrations", dry_run=True, verbosity=3, stdout=out)
output = out.getvalue()
assert 'No changes detected' in output


def set_databases(cls):
"""
This is to be used as a class decorator to set the databases
Expand Down
2 changes: 1 addition & 1 deletion analytics_data_api/v0/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Meta(BaseCourseModel.Meta):

module_id = models.CharField(db_index=True, max_length=255)
part_id = models.CharField(db_index=True, max_length=255)
correct = models.BooleanField(null=True)
correct = models.BooleanField(default=None, null=True)
value_id = models.CharField(db_index=True, max_length=255, null=True)
answer_value = models.TextField(null=True, db_column='answer_value_text')
variant = models.IntegerField(null=True)
Expand Down

0 comments on commit e4c7674

Please sign in to comment.