from typing import Callable, Union

import pytest

from mininet.common.node import Node


@pytest.fixture()
def node() -> Callable[[Union[dict, None]],Node]:
    """
    Fixture closure that returns a node instantiated
    with either default params or user provided
    """

    # initialization stuff

    created_node = None

    def _node(**kwargs) -> Node:
        nonlocal created_node
        default_config = {
            "x": 1,
        }
        default_config.update(kwargs)
        created_node =  Node(**default_config)
        return created_node

    yield _node

    # teardown stuff
    # create_node.release()

@pytest.fixture()
def cluster(node) -> tuple[Node, Node, Node]:
    node_1 = node(...)
    node_2 = node(...)
    node_3 = node(...)
    return node_1, node_2, node_3


def multiply_by(x: int) -> Callable[[float], float]:
    def _multiply_by(val: float):
        return val * x
    return _multiply_by

def use_the_thing():
    multiplier = multiply_by(10)
    multiplier(2)
    multiplier(3)

def test_node(node):
    my_node = node(param_1="str")





