当前位置: 首页>>代码示例>>Python>>正文


Python EUDATHandleClient.is_10320LOC_empty方法代码示例

本文整理汇总了Python中b2handle.handleclient.EUDATHandleClient.is_10320LOC_empty方法的典型用法代码示例。如果您正苦于以下问题:Python EUDATHandleClient.is_10320LOC_empty方法的具体用法?Python EUDATHandleClient.is_10320LOC_empty怎么用?Python EUDATHandleClient.is_10320LOC_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在b2handle.handleclient.EUDATHandleClient的用法示例。


在下文中一共展示了EUDATHandleClient.is_10320LOC_empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: EUDATHandleClientReadaccessPatchedTestCase

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import is_10320LOC_empty [as 别名]

#.........这里部分代码省略.........
            'Key "HS_ADMIN" not in handlerecord dictionary!')

        self.assertEqual(dict_record['TEST1'], 'val1',
            'The value of "test1" is not "val1.')
        self.assertEqual(dict_record['TEST2'], 'val2',
            'The value of "test2" is not "val2.')
        self.assertIn(dict_record['TESTDUP'], ("dup1", "dup2"),
            'The value of the duplicate key "TESTDUP" should be "dup1" or "dup2".')
        self.assertIn('permissions', dict_record['HS_ADMIN'],
            'The HS_ADMIN has no permissions: '+dict_record['HS_ADMIN'])

        self.assertEqual(len(dict_record), 4,
            'The record should have a length of 5 (as the duplicate is ignored.')

    # get_value_from_handle

    @mock.patch('b2handle.handleclient.requests.Session.get')
    def test_get_value_from_handle_when_handle_inexistent(self, getpatch):
        """Test error when retrieving a handle record, giving a None type."""
        
        # Test variables
        testhandle = 'who/cares'
        key = 'foo'

        # Define the replacement for the patched method:
        mock_response = MockResponse(notfound=True)
        getpatch.return_value = mock_response

        # Call method and check result:
        with self.assertRaises(HandleNotFoundException):
            self.inst.get_value_from_handle(testhandle, key=key)

    @mock.patch('b2handle.handleclient.requests.Session.get')
    def test_is_10320LOC_empty_handle_does_not_exist(self, getpatch):
        """Test exception"""

        # Test variables
        testhandle = 'who/cares'

        # Define the replacement for the patched method:
        mock_response = MockResponse(notfound=True)
        getpatch.return_value = mock_response

        # Call method and check result:
        with self.assertRaises(HandleNotFoundException):
            self.inst.is_10320LOC_empty(testhandle)

    @mock.patch('b2handle.handleclient.requests.Session.get')
    def test_is_url_contained_in_10320LOC_handle_does_not_exist(self, getpatch):
        """Test exception"""

        # Test variables
        testhandle = 'who/cares'
        one_url = 'http://bla'
        list_of_urls = ['http://bla','http://foo.foo']

        # Define the replacement for the patched method:
        mock_response = MockResponse(notfound=True)
        getpatch.return_value = mock_response

        # Call method and check result:
        with self.assertRaises(HandleNotFoundException):
            self.inst.is_URL_contained_in_10320LOC(testhandle, url=one_url)
        with self.assertRaises(HandleNotFoundException):
            self.inst.is_URL_contained_in_10320LOC(testhandle, url=list_of_urls)
开发者ID:EUDAT-B2SAFE,项目名称:B2HANDLE,代码行数:69,代码来源:handleclient_2_read_patched_unit_test.py

示例2: EUDATHandleClientReadaccessPatchedTestCase

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import is_10320LOC_empty [as 别名]

#.........这里部分代码省略.........

    @patch("b2handle.handleclient.requests.get")
    def test_check_if_username_exists_inconsistent_info(self, getpatch):
        """Test exception when contradictory inputs are given."""

        # Test variables
        handlerecord_string = open("resources/handlerecord_for_reading.json").read()
        testhandle = "who/cares"

        # Define the replacement for the patched method:
        mock_response = MockResponse(success=True, content=handlerecord_string)
        getpatch.return_value = mock_response

        # Call method and check result:
        with self.assertRaises(GenericHandleError):
            self.inst.check_if_username_exists(testhandle)

    @patch("b2handle.handleclient.requests.get")
    def test_check_if_username_exists_it_doesnot(self, getpatch):
        """Test exception"""

        # Test variables
        testhandle = "who/cares"

        # Define the replacement for the patched method:
        mock_response = MockResponse(notfound=True)
        getpatch.return_value = mock_response

        # Call method and check result:
        with self.assertRaises(HandleNotFoundException):
            self.inst.check_if_username_exists(testhandle)

    @patch("b2handle.handleclient.requests.get")
    def test_is_10320LOC_empty_handle_does_not_exist(self, getpatch):
        """Test exception"""

        # Test variables
        testhandle = "who/cares"

        # Define the replacement for the patched method:
        mock_response = MockResponse(notfound=True)
        getpatch.return_value = mock_response

        # Call method and check result:
        with self.assertRaises(HandleNotFoundException):
            self.inst.is_10320LOC_empty(testhandle)

    @patch("b2handle.handleclient.requests.get")
    def test_is_url_contained_in_10320LOC_handle_does_not_exist(self, getpatch):
        """Test exception"""

        # Test variables
        testhandle = "who/cares"
        one_url = "http://bla"
        list_of_urls = ["http://bla", "http://foo.foo"]

        # Define the replacement for the patched method:
        mock_response = MockResponse(notfound=True)
        getpatch.return_value = mock_response

        # Call method and check result:
        with self.assertRaises(HandleNotFoundException):
            self.inst.is_URL_contained_in_10320LOC(testhandle, url=one_url)
        with self.assertRaises(HandleNotFoundException):
            self.inst.is_URL_contained_in_10320LOC(testhandle, url=list_of_urls)
开发者ID:TonyWildish,项目名称:B2HANDLE,代码行数:69,代码来源:handleclient_readaccess_patched_test.py

示例3: EUDATHandleClientReadaccessFakedTestCase

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import is_10320LOC_empty [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(len(indices),1,
            'There is more or less than 1 index!')
        self.assertEqual(indices[0], 3,
            'The index of "test1" is not 3.')

    def test_get_indices_for_key_duplicatekey(self):
        """Test getting the indices for a duplicate key."""

        handlerecord = json.load(open('resources/handlerecord_for_reading.json'))
        handle = handlerecord['handle']

        indices = self.inst.get_handlerecord_indices_for_key('testdup', handlerecord['values'])
        self.assertEqual(len(indices),2,
            'There is more or less than 2 indices!')
        self.assertIn(5, indices,
            '5 is not in indices for key "testdup".')
        self.assertIn(6, indices,
            '6 is not in indices for key "testdup".')

    def test_get_indices_for_key_inexistentkey(self):
        """Test getting the indices for an inexistent key."""

        handlerecord = json.load(open('resources/handlerecord_for_reading.json'))
        handle = handlerecord['handle']

        indices = self.inst.get_handlerecord_indices_for_key('test100', handlerecord['values'])
        self.assertEqual(len(indices),0,
            'There is more than 0 index!')
        self.assertEqual(indices,[],
            'Indices should be an empty list!')

# is_10320LOC_empty

    def test_is_10320LOC_empty_notempty(self):
        """Test if presence of 10320/LOC is detected."""
        handlerecord = json.load(open('resources/handlerecord_with_10320LOC.json'))
        handle = handlerecord['handle']
        answer = self.inst.is_10320LOC_empty(handle, handlerecord)

        self.assertFalse(answer,
            'The record contains a 10320/LOC, but the is_empty does not return False.')

    def test_is_10320LOC_empty_no10320LOC(self):
        """Test if absence of 10320/LOC is detected."""
        handlerecord = json.load(open('resources/handlerecord_without_10320LOC.json'))
        handle = handlerecord['handle']
        answer = self.inst.is_10320LOC_empty(handle, handlerecord)

        self.assertTrue(answer,
            'The record contains no 10320/LOC, but the is_empty does not return True.')

    def test_is_10320LOC_empty_empty10320LOC(self):
        """Test if emptiness of 10320/LOC is detected."""
        handlerecord = json.load(open('resources/handlerecord_with_empty_10320LOC.json'))
        handle = handlerecord['handle']
        answer = self.inst.is_10320LOC_empty(handle, handlerecord)

        self.assertTrue(answer,
            'The record contains an empty 10320/LOC, but the is_empty does not return True.')

    # is_URL_contained_in_1302loc

    def test_is_URL_contained_in_10320LOC_true(self):
        """Test if presence of URL is found in 10320/LOC."""
        handlerecord = json.load(open('resources/handlerecord_with_10320LOC.json'))
        handle = handlerecord['handle']
开发者ID:merretbuurman,项目名称:B2HANDLE,代码行数:70,代码来源:handleclient_readaccess_faked_test.py

示例4: EUDATHandleClientReadaccessFaked10320LOCTestCase

# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import is_10320LOC_empty [as 别名]
class EUDATHandleClientReadaccessFaked10320LOCTestCase(unittest.TestCase):
    '''Testing methods that read the 10320/LOC entry.'''

    def setUp(self):
        self.inst = EUDATHandleClient()

    def tearDown(self):
        pass

    # is_10320LOC_empty

    def test_is_10320LOC_empty_notempty(self):
        """Test if presence of 10320/LOC is detected."""
        handlerecord = RECORD_WITH
        handle = handlerecord['handle']
        answer = self.inst.is_10320LOC_empty(handle, handlerecord)

        self.assertFalse(answer,
            'The record contains a 10320/LOC, but the is_empty does not return False.')

    def test_is_10320LOC_empty_no10320LOC(self):
        """Test if absence of 10320/LOC is detected."""
        handlerecord = RECORD_WITHOUT
        handle = handlerecord['handle']
        answer = self.inst.is_10320LOC_empty(handle, handlerecord)

        self.assertTrue(answer,
            'The record contains no 10320/LOC, but the is_empty does not return True.')

    def test_is_10320LOC_empty_empty10320LOC(self):
        """Test if emptiness of 10320/LOC is detected."""
        handlerecord = RECORD_WITH_EMPTY
        handle = handlerecord['handle']
        answer = self.inst.is_10320LOC_empty(handle, handlerecord)

        self.assertTrue(answer,
            'The record contains an empty 10320/LOC, but the is_empty does not return True.')

    # is_URL_contained_in_1302loc

    def test_is_URL_contained_in_10320LOC_true(self):
        """Test if presence of URL is found in 10320/LOC."""
        handlerecord = RECORD_WITH
        handle = handlerecord['handle']
        answer = self.inst.is_URL_contained_in_10320LOC(handle,
                                                        'http://foo.bar',
                                                        handlerecord)
        val = self.inst.get_value_from_handle(handle, '10320/LOC', handlerecord)
        self.assertTrue(answer,
            'The URL exists in the 10320/LOC, and still the method does not return True:\n'+str(val))

    def test_is_URL_contained_in_10320LOC_false(self):
        """Test if absence of URL is detected in existing 10320/LOC."""
        handlerecord = RECORD_WITH
        handle = handlerecord['handle']
        answer = self.inst.is_URL_contained_in_10320LOC(handle,
                                                        'http://bar.bar',
                                                        handlerecord)
        self.assertFalse(answer,
            'The 10320/LOC does not contain the URL, and still the method does not return False.')

    def test_is_URL_contained_in_inexistent_10320LOC(self):
        """Test if absence of URL is detected if 10320/LOC does not exist."""
        handlerecord = RECORD_WITHOUT
        handle = handlerecord['handle']
        answer = self.inst.is_URL_contained_in_10320LOC(handle,
                                                        'http://whatever.foo',
                                                        handlerecord)
        self.assertFalse(answer,
            'The 10320/LOC does not exist, and still the method does not return False.')

    def test_is_URL_contained_in_empty_10320LOC(self):
        """Test if absence of URL is detected if 10320/LOC is empty."""
        handlerecord = RECORD_WITH_EMPTY
        handle = handlerecord['handle']
        answer = self.inst.is_URL_contained_in_10320LOC(handle,
                                                        'http://whatever.foo',
                                                        handlerecord)
        self.assertFalse(answer,
            'The 10320/LOC is empty, and still the method does not return False.')
开发者ID:EUDAT-B2SAFE,项目名称:B2HANDLE,代码行数:82,代码来源:handleclient_10320loc_read_patched_unit_test.py


注:本文中的b2handle.handleclient.EUDATHandleClient.is_10320LOC_empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。