Example #1
0
    def test_no_response(self, mock_post):
        mock_post.return_value = None

        emp_dep = EmpiarDepositor("ABC123", self.json_path, "", entry_id=1)

        c = emp_dep.grant_rights()
        self.assertEqual(c, 1)
Example #2
0
    def test_no_rights_granting_input_return(self, mock_post):
        mock_post = mock_response(
            mock_post,
            status_code=403,
            headers={'content-type': 'application/json'},
            json={'detail': 'You do not have permission to perform this action.'}
        )

        emp_dep = EmpiarDepositor("ABC123", self.json_path, "", entry_id=1)

        c = emp_dep.grant_rights()
        self.assertEqual(c, 1)
Example #3
0
    def test_successful_rights_granting(self, mock_post):
        mock_post = mock_response(
            mock_post,
            status_code=200,
            headers={'content-type': 'application/json'},
            json={
                'test1': True,'test2': True,
                '*****@*****.**': True, '*****@*****.**': True,
                '0000-0000-0000-0000': True, '0000-0000-0000-0001': True
            }
        )

        emp_dep = EmpiarDepositor("ABC123", self.json_path, "",
                                  entry_id = 1,
                                  grant_rights_usernames=self.grant_rights_usernames,
                                  grant_rights_emails=self.grant_rights_emails,
                                  grant_rights_orcids=self.grant_rights_orcids
                                  )

        c = emp_dep.grant_rights()
        self.assertEqual(c, 0)
Example #4
0
    def test_no_entry_id_return(self, mock_post):
        emp_dep = EmpiarDepositor("ABC123", self.json_path, "")

        c = emp_dep.grant_rights()
        self.assertEqual(c, 1)