-
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.
- Loading branch information
Showing
2 changed files
with
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
import unittest | ||
from unittest import TestCase | ||
|
||
from rpft.rapidpro.models.actions import EnterFlowAction | ||
from rpft.rapidpro.models.common import generate_field_key | ||
from rpft.rapidpro.models.exceptions import RapidProActionError | ||
|
||
|
||
class TestActions(unittest.TestCase): | ||
def setUp(self) -> None: | ||
pass | ||
class TestActions(TestCase): | ||
|
||
def test_enter_flow_node(self): | ||
enter_flow_node = EnterFlowAction(flow_name="test_flow", flow_uuid="fake-uuid") | ||
render_output = enter_flow_node.render() | ||
self.assertEqual(render_output["type"], "enter_flow") | ||
self.assertEqual(render_output["flow"]["name"], "test_flow") | ||
self.assertEqual(render_output["flow"]["uuid"], "fake-uuid") | ||
out = EnterFlowAction(flow_name="test_flow", flow_uuid="fake-uuid").render() | ||
|
||
self.assertEqual(out["type"], "enter_flow") | ||
self.assertEqual(out["flow"]["name"], "test_flow") | ||
self.assertEqual(out["flow"]["uuid"], "fake-uuid") | ||
|
||
|
||
class TestFieldKeyGenerator(TestCase): | ||
|
||
def test_generate_key_from_field_name(self): | ||
self.assertEqual( | ||
generate_field_key(" Field Name "), | ||
"field_name", | ||
) | ||
|
||
def test_generate_keys_up_to_max_length_limit(self): | ||
self.assertIsNotNone(generate_field_key("x" * 36)) | ||
|
||
def test_fail_if_max_key_length_exceeded(self): | ||
with self.assertRaises(RapidProActionError): | ||
generate_field_key("z" * 37) | ||
|
||
def test_fail_if_key_does_not_contain_letters(self): | ||
with self.assertRaises(RapidProActionError): | ||
generate_field_key("123") |