Exemplo n.º 1
0
    def test_submit_deposit_notoken(self):
        no_token = Repository()
        no_token.api_key = None
        repo_without_token = OSFProtocol(no_token)

        data = {'onbehalfof': ''}
        repo_without_token.form = repo_without_token.get_bound_form(data)
        repo_without_token.form.is_valid()

        with self.assertRaises(DepositError):
            repo_without_token.submit_deposit(pdf=None, form=None)
Exemplo n.º 2
0
    def test_submit_deposit_notoken(self):
        no_token = Repository()
        no_token.api_key = None
        repo_without_token = OSFProtocol(no_token)

        data = {'onbehalfof': ''}
        repo_without_token.form = repo_without_token.get_bound_form(data)
        repo_without_token.form.is_valid()

        with self.assertRaises(DepositError):
            repo_without_token.submit_deposit(pdf=None, form=None)
Exemplo n.º 3
0
    def setUp(self):
        super(ZenodoProtocolTest, self).setUp()
        if 'ZENODO_SANDBOX_API_KEY' not in os.environ:
            raise unittest.SkipTest(
                "Environment variable ZENODO_SANDBOX_API_KEY is undefined")
        self.setUpForProtocol(
            ZenodoProtocol,
            Repository(
                name='Zenodo Sandbox',
                endpoint='https://sandbox.zenodo.org/api/deposit/depositions',
                api_key=os.environ['ZENODO_SANDBOX_API_KEY'],
            ))

        self.testdir = os.path.dirname(os.path.abspath(__file__))
        with open(os.path.join(self.testdir, 'testdata/zenodo_record.xml'),
                  'r') as f:
            self.zenodo_record = f.read()

        self.l = License.objects.get(
            uri="https://dissem.in/deposit/license/zenodo-freetoread-1.0/")
        self.lc, unused = LicenseChooser.objects.get_or_create(
            license=self.l,
            repository=self.repo,
            transmit_id='zenodo-freetoread-1.0',
            default=True,
        )
Exemplo n.º 4
0
 def setUp(self):
     super(HALProtocolTest, self).setUp()
     self.setUpForProtocol(
         HALProtocol,
         Repository(
             username='******',
             password='******',
             endpoint='https://api-preprod.archives-ouvertes.fr/sword/'))
Exemplo n.º 5
0
    def setUp(self):
        super(OSFProtocolTest, self).setUp()
        api_key = 'eJMuNoeFvKTIC5A6POx1nrmsiQoMZqwh'
        api_key += 'CgeEXwDgggYWDeR96Y9KbypgVGNuCY5r9qVgan'

        self.setUpForProtocol(
            OSFProtocol,
            Repository(api_key=api_key,
                       endpoint="https://test-api.osf.io/",
                       username="******"))

        # go to https://api.osf.io/v2/users/me/ (once logged in) to get
        # this identifier. (it is returned as "id" in the JSON response)

        # Fill here the details of the metadata form
        # for your repository
        data = {'onbehalfof': ''}
        self.form = self.proto.get_bound_form(data)
        self.form.is_valid()  # this validates our sample data
Exemplo n.º 6
0
 def setUp(self):
     self.protocol = HALProtocol(repository=Repository())