-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from adamalton/fix-migration-id-from-filename
Fix migration id from filename, add GitHub tests workflow
- Loading branch information
Showing
5 changed files
with
86 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Test | ||
on: [push] | ||
env: | ||
DJANGO_SETTINGS_MODULE: "testing.test_settings" | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
# This is the version of the action for setting up Python, not the Python version. | ||
uses: actions/setup-python@v5 | ||
with: | ||
# Semantic version range syntax or exact version of a Python version | ||
python-version: '3.11' | ||
- name: Install | ||
run: pip install -e . | ||
- name: Run tests | ||
run: >- | ||
django-admin test massmigration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Third party | ||
from django.test import TestCase | ||
|
||
# Mass Migration | ||
from massmigration.loader import ( | ||
is_valid_migration_id, | ||
is_valid_migration_name, | ||
migration_id_from_filename, | ||
) | ||
|
||
class LoaderTestCase(TestCase): | ||
""" Tests for the 'loader.py' module. """ | ||
|
||
def test_is_valid_migration_id(self): | ||
""" Test the `is_valid_migration_id` function. """ | ||
for migration_id, expect_valid in [ | ||
("0023_valid_name", True), | ||
("0023_dots_not_allowed.html", False), | ||
("no_leading_zeros", False), | ||
]: | ||
self.assertEqual(is_valid_migration_id(migration_id), expect_valid) | ||
|
||
def test_is_valid_migration_name(self): | ||
""" Test the `is_valid_migration_name` function. """ | ||
for name, expect_valid in [ | ||
("valid_name_here", True), | ||
("hyphens-not-allowed", False), | ||
("dots.not.allowed", False), | ||
]: | ||
self.assertEqual(is_valid_migration_name(name), expect_valid) | ||
|
||
def test_migration_id_from_filename(self): | ||
""" Test the `migration_id_from_filename` function. """ | ||
for filename, expected_id in [ | ||
("0001_my_migration.py", "0001_my_migration"), | ||
("0001_my_migration.html", None), | ||
("__init__.py", None), | ||
]: | ||
self.assertEqual(migration_id_from_filename(filename), expected_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.