-
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 #122 from mskcc/develop
Develop, for release 1.6.0
- Loading branch information
Showing
12 changed files
with
169 additions
and
73 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
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
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 |
---|---|---|
@@ -1,82 +1,80 @@ | ||
import os | ||
from django.apps import apps | ||
from django.test import TestCase | ||
from django.db.migrations.executor import MigrationExecutor | ||
from django.db import connection | ||
from toil_orchestrator import migrations | ||
from django_test_migrations.contrib.unittest_case import MigratorTestCase | ||
from toil_orchestrator.models import Status | ||
import json | ||
|
||
current_app = 'toil_orchestrator' | ||
|
||
|
||
class TestMigration(MigratorTestCase): | ||
|
||
def setUp(self,migrate_from,migrate_to): | ||
def setUp(self, migrate_from, migrate_to): | ||
self.migrate_from = (current_app, self.get_migration_file_name(migrate_from)) | ||
self.migrate_to = (current_app, self.get_migration_file_name(migrate_to)) | ||
super().setUp() | ||
|
||
def get_migration_file_name(self,number): | ||
def get_migration_file_name(self, number): | ||
migration_path = migrations.__path__[0] | ||
migration_files = os.listdir(migration_path) | ||
for single_file in migration_files: | ||
single_file_split = single_file.split('_') | ||
if str(number) in single_file_split[0]: | ||
return os.path.splitext(single_file)[0] | ||
|
||
|
||
class TestMessageMigration(TestMigration): | ||
|
||
def setUp(self): | ||
super().setUp(13,17) | ||
super().setUp(13, 17) | ||
|
||
def prepare(self): | ||
job = self.old_state.apps.get_model('toil_orchestrator','job') | ||
job = self.old_state.apps.get_model('toil_orchestrator', 'job') | ||
job.objects.create( | ||
app={ | ||
"github": { | ||
"github": { | ||
"entrypoint": "tempo.cwl", | ||
"repository": "https://github.com/mskcc-cwl/tempo" | ||
} | ||
}, | ||
} | ||
}, | ||
message="sample_info_string" | ||
|
||
) | ||
) | ||
|
||
def test_migration(self): | ||
job = self.new_state.apps.get_model('toil_orchestrator','job') | ||
job = self.new_state.apps.get_model('toil_orchestrator', 'job') | ||
current_job = job.objects.all().first() | ||
|
||
def test_message(self): | ||
job = self.new_state.apps.get_model('toil_orchestrator','job') | ||
job = self.new_state.apps.get_model('toil_orchestrator', 'job') | ||
current_job = job.objects.all().first() | ||
new_message_obj = json.loads(current_job.message) | ||
self.assertEqual(new_message_obj['info'],"sample_info_string") | ||
self.assertEqual(new_message_obj['info'], "sample_info_string") | ||
|
||
|
||
class TestDateMigration(TestMigration): | ||
|
||
def setUp(self): | ||
super().setUp(12,13) | ||
super().setUp(12, 13) | ||
|
||
def prepare(self): | ||
job = self.old_state.apps.get_model('toil_orchestrator','job') | ||
job = self.old_state.apps.get_model('toil_orchestrator', 'job') | ||
job.objects.create( | ||
app={ | ||
"github": { | ||
"github": { | ||
"entrypoint": "tempo.cwl", | ||
"repository": "https://github.com/mskcc-cwl/tempo" | ||
} | ||
}, | ||
} | ||
}, | ||
status=Status.COMPLETED, | ||
finished=None, | ||
started=None, | ||
submitted=None | ||
) | ||
) | ||
|
||
def test_date_change(self): | ||
job = self.new_state.apps.get_model('toil_orchestrator','job') | ||
job = self.new_state.apps.get_model('toil_orchestrator', 'job') | ||
current_job = job.objects.all().first() | ||
self.assertNotEqual(current_job.started,None) | ||
self.assertNotEqual(current_job.submitted,None) | ||
self.assertNotEqual(current_job.finished,None) | ||
|
||
self.assertNotEqual(current_job.started, None) | ||
self.assertNotEqual(current_job.submitted, None) | ||
self.assertNotEqual(current_job.finished, None) |
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
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,34 @@ | ||
# Generated by Django 2.2.10 on 2020-12-21 18:00 | ||
|
||
from django.db import migrations, models | ||
import toil_orchestrator.models | ||
|
||
|
||
def migrate_statuses(apps, schema_editor): | ||
Job = apps.get_model('toil_orchestrator', 'Job') | ||
jobs = Job.objects.all() | ||
for job in jobs: | ||
if job.status == 5: | ||
job.status = 6 | ||
job.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('toil_orchestrator', '0017_auto_20200624_1635'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='commandlinetooljob', | ||
name='status', | ||
field=models.IntegerField(choices=[(0, 'CREATED'), (1, 'PENDING'), (2, 'RUNNING'), (3, 'COMPLETED'), (4, 'FAILED'), (5, 'ABORTED'), (6, 'UNKNOWN')], default=0), | ||
), | ||
migrations.AlterField( | ||
model_name='job', | ||
name='status', | ||
field=models.IntegerField(choices=[(0, 'CREATED'), (1, 'PENDING'), (2, 'RUNNING'), (3, 'COMPLETED'), (4, 'FAILED'), (5, 'ABORTED'), (6, 'UNKNOWN')], default=toil_orchestrator.models.Status(0)), | ||
), | ||
migrations.RunPython(migrate_statuses) | ||
] |
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
Oops, something went wrong.