Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
seanlip committed Jul 10, 2015
1 parent 7343c46 commit 617dde6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
8 changes: 3 additions & 5 deletions core/domain/exp_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _validate_customization_args_and_values(
validation.
Note that this may modify the given customization_args dict, if it has
extra keys. This will only log an error, but not raise an Exception.
extra or missing keys.
"""
ca_spec_names = [
ca_spec.name for ca_spec in ca_specs_to_validate_against]
Expand Down Expand Up @@ -521,7 +521,6 @@ class TriggerInstance(object):
playthrough, such as a certain number of loop-arounds on the current state,
or a certain amount of time having elapsed.
"""

def __init__(self, trigger_type, customization_args):
# A string denoting the type of trigger.
self.trigger_type = trigger_type
Expand Down Expand Up @@ -623,7 +622,7 @@ def from_dict(cls, interaction_dict):
[AnswerGroup.from_dict(h)
for h in interaction_dict['answer_groups']],
default_outcome_dict,
interaction_dict['fallbacks'])
[Fallback.from_dict(f) for f in interaction_dict['fallbacks']])

def __init__(
self, interaction_id, customization_args, answer_groups,
Expand Down Expand Up @@ -1201,7 +1200,7 @@ def create_exploration_from_dict(
state.interaction = InteractionInstance(
idict['id'], idict['customization_args'],
interaction_answer_groups, default_outcome,
idict['fallbacks'])
[Fallback.from_dict(f) for f in idict['fallbacks']])

exploration.states[state_name] = state

Expand Down Expand Up @@ -1762,7 +1761,6 @@ def _convert_states_v1_dict_to_v2_dict(cls, states_dict):
'param_changes': []
}]
}],
'fallbacks': []
},
'param_changes': []
}
Expand Down
31 changes: 29 additions & 2 deletions core/domain/exp_domain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@
dest: New state
feedback: []
param_changes: []
fallbacks: []
fallbacks:
- outcome:
dest: New state
feedback: []
param_changes: []
trigger:
customization_args:
num_submits:
value: 42
trigger_type: NthResubmission
id: null
param_changes: []
states_schema_version: %d
Expand Down Expand Up @@ -830,6 +839,24 @@ def test_yaml_import_and_export(self):
exploration.add_states(['New state'])
self.assertEqual(len(exploration.states), 2)

exploration.states['New state'].update_interaction_fallbacks([{
'trigger': {
'trigger_type': 'NthResubmission',
'customization_args': {
'num_submits': {
'value': 42,
},
},
},
'outcome': {
'dest': 'New state',
'feedback': [],
'param_changes': [],
},
}])

exploration.validate()

yaml_content = exploration.to_yaml()
self.assertEqual(yaml_content, SAMPLE_YAML_CONTENT)

Expand Down Expand Up @@ -861,7 +888,6 @@ def test_yaml_import_and_export_without_gadgets(self):
yaml_content = exploration_without_gadgets.to_yaml()
self.assertEqual(yaml_content, SAMPLE_YAML_CONTENT)


def test_yaml_import_and_export_with_gadgets(self):
"""Test from_yaml() and to_yaml() methods including gadgets."""

Expand All @@ -875,6 +901,7 @@ def test_yaml_import_and_export_with_gadgets(self):
SAMPLE_YAML_CONTENT_WITH_GADGETS)
self.assertEqual(generated_yaml_as_dict, sample_yaml_as_dict)


class SchemaMigrationUnitTests(test_utils.GenericTestBase):
"""Test migration methods for yaml content."""

Expand Down
3 changes: 2 additions & 1 deletion core/domain/trigger_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def get_trigger(cls, trigger_type):
"""Gets a trigger by its type.
Refreshes once if the trigger is not found; subsequently, throws a
KeyError."""
KeyError.
"""
if trigger_type not in cls._triggers_dict:
cls._refresh()

Expand Down
1 change: 0 additions & 1 deletion extensions/triggers/trigger_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class BaseTrigger(object):
This class is not meant to be user-editable. The only methods on it should
be get()-type methods.
"""

# Customization arg specifications for the trigger, including their
# descriptions, schemas and default values. Overridden in subclasses.
_customization_arg_specs = []
Expand Down

0 comments on commit 617dde6

Please sign in to comment.