Skip to content

Commit

Permalink
Merge pull request #32 from grking8/move-tests
Browse files Browse the repository at this point in the history
Move tests
  • Loading branch information
grking8 committed Feb 10, 2019
2 parents f687a01 + d3be2dc commit 6f6de4a
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion aiostorage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .exceptions import (BlobStorageMissingCredentialsError,
BlobStorageUnrecognizedProviderError,)

__version__ = '0.1.15'
__version__ = '0.1.16'

__all__ = ['BlobStorage', 'BlobStorageUnrecognizedProviderError',
'BlobStorageMissingCredentialsError']
Empty file added aiostorage/tests/__init__.py
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pytest

from aiostorage.providers.backblaze import Backblaze
from ....providers.backblaze import Backblaze

VIDEOS_PATH = os.path.join('tests', 'data', 'videos')
VIDEOS_PATH = os.path.join('aiostorage', 'tests', 'data', 'videos')
BUCKET_ID = os.environ['BACKBLAZE_TEST_BUCKET_ID']


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from aiostorage.providers.backblaze import Backblaze
from ...providers.backblaze import Backblaze


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import asynctest
import pytest

from aiostorage import (BlobStorage, BlobStorageMissingCredentialsError,
BlobStorageUnrecognizedProviderError, )
from aiostorage.providers import PROVIDERS
from aiostorage.providers.backblaze import Backblaze
from aiostorage.providers.exceptions import (ProviderAuthorizationError,
ProviderFileUploadError)
from .. import (BlobStorage, BlobStorageMissingCredentialsError,
BlobStorageUnrecognizedProviderError, )
from ..providers import backblaze, exceptions, PROVIDERS


@pytest.fixture
Expand Down Expand Up @@ -60,19 +57,21 @@ def fake_provider_upload_file_side_effect(bucket_id, file_to_upload,
@pytest.fixture
def mock_provider_authorize(monkeypatch):
fake_provider_authorize = asynctest.CoroutineMock(
Backblaze.authorize,
backblaze.Backblaze.authorize,
side_effect=fake_provider_authorize_side_effect
)
monkeypatch.setattr(Backblaze, 'authorize', fake_provider_authorize)
monkeypatch.setattr(
backblaze.Backblaze, 'authorize', fake_provider_authorize)
return fake_provider_authorize


@pytest.fixture
def mock_provider_upload_file(monkeypatch):
fake_provider_upload_file = asynctest.CoroutineMock(
Backblaze.upload_file,
backblaze.Backblaze.upload_file,
side_effect=fake_provider_upload_file_side_effect)
monkeypatch.setattr(Backblaze, 'upload_file', fake_provider_upload_file)
monkeypatch.setattr(
backblaze.Backblaze, 'upload_file', fake_provider_upload_file)
return fake_provider_upload_file


Expand All @@ -97,11 +96,11 @@ def fake_provider_authorize_error_side_effect():
@pytest.fixture
def mock_provider_authorize_error(monkeypatch):
fake_provider_authorize_error = asynctest.CoroutineMock(
Backblaze.authorize,
backblaze.Backblaze.authorize,
side_effect=fake_provider_authorize_error_side_effect
)
monkeypatch.setattr(
Backblaze, 'authorize', fake_provider_authorize_error)
backblaze.Backblaze, 'authorize', fake_provider_authorize_error)
return fake_provider_authorize_error


Expand All @@ -112,7 +111,7 @@ async def test_upload_file_authorization_error(
):
bucket_id = '3432'
file_to_upload = {'content_type': 'video/mp4', 'path': 'hello.mp4'}
with pytest.raises(ProviderAuthorizationError):
with pytest.raises(exceptions.ProviderAuthorizationError):
await storage.upload_file(bucket_id, file_to_upload)


Expand All @@ -124,11 +123,11 @@ def fake_provider_upload_file_error_side_effect(bucket_id, file_to_upload,
@pytest.fixture
def mock_provider_upload_file_error(monkeypatch):
fake_provider_upload_file_error = asynctest.CoroutineMock(
Backblaze.upload_file,
backblaze.Backblaze.upload_file,
side_effect=fake_provider_upload_file_error_side_effect
)
monkeypatch.setattr(
Backblaze, 'upload_file', fake_provider_upload_file_error)
backblaze.Backblaze, 'upload_file', fake_provider_upload_file_error)
return fake_provider_upload_file_error


Expand All @@ -140,5 +139,5 @@ async def test_upload_file_upload_file_error(
):
bucket_id = '3432'
file_to_upload = {'content_type': 'video/mp4', 'path': 'hello.mp4'}
with pytest.raises(ProviderFileUploadError):
with pytest.raises(exceptions.ProviderFileUploadError):
await storage.upload_file(bucket_id, file_to_upload)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import-order-style = smarkets
application-import-names = aiostorage

[tool:pytest]
addopts = -vv --ignore=tests/providers/apis/ --cov=aiostorage tests/
addopts = -vv --ignore=aiostorage/tests/providers/apis/ --cov=aiostorage aiostorage/tests/
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'asynchronously. The aim is to support multiple object storage '
'providers, e.g. Google Cloud, Backblaze, etc.'
)
version = '0.1.15'
version = '0.1.16'
classifiers = [
'Development Status :: 1 - Planning',

Expand Down

0 comments on commit 6f6de4a

Please sign in to comment.