2021-02-09 17:37:55 -05:00
|
|
|
from tests.base_test import BaseTest
|
|
|
|
from crc import session
|
|
|
|
from crc.models.study import StudyModel
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
class TestGetStudyFromModel(BaseTest):
|
|
|
|
|
|
|
|
def test_get_study_from_model(self):
|
|
|
|
|
2022-02-09 22:13:02 -05:00
|
|
|
self.add_studies()
|
2021-02-09 17:37:55 -05:00
|
|
|
study = session.query(StudyModel).order_by(StudyModel.id.desc()).first()
|
|
|
|
id = study.id + 1
|
|
|
|
result = self.app.get('/v1.0/study/%i' % id,
|
|
|
|
headers=self.logged_in_headers())
|
|
|
|
json_data = json.loads(result.get_data(as_text=True))
|
|
|
|
self.assertIn('code', json_data)
|
|
|
|
self.assertEqual('empty_study_model', json_data['code'])
|