Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 19, 2024
1 parent 1225118 commit b26c443
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/functional/test_network_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
from pathlib import Path
from typing import ClassVar
from unittest import mock

import pytest
Expand Down Expand Up @@ -206,6 +207,31 @@ def test_providers(ethereum):
assert "node" in providers


def test_providers_NAME_defined(mocker):
"""
Show that when a provider plugin used the NAME ClassVar,
the provider's name is that instead of the plugin's name.
"""
ecosystem_name = "my-ecosystem"
network_name = "my-network"
provider_name = "my-provider"

class MyProvider(ProviderAPI):
NAME: ClassVar[str] = provider_name

class MyNetwork(NetworkAPI):
def _get_plugin_providers(self):
yield "my-provider-plugin", (ecosystem_name, network_name, MyProvider)

class MyEcosystem(Ethereum):
pass

ecosystem = MyEcosystem(name=ecosystem_name)
network = MyNetwork(name=network_name, ecosystem=ecosystem)
actual = list(network.providers)
assert actual == [provider_name] # And not "my-provider-plugin"


def test_providers_custom_network(project, custom_networks_config_dict, ethereum):
with project.temp_config(**custom_networks_config_dict):
network = ethereum.apenet
Expand Down

0 comments on commit b26c443

Please sign in to comment.