示例#1
0
    def test_build_study_info_empty_study(self):
        info = {
            'timeseries_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'
        }
        Study.create(User('*****@*****.**'), "My study", efo=[1], info=info)
        obs = _build_study_info(User('*****@*****.**'), 'user')

        self.exp.append({
            'metadata_complete': False,
            'ebi_submission_status': 'not submitted',
            'shared': [],
            'pmid': [],
            'pi': ('*****@*****.**', 'PIDude'),
            'status': 'sandbox',
            'proc_data_info': [],
            'publication_doi': [],
            'study_abstract': 'abstract',
            'study_id': 2,
            'ebi_study_accession': None,
            'study_title': 'My study',
            'number_samples_collected': 0
        })

        self.assertItemsEqual(obs, self.exp)

        # Now testing that admin also sees this study
        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, self.exp)
示例#2
0
    def test_build_study_info_empty_study(self):
        info = {
            'timeseries_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'}
        Study.create(User('*****@*****.**'), "My study", efo=[1], info=info)
        obs = _build_study_info(User('*****@*****.**'), 'user')

        self.exp.append({
            'metadata_complete': False,
            'ebi_submission_status':
            'not submitted',
            'shared': [],
            'publication_pid': [],
            'pi': ('*****@*****.**', 'PIDude'),
            'status': 'sandbox',
            'proc_data_info': [],
            'publication_doi': [],
            'study_abstract': 'abstract',
            'study_id': 2,
            'ebi_study_accession': None,
            'study_title': 'My study',
            'number_samples_collected': 0})

        self.assertItemsEqual(obs, self.exp)

        # Now testing that admin also sees this study
        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, self.exp)
示例#3
0
    def test_build_study_info(self):
        obs = _build_study_info(User('*****@*****.**'))
        self.assertEqual(obs, self.exp)

        with self.assertRaises(IncompetentQiitaDeveloperError):
            obs = _build_study_info(User('*****@*****.**'), study_proc={})
        with self.assertRaises(IncompetentQiitaDeveloperError):
            obs = _build_study_info(User('*****@*****.**'), proc_samples={})
示例#4
0
    def test_build_study_info(self):
        obs = _build_study_info(User('*****@*****.**'))
        self.assertEqual(obs, self.exp)

        with self.assertRaises(IncompetentQiitaDeveloperError):
            obs = _build_study_info(User('*****@*****.**'), study_proc={})
        with self.assertRaises(IncompetentQiitaDeveloperError):
            obs = _build_study_info(User('*****@*****.**'), proc_samples={})
示例#5
0
    def test_build_study_info_new_study(self):
        ProcessedData(1).status = 'public'
        info = {
            'timeseries_type_id': 1,
            'portal_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'}
        user = User('*****@*****.**')

        Study.create(user, 'test_study_1', efo=[1], info=info)
        obs = _build_study_info(user)
        self.exp.append({
            'status': 'sandbox',
            'checkbox': "<input type='checkbox' value='2' />",
            'abstract': 'abstract',
            'meta_complete': "<span class='glyphicon glyphicon-remove'>"
            "</span>",
            'title': '<a href=\'#\' data-toggle=\'modal\' data-target=\'#study'
            '-abstract-modal\' onclick=\'fillAbstract("studies-table"'
            ', 1)\'><span class=\'glyphicon glyphicon-file\' aria-hidden=\''
            'true\'></span></a> | <a href=\'/study/description/2\' id=\''
            'study1-title\'>test_study_1</a>',
            'num_raw_data': 0, 'id': 2, 'num_samples': '0',
            'shared': "<span id='shared_html_2'></span><br/><a class='btn "
            "btn-primary btn-xs' data-toggle='modal' data-target='#share-study"
            "-modal-view' onclick='modify_sharing(2);'>Modify</a>",
            'pmid': '', 'pi':
            '<a target="_blank" href="mailto:[email protected]">PIDude</a>'})
        self.assertEqual(obs, self.exp)
    def test_build_study_info_new_study(self):
        info = {
            'timeseries_type_id': 1,
            'portal_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'}
        user = User('*****@*****.**')

        Study.create(user, 'test_study_1', efo=[1], info=info)

        obs = _build_study_info('private', user)

        StudyTuple = namedtuple('StudyInfo', 'id title meta_complete '
                                'num_samples_collected shared num_raw_data pi '
                                'pmids owner status')
        exp = [
            StudyTuple(
                id=2,
                title='test_study_1',
                meta_complete=False, num_samples_collected=None,
                shared='',
                num_raw_data=0,
                pi='<a target="_blank" href="mailto:[email protected]">'
                   'PIDude</a>',
                pmids='',
                owner='<a target="_blank" href="mailto:[email protected]">'
                      '[email protected]</a>',
                status='sandbox')]
        self.assertEqual(obs, exp)
示例#7
0
 def test_build_study_info(self):
     Study(1).status = 'public'
     obs = _build_study_info('public', User('*****@*****.**'))
     StudyTuple = namedtuple(
         'StudyInfo', 'id title meta_complete '
         'num_samples_collected shared num_raw_data pi '
         'pmids owner status')
     exp = [
         StudyTuple(
             id=1,
             title='Identification of the Microbiomes for Cannabis Soils',
             meta_complete=True,
             num_samples_collected=27,
             shared='<a target="_blank" href="mailto:[email protected]">'
             'Shared</a>',
             num_raw_data=4,
             pi='<a target="_blank" href="mailto:[email protected]">'
             'PIDude</a>',
             pmids='<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
             'pubmed/123456">123456</a>, '
             '<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
             'pubmed/7891011">7891011</a>',
             owner='<a target="_blank" href="mailto:[email protected]">'
             '[email protected]</a>',
             status='public')
     ]
     self.assertEqual(obs, exp)
示例#8
0
    def test_build_study_info_new_study(self):
        info = {
            'timeseries_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'}
        user = User('*****@*****.**')

        Study.create(user, 'test_study_1', efo=[1], info=info)
        obs = _build_study_info(user)
        self.exp.append({
            'study_id': 2,
            'status': 'sandbox',
            'study_abstract': 'abstract',
            'metadata_complete': False,
            'study_title': 'test_study_1',
            'num_raw_data': 0,
            'number_samples_collected': 0,
            'shared': '',
            'pmid': '',
            'publication_doi': '',
            'pi':
                '<a target="_blank" href="mailto:[email protected]">PIDude</a>',
            'proc_data_info': []})
        self.assertEqual(obs, self.exp)
示例#9
0
    def test_build_study_info_new_study(self):
        info = {
            'timeseries_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'
        }
        user = User('*****@*****.**')

        Study.create(user, 'test_study_1', efo=[1], info=info)
        obs = _build_study_info(user)
        self.exp.append({
            'study_id': 2,
            'status': 'sandbox',
            'study_abstract': 'abstract',
            'metadata_complete': False,
            'study_title': 'test_study_1',
            'num_raw_data': 0,
            'number_samples_collected': 0,
            'shared': '',
            'pmid': '',
            'publication_doi': '',
            'pi':
            '<a target="_blank" href="mailto:[email protected]">PIDude</a>',
            'proc_data_info': []
        })
        self.assertEqual(obs, self.exp)
示例#10
0
    def test_build_study_info(self):
        for a in Study(1).artifacts():
            a.visibility = 'private'

        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, self.exp)

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, [])

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, [])

        # make all the artifacts public - (1) the only study in the tests,
        for a in Study(1).artifacts():
            a.visibility = 'public'
        self.exp[0]['status'] = 'public'

        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, self.exp)

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, [])

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, self.exp)

        # return to it's private status
        for a in Study(1).artifacts():
            a.visibility = 'private'
示例#11
0
 def test_build_study_info_erros(self):
     with self.assertRaises(IncompetentQiitaDeveloperError):
         _build_study_info(User('*****@*****.**'), 'user', study_proc={})
     with self.assertRaises(IncompetentQiitaDeveloperError):
         _build_study_info(User('*****@*****.**'), 'user', proc_samples={})
     with self.assertRaises(ValueError):
         _build_study_info(User('*****@*****.**'), 'wrong')
示例#12
0
 def test_build_study_info_erros(self):
     with self.assertRaises(IncompetentQiitaDeveloperError):
         _build_study_info(User('*****@*****.**'), 'user', study_proc={})
     with self.assertRaises(IncompetentQiitaDeveloperError):
         _build_study_info(User('*****@*****.**'), 'user', proc_samples={})
     with self.assertRaises(ValueError):
         _build_study_info(User('*****@*****.**'), 'wrong')
示例#13
0
    def test_build_study_info_new_study(self):
        info = {
            'timeseries_type_id': 1,
            'portal_type_id': 1,
            'lab_person_id': None,
            'principal_investigator_id': 3,
            'metadata_complete': False,
            'mixs_compliant': True,
            'study_description': 'desc',
            'study_alias': 'alias',
            'study_abstract': 'abstract'
        }
        user = User('*****@*****.**')

        Study.create(user, 'test_study_1', efo=[1], info=info)

        obs = _build_study_info('private', user)

        StudyTuple = namedtuple(
            'StudyInfo', 'id title meta_complete '
            'num_samples_collected shared num_raw_data pi '
            'pmids owner status')
        exp = [
            StudyTuple(id=2,
                       title='test_study_1',
                       meta_complete=False,
                       num_samples_collected=None,
                       shared='',
                       num_raw_data=0,
                       pi='<a target="_blank" href="mailto:[email protected]">'
                       'PIDude</a>',
                       pmids='',
                       owner='<a target="_blank" href="mailto:[email protected]">'
                       '[email protected]</a>',
                       status='sandbox')
        ]
        self.assertEqual(obs, exp)
示例#14
0
 def test_build_study_info(self):
     Study(1).status = 'public'
     obs = _build_study_info('public', User('*****@*****.**'))
     StudyTuple = namedtuple('StudyInfo', 'id title meta_complete '
                             'num_samples_collected shared num_raw_data pi '
                             'pmids owner status')
     exp = [
         StudyTuple(
             id=1,
             title='Identification of the Microbiomes for Cannabis Soils',
             meta_complete=True, num_samples_collected=27,
             shared='<a target="_blank" href="mailto:[email protected]">'
                    'Shared</a>',
             num_raw_data=2,
             pi='<a target="_blank" href="mailto:[email protected]">'
                'PIDude</a>',
             pmids='<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
                   'pubmed/123456">123456</a>, '
                   '<a target="_blank" href="http://www.ncbi.nlm.nih.gov/'
                   'pubmed/7891011">7891011</a>',
             owner='<a target="_blank" href="mailto:[email protected]">'
                   '[email protected]</a>',
             status='public')]
     self.assertEqual(obs, exp)
示例#15
0
 def test_build_study_info(self):
     obs = _build_study_info(User('*****@*****.**'), 'user')
     self.assertEqual(obs, self.exp)
示例#16
0
 def test_build_study_info(self):
     obs = _build_study_info(User('*****@*****.**'), 'user')
     self.assertEqual(obs, self.exp)
示例#17
0
    def test_build_study_info(self):
        for a in Study(1).artifacts():
            a.visibility = 'private'

        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, self.exp)

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, [])

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, [])

        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, self.exp)

        # make all the artifacts public - (1) the only study in the tests,
        for a in Study(1).artifacts():
            a.visibility = 'public'
        self.exp[0]['status'] = 'public'

        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, self.exp)

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, [])

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, self.exp)

        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, [])

        # make all the artifacts awaiting_approval - (1) the only study
        # in the tests,
        for a in Study(1).artifacts():
            a.visibility = 'awaiting_approval'
        self.exp[0]['status'] = 'awaiting_approval'

        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, self.exp)

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, [])

        obs = _build_study_info(User('*****@*****.**'), 'public')
        self.assertEqual(obs, [])

        obs = _build_study_info(User('*****@*****.**'), 'user')
        self.assertEqual(obs, self.exp)

        # awaiting_approval
        # return to it's private status
        for a in Study(1).artifacts():
            a.visibility = 'private'
示例#18
0
 def test_build_study_info(self):
     ProcessedData(1).status = 'public'
     obs = _build_study_info(User('*****@*****.**'))
     self.assertEqual(obs, self.exp)