def test_remove_index_noindex(self):
     handle_with_index = "foo/bar"
     syntax_checked = check_handle_syntax(handle_with_index)
     self.assertTrue(syntax_checked, 'Test precondition failed!')
     index, handle = remove_index_from_handle(handle_with_index)
     syntax_checked = check_handle_syntax(handle)
     self.assertTrue(syntax_checked,
                     'After removing the index, the syntax of the handle should ' + \
                     'be prefix/suffix.')
Пример #2
0
    def test_get_value_from_handle_HS_ADMIN(self):
        """Test retrieving an HS_ADMIN value from a handle record."""

        handlerecord = RECORD
        handle = handlerecord['handle']

        val = self.inst.get_value_from_handle(handle, 'HS_ADMIN', handlerecord)
        self.assertIn('handle', val, 'The HS_ADMIN has no entry "handle".')
        self.assertIn('index', val, 'The HS_ADMIN has no entry "index".')
        self.assertIn('permissions', val,
                      'The HS_ADMIN has no entry "permissions".')
        syntax_ok = check_handle_syntax(val['handle'])
        self.assertTrue(syntax_ok,
                        'The handle in HS_ADMIN is not well-formatted.')
        self.assertIsInstance(val['index'], (int, long),
                              'The index of the HS_ADMIN is not an integer.')
        self.assertEqual(
            str(val['permissions']).replace('0', '').replace('1', ''), '',
            'The permission value in the HS_ADMIN contains not just 0 and 1.')
 def test_check_handle_syntax_no_prefix(self):
     """Handle Syntax: Exception if no prefix."""
     with self.assertRaises(HandleSyntaxError):
         check_handle_syntax("/bar")
 def test_check_handle_syntax_no_slashes(self):
     """Handle Syntax: Exception if too many slashes in handle."""
     with self.assertRaises(HandleSyntaxError):
         check_handle_syntax("foobar")
 def test_check_handle_syntax_two_slashes(self):
     """Handle Syntax: No exception if too many slashes in handle."""
     check_handle_syntax("foo/bar/foo")
 def test_check_handle_syntax_normal(self):
     """Test check handle syntax"""
     syntax_checked = check_handle_syntax("foo/bar")
     self.assertTrue(syntax_checked)
 def test_check_handle_syntax_none(self):
     """Test check handle syntax where handle is None"""
     with self.assertRaises(HandleSyntaxError):
         syntax_checked = check_handle_syntax(None)
 def test_check_handle_syntax_with_index(self):
     """Test check handle syntax with index."""
     syntax_checked = check_handle_syntax("300:foo/bar")
     self.assertTrue(syntax_checked,
         'The syntax of the handle is not index:prefix/suffix.')
 def test_check_handle_syntax_no_suffix(self):
     """Handle Syntax: Exception if no suffix."""
     with self.assertRaises(HandleSyntaxError):
         check_handle_syntax("foo/")