Skip to content

Commit

Permalink
Add first pass typing and tests for configs
Browse files Browse the repository at this point in the history
  • Loading branch information
abegong committed Aug 20, 2019
1 parent 4137ae2 commit 8ec46ce
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
2 changes: 1 addition & 1 deletion great_expectations/actions/actions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .types import (
BasicValidationActionConfig
ActionConfig
)

class BasicValidationAction():
Expand Down
31 changes: 27 additions & 4 deletions great_expectations/actions/types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
from six import string_types

from ..types import (
LooselyTypedDotDict
LooselyTypedDotDict,
ListOf,
)

class BasicValidationActionConfig(LooselyTypedDotDict):
class ActionConfig(LooselyTypedDotDict):
_allowed_keys = set([
"module_name",
"class_name",
"kwargs"
])
_key_types = {
"module_name" : str, #This should be string_types. Need to merge in fixes to LooselyTypedDataDcit before that will work, though...
"class_name" : str, #This should be string_types. Need to merge in fixes to LooselyTypedDataDcit before that will work, though...
"kwargs" : dict,
}

class ActionSetConfig(LooselyTypedDotDict):
_allowed_keys = set([

])
"module_name",
"class_name",
"action_list",
])

_key_types = {
"module_name" : string_types,
"class_name" : string_types,
"action_list" : ListOf(ActionConfig),
}
35 changes: 32 additions & 3 deletions tests/actions/test_core_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,37 @@
BasicValidationAction,
)
from great_expectations.actions.types import (
BasicValidationActionConfig
ActionConfig,
ActionSetConfig,
)

def test_nothing():
pass

def test_action_config():

ActionConfig(**{
"module_name" : "great_expectations.actions",
"class_name": "SummarizeAndSendToWebhookAction",
"kwargs" : {
"webhook": "http://myslackwebhook.com/",
"summarization_module_name": "great_expectations.render",
"summarization_class_name": "SummarizeValidationResultsForSlack",
}
})

def test_action_set_config():

ActionSetConfig(
# coerce_types=True, #Need to merge in fixes to LooselyTypedDataDcit before this will work.
#TODO: We'll also need to modify LLTD to take a DictOf argument
**{
"action_list" : [ActionConfig(**{
"module_name" : "great_expectations.actions",
"class_name": "SummarizeAndSendToWebhookAction",
"kwargs" : {
"webhook": "http://myslackwebhook.com/",
"summarization_module_name": "great_expectations.render",
"summarization_class_name": "SummarizeValidationResultsForSlack",
}
})]
}
)

0 comments on commit 8ec46ce

Please sign in to comment.