Ejemplo n.º 1
0
    def test_global_resolve(self):
        """Testing if instantiating with default handle server'works
        and if a handle is correctly retrieved. """

        # Create instance with default server url:
        inst = EUDATHandleClient(HTTPS_verify=self.https_verify)
        rec = inst.retrieve_handle_record_json(self.handle_global)

        self.assertIn('handle', rec, 'Response lacks "handle".')
        self.assertIn('responseCode', rec, 'Response lacks "responseCode".')
Ejemplo n.º 2
0
    def __init__(self, credentials=None):
        """Constructor.

        :param credentials: B2Handle credentials.
        """
        self.credentials = credentials
        self.handle_prefix = None
        self.handle_client = None
        if credentials:
            self.handle_prefix = credentials.get('prefix')
            assert self.handle_prefix
            self.handle_client = EUDATHandleClient(**credentials)
Ejemplo n.º 3
0
    def test_modify_handle_value_without_authentication(self):
        """Test if exception when not authenticated."""
        log_new_case("test_modify_handle_value_without_authentication")

        # Test variables
        testhandle = self.handle
        inst_readonly = EUDATHandleClient(self.url,
                                          HTTPS_verify=self.https_verify)

        # Run code to be tested + check exception:
        log_start_test_code()
        with self.assertRaises(HandleAuthenticationError):
            inst_readonly.modify_handle_value(testhandle, foo='bar')
        log_end_test_code()
Ejemplo n.º 4
0
    def setUp(self):
        """ For most test, provide a client instance with the user-specified
        handle server url."""

        self.inst = EUDATHandleClient(HTTPS_verify=self.https_verify,
                                      handle_server_url=self.url,
                                      url_extension_REST_API=self.path_to_api)

        # Before being able to run these tests without write access,
        # the handle that we use for testing must exist. With this code,
        # you can create it. You only need to create it once and leave it
        # on the server, it will not be modified and can be used eternally.
        if False:
            # This should always be false!!! Except for creating the
            # required handle once!
            self.create_required_test_handles()
 def test_create_revlookup_query_norestriction(self):
     inst = EUDATHandleClient(allowed_search_keys=[])
     query = inst.create_revlookup_query(baz='baz')
     self.assertEqual(query, '?baz=baz', 'The query is: ' + query)
 def setUp(self):
     self.inst = EUDATHandleClient()
Ejemplo n.º 7
0
 def setUp(self):
     self.inst = EUDATHandleClient()
     self.inst._EUDATHandleClient__searcher._Searcher__has_search_access = True  # fake search access
     self.searcher = Searcher()
     self.searcher._Searcher__has_search_access = True  # Fake search access
Ejemplo n.º 8
0
 def test_constructor_with_url(self):
     """Test constructor with one arg (ill-formatted server URL): No exception raised."""
     inst = EUDATHandleClient('foo')
     self.assertIsInstance(inst, EUDATHandleClient,
                           'Not a client instance!')
Ejemplo n.º 9
0
 def test_constructor_no_args(self):
     """Test constructor without args: No exception raised."""
     inst = EUDATHandleClient()
     self.assertIsInstance(inst, EUDATHandleClient,
                           'Not a client instance!')