-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from runemalm/feature/constructor-args
Feature/constructor args
- Loading branch information
Showing
17 changed files
with
370 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
from typing import Any, Dict | ||
|
||
from dependency_injection.scope import Scope | ||
|
||
|
||
class Registration(): | ||
|
||
def __init__(self, interface, class_, scope: Scope): | ||
def __init__(self, interface, class_, scope: Scope, constructor_args: Dict[str, Any] = None): | ||
self.interface = interface | ||
self.class_ = class_ | ||
self.scope = scope | ||
self.constructor_args = constructor_args or {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/unit_test/container/register/test_register_with_args.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from dependency_injection.container import DependencyContainer | ||
from unit_test.unit_test_case import UnitTestCase | ||
|
||
|
||
class TestRegisterWithArgs(UnitTestCase): | ||
|
||
def test_register_with_constructor_args( | ||
self, | ||
): | ||
# arrange | ||
class Vehicle: | ||
pass | ||
|
||
class Car(Vehicle): | ||
pass | ||
|
||
dependency_container = DependencyContainer.get_instance() | ||
interface = Vehicle | ||
dependency_class = Car | ||
|
||
# act + assert (no exception) | ||
dependency_container.register_transient(interface, dependency_class, constructor_args={"color": "red", "mileage": 3800}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.