Skip to content

Commit

Permalink
Fix import from pytest-ethereum error
Browse files Browse the repository at this point in the history
  • Loading branch information
njgheorghita committed Jul 9, 2019
1 parent c6cbb8f commit faaabd6
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 19 deletions.
1 change: 0 additions & 1 deletion ethpm/__init__.py
Expand Up @@ -16,7 +16,6 @@
ASSETS_DIR = ETHPM_DIR / "assets"
SPEC_DIR: Path = ASSETS_DIR / "spec"
ETHPM_SPEC_DIR = ETHPM_DIR.parent / "ethpm-spec"
V2_PACKAGES_DIR = ASSETS_DIR

from .package import Package # noqa: F401
from .backends.registry import RegistryURI # noqa: F401
8 changes: 4 additions & 4 deletions ethpm/validation/manifest.py
Expand Up @@ -12,8 +12,8 @@
)

from ethpm import (
ASSETS_DIR,
SPEC_DIR,
V2_PACKAGES_DIR,
)
from ethpm.exceptions import (
ValidationError,
Expand Down Expand Up @@ -116,11 +116,11 @@ def validate_manifest_deployments(manifest: Dict[str, Any]) -> None:

def validate_manifest_exists(manifest_id: str) -> None:
"""
Validate that manifest with manifest_id exists in V2_PACKAGES_DIR
Validate that manifest with manifest_id exists in ASSETS_DIR
"""
if not (V2_PACKAGES_DIR / manifest_id).is_file():
if not (ASSETS_DIR / manifest_id).is_file():
raise ValidationError(
f"Manifest not found in V2_PACKAGES_DIR with id: {manifest_id}"
f"Manifest not found in ASSETS_DIR with id: {manifest_id}"
)


Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -84,6 +84,7 @@
python_requires='>=3.6,<4',
extras_require=extras_require,
py_modules=['web3', 'ens', 'ethpm'],
entry_points={"pytest11": ["pytest_ethereum = web3.tools.pytest_ethereum.plugins"]},
license="MIT",
zip_safe=False,
keywords='ethereum',
Expand Down
6 changes: 3 additions & 3 deletions tests/ethpm/backends/test_ipfs_backends.py
Expand Up @@ -9,7 +9,7 @@
)

from ethpm import (
V2_PACKAGES_DIR,
ASSETS_DIR,
)
from ethpm.backends.ipfs import (
DummyIPFSBackend,
Expand All @@ -22,7 +22,7 @@
INFURA_GATEWAY_MULTIADDR,
)

OWNED_MANIFEST_PATH = V2_PACKAGES_DIR / "owned" / "1.0.0.json"
OWNED_MANIFEST_PATH = ASSETS_DIR / "owned" / "1.0.0.json"


@pytest.fixture
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_pin_assets_to_dummy_backend(dummy_ipfs_backend):
assert asset_data["Hash"] == "QmaRFTSyy6kifqpJBVF2dndQEduDE9s8kafNaRh6UTYKhj"
assert asset_data["Size"] == "434"
# Test pinning a directory
dir_data = backend.pin_assets(V2_PACKAGES_DIR / "standard-token" / "contracts")
dir_data = backend.pin_assets(ASSETS_DIR / "standard-token" / "contracts")
dir_names = [result["Name"] for result in dir_data]
dir_hashes = [result["Hash"] for result in dir_data]
dir_sizes = [result["Size"] for result in dir_data]
Expand Down
9 changes: 4 additions & 5 deletions tests/ethpm/conftest.py
Expand Up @@ -8,7 +8,6 @@

from ethpm import (
ASSETS_DIR,
V2_PACKAGES_DIR,
Package,
)
from ethpm._utils.chains import (
Expand Down Expand Up @@ -48,13 +47,13 @@ def package_names():

@pytest.fixture(params=PACKAGE_NAMES)
def all_strict_manifests(request):
return (V2_PACKAGES_DIR / request.param[0] / "1.0.0.json").read_text().rstrip("\n")
return (ASSETS_DIR / request.param[0] / "1.0.0.json").read_text().rstrip("\n")


@pytest.fixture(params=PACKAGE_NAMES)
def all_pretty_manifests(request):
return (
(V2_PACKAGES_DIR / request.param[0] / "1.0.0-pretty.json")
(ASSETS_DIR / request.param[0] / "1.0.0-pretty.json")
.read_text()
.rstrip("\n")
)
Expand Down Expand Up @@ -104,7 +103,7 @@ def safe_math_manifest(get_manifest):
@pytest.fixture
def piper_coin_manifest():
return json.loads(
(V2_PACKAGES_DIR / "piper-coin" / "1.0.0-pretty.json").read_text()
(ASSETS_DIR / "piper-coin" / "1.0.0-pretty.json").read_text()
)


Expand Down Expand Up @@ -139,7 +138,7 @@ def _get_factory(package, factory_name):

@pytest.fixture
def owned_contract():
return (V2_PACKAGES_DIR / "owned" / "contracts" / "Owned.sol").read_text()
return (ASSETS_DIR / "owned" / "contracts" / "Owned.sol").read_text()


@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions tests/ethpm/integration/test_ipfs_integration.py
Expand Up @@ -5,7 +5,7 @@
)

from ethpm import (
V2_PACKAGES_DIR,
ASSETS_DIR,
)
from ethpm.backends.ipfs import (
InfuraIPFSBackend,
Expand All @@ -16,7 +16,7 @@
builder as b,
)

OWNED_MANIFEST_PATH = V2_PACKAGES_DIR / "owned" / "1.0.0.json"
OWNED_MANIFEST_PATH = ASSETS_DIR / "owned" / "1.0.0.json"


def test_local_ipfs_backend_integration_round_trip(monkeypatch):
Expand Down
2 changes: 1 addition & 1 deletion tests/ethpm/tools/test_builder.py
Expand Up @@ -47,7 +47,7 @@
version,
write_to_disk,
)
from pytest_ethereum.linker import (
from web3.tools.pytest_ethereum.linker import (
deploy,
link,
linker,
Expand Down
4 changes: 2 additions & 2 deletions tests/ethpm/validation/test_manifest.py
@@ -1,7 +1,7 @@
import pytest

from ethpm import (
V2_PACKAGES_DIR,
ASSETS_DIR,
)
from ethpm.exceptions import (
ValidationError,
Expand Down Expand Up @@ -56,7 +56,7 @@ def test_validate_raw_manifest_format_invalidates_invalid_manifests(tmpdir, mani

def test_validate_manifest_exists_validates():
assert (
validate_manifest_exists(V2_PACKAGES_DIR / "safe-math-lib" / "1.0.0.json")
validate_manifest_exists(ASSETS_DIR / "safe-math-lib" / "1.0.0.json")
is None
)

Expand Down
2 changes: 1 addition & 1 deletion web3/tools/__init__.py
@@ -1 +1 @@
from .pytest_ethereum import linker # noqa: F401
from .pytest_ethereum import deployer, linker # noqa: F401
Empty file.
30 changes: 30 additions & 0 deletions web3/tools/pytest_ethereum/plugins.py
@@ -0,0 +1,30 @@
import json
from pathlib import Path
from typing import Callable

from ethpm import Package
import pytest
from web3 import Web3

from web3.tools.pytest_ethereum.deployer import Deployer


# @pytest.fixture
# def w3() -> Web3:
# w3 = Web3(Web3.EthereumTesterProvider())
# return w3


@pytest.fixture
def deployer(w3: Web3) -> Callable[[Path], Deployer]:
"""
Returns a `Deployer` instance composed from a `Package` instance
generated from the manifest located at the provided `path` folder.
"""

def _deployer(path: Path) -> Deployer:
manifest = json.loads(path.read_text())
package = Package(manifest, w3)
return Deployer(package)

return _deployer

0 comments on commit faaabd6

Please sign in to comment.