Example #1
0
    def test_study_patch_request_tags(self):
        # adding test for study_tags_request here as it makes sense to check
        # that the tags were added
        obs = study_tags_request()
        exp = {
            'status': 'success',
            'message': '',
            'tags': {
                'admin': [],
                'user': []
            }
        }
        self.assertEqual(obs, exp)

        obs = study_patch_request('*****@*****.**', 1, 'replace', '/tags',
                                  ['testA', 'testB'])
        exp = {'status': 'success', 'message': ''}
        self.assertEqual(obs, exp)

        obs = study_tags_request()
        exp = {
            'status': 'success',
            'message': '',
            'tags': {
                'admin': [],
                'user': ['testA', 'testB']
            }
        }
        self.assertEqual(obs, exp)

        obs = study_patch_request('*****@*****.**', 2000, 'replace', '/tags',
                                  ['testA', 'testB'])
        exp = {'message': 'Study does not exist', 'status': 'error'}
        self.assertEqual(obs, exp)
Example #2
0
    def test_study_patch_request_errors(self):
        # check errors
        obs = study_patch_request('*****@*****.**', 1, 'no-exists', '/tags',
                                  ['testA', 'testB'])
        exp = {
            'message': ('Operation "no-exists" not supported. Current '
                        'supported operations: replace'),
            'status':
            'error'
        }
        self.assertEqual(obs, exp)

        obs = study_patch_request('*****@*****.**', 1, 'replace', '/tags/na',
                                  ['testA', 'testB'])
        exp = {'message': 'Incorrect path parameter', 'status': 'error'}
        self.assertEqual(obs, exp)

        obs = study_patch_request('*****@*****.**', 1, 'replace', '/na')
        exp = {
            'message': ('Attribute "na" not found. Please, check the '
                        'path parameter'),
            'status':
            'error'
        }
        self.assertEqual(obs, exp)
Example #3
0
    def test_study_patch_request_specimen_id_errors(self):
        obs = study_patch_request('*****@*****.**', 1,
                                  'replace', '/specimen_id_column',
                                  'taxon_id')
        exp = {'status': 'error', 'message': 'The category does not contain'
               ' unique values.'}
        self.assertEqual(obs, exp)

        obs = study_patch_request('*****@*****.**', 1,
                                  'replace', '/specimen_id_column',
                                  'bleep_bloop')
        exp = {'status': 'error', 'message': "Category 'bleep_bloop' is not"
               " present in the sample information."}
        self.assertEqual(obs, exp)
Example #4
0
    def test_study_patch_request_specimen_id(self):
        obs = study_patch_request('*****@*****.**', 1,
                                  'replace', '/specimen_id_column',
                                  'anonymized_name')
        exp = {'status': 'success', 'message': 'Successfully updated '
                                               'specimen id column'}
        self.assertEqual(obs, exp)

        obs = study_patch_request('*****@*****.**', 1,
                                  'replace', '/specimen_id_column',
                                  'host_subject_id')
        exp = {'status': 'success', 'message': 'Successfully updated '
                                               'specimen id column'}
        self.assertEqual(obs, exp)

        qdb.study.Study(1).specimen_id_column = None
Example #5
0
    def test_study_patch_request_errors(self):
        # check errors
        obs = study_patch_request(
            '*****@*****.**', 1, 'no-exists', '/tags', ['testA', 'testB'])
        exp = {'message': ('Operation "no-exists" not supported. Current '
               'supported operations: replace'), 'status': 'error'}
        self.assertEqual(obs, exp)

        obs = study_patch_request(
            '*****@*****.**', 1, 'replace', '/tags/na', ['testA', 'testB'])
        exp = {'message': 'Incorrect path parameter', 'status': 'error'}
        self.assertEqual(obs, exp)

        obs = study_patch_request(
            '*****@*****.**', 1, 'replace', '/na')
        exp = {'message': ('Attribute "na" not found. Please, check the '
                           'path parameter'), 'status': 'error'}
        self.assertEqual(obs, exp)
Example #6
0
    def test_study_patch_request_toggle_public_raw_download(self):
        study_id = 1
        study = qdb.study.Study(study_id)
        obs = study_patch_request('*****@*****.**', study_id,
                                  'replace', '/toggle_public_raw_download',
                                  None)
        exp = {'status': 'success', 'message': 'Successfully updated '
                                               'public_raw_download'}
        self.assertEqual(obs, exp)
        self.assertTrue(study.public_raw_download)

        obs = study_patch_request('*****@*****.**', study_id,
                                  'replace', '/specimen_id_column',
                                  'host_subject_id')
        exp = {'status': 'error',
               'message': 'User does not have access to study'}
        self.assertEqual(obs, exp)
        self.assertTrue(study.public_raw_download)

        # returning to default status
        study.public_raw_download = False
Example #7
0
    def test_study_patch_request_tags(self):
        # adding test for study_tags_request here as it makes sense to check
        # that the tags were added
        obs = study_tags_request()
        exp = {'status': 'success', 'message': '',
               'tags': {'admin': [], 'user': []}}
        self.assertEqual(obs, exp)

        obs = study_patch_request(
            '*****@*****.**', 1, 'replace', '/tags', ['testA', 'testB'])
        exp = {'status': 'success', 'message': ''}
        self.assertEqual(obs, exp)

        obs = study_tags_request()
        exp = {'status': 'success', 'message': '',
               'tags': {'admin': [], 'user': ['testA', 'testB']}}
        self.assertEqual(obs, exp)

        obs = study_patch_request(
            '*****@*****.**', 2000, 'replace', '/tags', ['testA', 'testB'])
        exp = {'message': 'Study does not exist', 'status': 'error'}
        self.assertEqual(obs, exp)