Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/tests/test_objstorage_azure.py
# Copyright (C) 2016-2018 The Software Heritage developers | # Copyright (C) 2016-2018 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import unittest | import unittest | ||||
from collections import defaultdict | from collections import defaultdict | ||||
from unittest.mock import patch | from unittest.mock import patch | ||||
from typing import Any, Dict | |||||
from azure.common import AzureMissingResourceHttpError | from azure.common import AzureMissingResourceHttpError | ||||
from swh.model.hashutil import hash_to_hex | from swh.model.hashutil import hash_to_hex | ||||
from swh.objstorage import get_objstorage | from swh.objstorage import get_objstorage | ||||
from .objstorage_testing import ObjStorageTestFixture | from .objstorage_testing import ObjStorageTestFixture | ||||
class MockBlob(): | class MockBlob(): | ||||
""" Libcloud object mock that replicates its API """ | """ Libcloud object mock that replicates its API """ | ||||
def __init__(self, name, content): | def __init__(self, name, content): | ||||
self.name = name | self.name = name | ||||
self.content = content | self.content = content | ||||
class MockBlockBlobService(): | class MockBlockBlobService(): | ||||
"""Mock internal azure library which AzureCloudObjStorage depends upon. | """Mock internal azure library which AzureCloudObjStorage depends upon. | ||||
""" | """ | ||||
data = {} | data = {} # type: Dict[str, Any] | ||||
vlorentz: It should be a protected attribute | |||||
Done Inline ActionsI'm not sure what you mean here. You want a heading "_" added, a getter, or what? zack: I'm not sure what you mean here. You want a heading "_" added, a getter, or what? | |||||
def __init__(self, account_name, account_key, **kwargs): | def __init__(self, account_name, account_key, **kwargs): | ||||
# do not care for the account_name and the api_secret_key here | # do not care for the account_name and the api_secret_key here | ||||
self.data = defaultdict(dict) | self.data = defaultdict(dict) | ||||
def get_container_properties(self, container_name): | def get_container_properties(self, container_name): | ||||
self.data[container_name] | self.data[container_name] | ||||
return container_name in self.data | return container_name in self.data | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |
It should be a protected attribute