Replaces migration and fixes broken tests

This commit is contained in:
Aaron Louie 2020-03-03 16:01:36 -05:00
parent 93168482c2
commit 01720a8bbf
5 changed files with 13 additions and 12 deletions

View File

@ -733,7 +733,7 @@ components:
example: "2019-12-25T09:12:33.001Z"
protocol_builder_status:
type: string
enum: [out_of_date, in_process, complete, updating]
enum: [DRAFT, IN_PROCESS, IN_REVIEW, REVIEW_COMPLETE, INACTIVE]
example: done
user_uid:
type: string

View File

@ -165,9 +165,9 @@ def map_pb_study_to_study(pb_study):
# Translate Protocol Builder states to enum values
status = ProtocolBuilderStatus.DRAFT
if pb_study['Q_COMPLETE']:
if pb_study['UPLOAD_COMPLETE']:
if pb_study['HSRNUMBER']:
if 'Q_COMPLETE' in pb_study['Q_COMPLETE'] and pb_study['Q_COMPLETE']:
if 'UPLOAD_COMPLETE' in pb_study and pb_study['UPLOAD_COMPLETE']:
if 'HSRNUMBER' in pb_study and pb_study['HSRNUMBER']:
status = ProtocolBuilderStatus.REVIEW_COMPLETE
else:
status = ProtocolBuilderStatus.IN_REVIEW

View File

@ -9,6 +9,7 @@ from crc.models.study import StudyModel
from crc.models.user import UserModel
from crc.models.workflow import WorkflowSpecModel
from crc.services.workflow_processor import WorkflowProcessor
from models.protocol_builder import ProtocolBuilderStatus
class ExampleDataLoader:
@ -31,7 +32,7 @@ class ExampleDataLoader:
id=1,
title='The impact of fried pickles on beer consumption in bipedal software developers.',
last_updated=datetime.datetime.now(),
protocol_builder_status='in_process',
protocol_builder_status=ProtocolBuilderStatus.IN_PROCESS.name,
primary_investigator_id='dhf8r',
sponsor='Sartography Pharmaceuticals',
ind_number='1234',
@ -41,7 +42,7 @@ class ExampleDataLoader:
id=2,
title='Requirement of hippocampal neurogenesis for the behavioral effects of soft pretzels',
last_updated=datetime.datetime.now(),
protocol_builder_status='in_process',
protocol_builder_status=ProtocolBuilderStatus.IN_PROCESS.name,
primary_investigator_id='dhf8r',
sponsor='Makerspace & Co.',
ind_number='5678',

View File

@ -1,8 +1,8 @@
"""empty message
Revision ID: cb3a03c10a0e
Revision ID: 1c6e4e179f8e
Revises:
Create Date: 2020-02-28 11:12:56.150837
Create Date: 2020-03-03 15:51:45.550681
"""
from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'cb3a03c10a0e'
revision = '1c6e4e179f8e'
down_revision = None
branch_labels = None
depends_on = None
@ -43,7 +43,7 @@ def upgrade():
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(), nullable=True),
sa.Column('last_updated', sa.DateTime(timezone=True), nullable=True),
sa.Column('protocol_builder_status', sa.Enum('out_of_date', 'in_process', 'complete', 'updating', name='protocolbuilderstatus'), nullable=True),
sa.Column('protocol_builder_status', sa.Enum('DRAFT', 'IN_PROCESS', 'IN_REVIEW', 'REVIEW_COMPLETE', 'INACTIVE', name='protocolbuilderstatus'), nullable=True),
sa.Column('primary_investigator_id', sa.String(), nullable=True),
sa.Column('sponsor', sa.String(), nullable=True),
sa.Column('hsr_number', sa.String(), nullable=True),

View File

@ -24,7 +24,7 @@ class TestStudyApi(BaseTest):
"title": "Phase III Trial of Genuine People Personalities (GPP) Autonomous Intelligent Emotional Agents "
"for Interstellar Spacecraft",
"last_updated": datetime.now(tz=timezone.utc),
"protocol_builder_status": ProtocolBuilderStatus.in_process,
"protocol_builder_status": ProtocolBuilderStatus.IN_PROCESS,
"primary_investigator_id": "tricia.marie.mcmillan@heartofgold.edu",
"sponsor": "Sirius Cybernetics Corporation",
"ind_number": "567890",
@ -49,7 +49,7 @@ class TestStudyApi(BaseTest):
self.load_example_data()
study: StudyModel = session.query(StudyModel).first()
study.title = "Pilot Study of Fjord Placement for Single Fraction Outcomes to Cortisol Susceptibility"
study.protocol_builder_status = ProtocolBuilderStatus.complete
study.protocol_builder_status = ProtocolBuilderStatus.REVIEW_COMPLETE
rv = self.app.put('/v1.0/study/%i' % study.id,
content_type="application/json",
headers=self.logged_in_headers(),