Beispiel #1
0
 def test_artifact_patch_request_errors(self):
     # No access to the study
     obs = artifact_patch_request('*****@*****.**', 'replace',
                                  '/1/name/', req_value='NEW_NAME')
     exp = {'status': 'error',
            'message': 'User does not have access to study'}
     self.assertEqual(obs, exp)
     # Incorrect path parameter
     obs = artifact_patch_request('*****@*****.**', 'replace',
                                  '/1/name/oops/', req_value='NEW_NAME')
     exp = {'status': 'error',
            'message': 'Incorrect path parameter'}
     self.assertEqual(obs, exp)
     # Missing value
     obs = artifact_patch_request('*****@*****.**', 'replace', '/1/name/')
     exp = {'status': 'error',
            'message': 'A value is required'}
     self.assertEqual(obs, exp)
     # Wrong attribute
     obs = artifact_patch_request('*****@*****.**', 'replace', '/1/oops/',
                                  req_value='NEW_NAME')
     exp = {'status': 'error',
            'message': 'Attribute "oops" not found. Please, check the '
                       'path parameter'}
     self.assertEqual(obs, exp)
     # Wrong operation
     obs = artifact_patch_request('*****@*****.**', 'add', '/1/name/',
                                  req_value='NEW_NAME')
     exp = {'status': 'error',
            'message': 'Operation "add" not supported. Current supported '
                       'operations: replace'}
     self.assertEqual(obs, exp)
Beispiel #2
0
 def test_artifact_patch_request_errors(self):
     # No access to the study
     obs = artifact_patch_request('*****@*****.**', 'replace',
                                  '/1/name/', req_value='NEW_NAME')
     exp = {'status': 'error',
            'message': 'User does not have access to study'}
     self.assertEqual(obs, exp)
     # Incorrect path parameter
     obs = artifact_patch_request('*****@*****.**', 'replace',
                                  '/1/name/oops/', req_value='NEW_NAME')
     exp = {'status': 'error',
            'message': 'Incorrect path parameter'}
     self.assertEqual(obs, exp)
     # Missing value
     obs = artifact_patch_request('*****@*****.**', 'replace', '/1/name/')
     exp = {'status': 'error',
            'message': 'A value is required'}
     self.assertEqual(obs, exp)
     # Wrong attribute
     obs = artifact_patch_request('*****@*****.**', 'replace', '/1/oops/',
                                  req_value='NEW_NAME')
     exp = {'status': 'error',
            'message': 'Attribute "oops" not found. Please, check the '
                       'path parameter'}
     self.assertEqual(obs, exp)
     # Wrong operation
     obs = artifact_patch_request('*****@*****.**', 'add', '/1/name/',
                                  req_value='NEW_NAME')
     exp = {'status': 'error',
            'message': 'Operation "add" not supported. Current supported '
                       'operations: replace'}
     self.assertEqual(obs, exp)
Beispiel #3
0
    def test_artifact_patch_request(self):
        obs = artifact_patch_request('*****@*****.**', 'replace', '/1/name/',
                                     req_value='NEW_NAME')
        exp = {'status': 'success', 'message': ''}
        self.assertEqual(obs, exp)

        self.assertEqual(Artifact(1).name, 'NEW_NAME')
Beispiel #4
0
    def test_artifact_patch_request(self):
        obs = artifact_patch_request('*****@*****.**', 'replace',
                                     '/%d/name/' % self.artifact.id,
                                     req_value='NEW_NAME')
        exp = {'status': 'success', 'message': ''}
        self.assertEqual(obs, exp)

        self.assertEqual(Artifact(self.artifact.id).name, 'NEW_NAME')