-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit message will require attention...
- Loading branch information
Showing
13 changed files
with
120 additions
and
15 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
Empty file.
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,20 @@ | ||
from dataclasses import dataclass, field | ||
from typing import Any, Optional | ||
|
||
|
||
@dataclass | ||
class CallyService: | ||
name: str | ||
environment: str | ||
|
||
|
||
@dataclass | ||
class CallyStackService(CallyService): | ||
providers: dict = field(default_factory=dict) | ||
stack_vars: dict = field(default_factory=dict) | ||
|
||
def get_provider_vars(self, provider: str) -> dict: | ||
return self.providers.get(provider, {}) | ||
|
||
def get_stack_var(self, var: str, default: Optional[Any] = None) -> Any: | ||
return self.stack_vars.get(var, default) |
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
Empty file.
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,36 @@ | ||
from cally.cli.config.types import CallyService, CallyStackService | ||
|
||
from .. import CallyTestHarness | ||
|
||
|
||
class TestCallyService(CallyTestHarness): | ||
def test_name(self): | ||
service = CallyService(name='snoopy', environment='yard') | ||
self.assertEqual(service.name, 'snoopy') | ||
|
||
def test_environment(self): | ||
service = CallyService(name='snoopy', environment='yard') | ||
self.assertEqual(service.name, 'snoopy') | ||
|
||
|
||
class TestCallyStackService(CallyTestHarness): | ||
def test_provider_empty(self): | ||
service = CallyStackService(name='snoopy', environment='yard') | ||
self.assertDictEqual(service.get_provider_vars('test'), {}) | ||
|
||
def test_get_provider_vars(self): | ||
providers = {'test': {'foo': 'bar', 'bar': 'foo'}, 'another': {'bar': 'foo'}} | ||
service = CallyStackService( | ||
name='snoopy', environment='yard', providers=providers | ||
) | ||
self.assertDictEqual( | ||
service.get_provider_vars('test'), {'foo': 'bar', 'bar': 'foo'} | ||
) | ||
|
||
def test_stack_var_empty(self): | ||
service = CallyStackService(name='snoopy', environment='yard') | ||
self.assertIsNone(service.get_stack_var('test')) | ||
|
||
def test_stack_var_default(self): | ||
service = CallyStackService(name='snoopy', environment='yard') | ||
self.assertEqual(service.get_stack_var('test', 'charlie'), 'charlie') |
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