Example #1
0
    def test_create_dirlist_dict_empty(self):
        from eudat_http_api.http_storage import cdmi

        with patch('eudat_http_api.metadata.stat', return_value={}):
            result = list(cdmi._create_dirlist_gen([], '/home/'))
            assert len(result) == 2
            entry_info = self.get_dirlist_entry_info(result)
            assert entry_info[0]['path'] == '/home/'
            assert entry_info[0]['name'] == '.'
            assert entry_info[1]['path'] == '/'
            assert entry_info[1]['name'] == '..'

            result = list(cdmi._create_dirlist_gen([], '/home'))
            assert len(result) == 2
            entry_info = self.get_dirlist_entry_info(result)
            assert entry_info[0]['path'] == '/home'
            assert entry_info[0]['name'] == '.'
            assert entry_info[1]['path'] == '/'
            assert entry_info[1]['name'] == '..'

            result = list(cdmi._create_dirlist_gen([], '/'))
            assert len(result) == 2
            entry_info = self.get_dirlist_entry_info(result)
            assert entry_info[0]['path'] == '/'
            assert entry_info[0]['name'] == '.'
            assert entry_info[1]['path'] == ''
            assert entry_info[1]['name'] == '..'
Example #2
0
    def test_create_dirlist_dict_one_file(self):
        from eudat_http_api.http_storage import cdmi
        from eudat_http_api.http_storage import storage

        with patch('eudat_http_api.metadata.stat', return_value={}):
            result = list(cdmi._create_dirlist_gen(
                [storage.StorageDir('test', '/home/test')],
                '/home/'))
            assert len(result) == 3
            entry_info = self.get_dirlist_entry_info(result)
            assert entry_info[0]['name'] == '.'
            assert entry_info[1]['name'] == '..'
            assert entry_info[2]['path'] == '/home/test'
            assert entry_info[2]['name'] == 'test'