Example #1
0
    def test_advanced_xform_create_owner_id_explicitly_set(self):
        """When owner_id is explicitly set, don't autoset"""
        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_properties': {'owner_id': 'owner'},
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'child'
                },
            ]
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_properties': {'owner_id': 'owner'},
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'extension'
                },
            ]
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_properties': {'owner_id': 'owner'},
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        advanced_open_action = AdvancedOpenCaseAction()
        self.assertTrue(autoset_owner_id_for_advanced_action(advanced_open_action))
Example #2
0
    def test_advanced_xform_create_owner_id_explicitly_set(self):
        """When owner_id is explicitly set, don't autoset"""
        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_properties': {'owner_id': 'owner'},
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'child'
                },
            ]
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_properties': {'owner_id': 'owner'},
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'extension'
                },
            ]
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_properties': {'owner_id': 'owner'},
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        advanced_open_action = AdvancedOpenCaseAction()
        self.assertTrue(autoset_owner_id_for_advanced_action(advanced_open_action))
 def _test_relationships(relationships, expected):
     advanced_open_action = AdvancedOpenCaseAction.wrap({'case_indices': [{
         'tag': 'tag{}'.format(i),
         'reference_id': 'case',
         'relationship': r,
     } for i, r in enumerate(relationships)]})
     self.assertEqual(autoset_owner_id_for_advanced_action(advanced_open_action), expected)
    def test_advanced_xform_create_owner_id_explicitly_set(self):
        """When owner_id is explicitly set, don't autoset"""
        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_properties': {"owner_id": {
                                "doc_type": "ConditionalCaseUpdate",
                                "question_path": "owner",
                                "update_mode": "always"}
                                },
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'child'
                },
            ]
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_properties': {"owner_id": {
                                "doc_type": "ConditionalCaseUpdate",
                                "question_path": "owner",
                                "update_mode": "always"}
                                },
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'extension'
                },
            ]
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_properties': {"owner_id": {
                                "doc_type": "ConditionalCaseUpdate",
                                "question_path": "owner",
                                "update_mode": "always"}
                                },
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        advanced_open_action = AdvancedOpenCaseAction()
        self.assertTrue(autoset_owner_id_for_advanced_action(advanced_open_action))
Example #5
0
 def test_parent_tag(self):
     """
     AdvancedOpenCaseAction migration should create a CaseIndex if a parent tag is given
     """
     action = AdvancedOpenCaseAction.wrap({
         'case_type': 'spam',
         'case_tag': 'ham',
         'parent_tag': 'eggs',
     })
     self.assertEqual(action.case_indices[0].tag, 'eggs')
Example #6
0
 def test_parent_tag(self):
     """
     AdvancedOpenCaseAction migration should create a CaseIndex if a parent tag is given
     """
     action = AdvancedOpenCaseAction.wrap({
         'case_type': 'spam',
         'case_tag': 'ham',
         'parent_tag': 'eggs',
     })
     self.assertEqual(action.case_indices[0].tag, 'eggs')
Example #7
0
 def test_advanced_action_no_parent_tag(self):
     """
     AdvancedOpenCaseAction migration should not create a CaseIndex without parent_tag
     """
     action = AdvancedOpenCaseAction.wrap({
         'case_type': 'spam',
         'case_tag': 'ham',
         'parent_reference_id': 'spam',
         'relationship': 'extension',
     })
     self.assertEqual(len(action.case_indices), 0)
Example #8
0
 def test_defaults(self):
     """
     AdvancedOpenCaseAction migration should create a CaseIndex with property defaults
     """
     action = AdvancedOpenCaseAction.wrap({
         'case_type': 'spam',
         'case_tag': 'ham',
         'parent_tag': 'eggs',
     })
     self.assertEqual(action.case_indices[0].reference_id, 'parent')
     self.assertEqual(action.case_indices[0].relationship, 'child')
Example #9
0
 def test_advanced_action_no_parent_tag(self):
     """
     AdvancedOpenCaseAction migration should not create a CaseIndex without parent_tag
     """
     action = AdvancedOpenCaseAction.wrap({
         'case_type': 'spam',
         'case_tag': 'ham',
         'parent_reference_id': 'spam',
         'relationship': 'extension',
     })
     self.assertEqual(len(action.case_indices), 0)
Example #10
0
 def test_defaults(self):
     """
     AdvancedOpenCaseAction migration should create a CaseIndex with property defaults
     """
     action = AdvancedOpenCaseAction.wrap({
         'case_type': 'spam',
         'case_tag': 'ham',
         'parent_tag': 'eggs',
     })
     self.assertEqual(action.case_indices[0].reference_id, 'parent')
     self.assertEqual(action.case_indices[0].relationship, 'child')
Example #11
0
    def test_advanced_xform_create_owner_id_with_without_extensions(self):
        """ Owner id should be automatically set if there are any non-extension indices"""

        # Only extensions
        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'extension',
                },
                {
                    'tag': 'father',
                    'reference_id': 'case',
                    'relationship': 'extension',
                }
            ]
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        # Extension and children
        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'extension',
                },
                {
                    'tag': 'father',
                    'reference_id': 'case',
                    'relationship': 'child',
                }
            ]
        })
        self.assertTrue(autoset_owner_id_for_advanced_action(advanced_open_action))

        # No indices
        advanced_open_action = AdvancedOpenCaseAction()
        self.assertTrue(autoset_owner_id_for_advanced_action(advanced_open_action))
Example #12
0
    def test_advanced_xform_create_owner_id_with_without_extensions(self):
        """ Owner id should be automatically set if there are any non-extension indices"""

        # Only extensions
        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'extension',
                },
                {
                    'tag': 'father',
                    'reference_id': 'case',
                    'relationship': 'extension',
                }
            ]
        })
        self.assertFalse(autoset_owner_id_for_advanced_action(advanced_open_action))

        # Extension and children
        advanced_open_action = AdvancedOpenCaseAction.wrap({
            'case_indices': [
                {
                    'tag': 'mother',
                    'reference_id': 'case',
                    'relationship': 'extension',
                },
                {
                    'tag': 'father',
                    'reference_id': 'case',
                    'relationship': 'child',
                }
            ]
        })
        self.assertTrue(autoset_owner_id_for_advanced_action(advanced_open_action))

        # No indices
        advanced_open_action = AdvancedOpenCaseAction()
        self.assertTrue(autoset_owner_id_for_advanced_action(advanced_open_action))
Example #13
0
 def test_properties(self):
     """
     AdvancedOpenCaseAction migration should create a CaseIndex with given properties
     """
     action = AdvancedOpenCaseAction.wrap({
         'case_type': 'spam',
         'case_tag': 'ham',
         'parent_tag': 'eggs',
         'parent_reference_id': 'spam',
         'relationship': 'extension',
     })
     self.assertEqual(action.case_indices[0].tag, 'eggs')
     self.assertEqual(action.case_indices[0].reference_id, 'spam')
     self.assertEqual(action.case_indices[0].relationship, 'extension')
Example #14
0
 def test_properties(self):
     """
     AdvancedOpenCaseAction migration should create a CaseIndex with given properties
     """
     action = AdvancedOpenCaseAction.wrap({
         'case_type': 'spam',
         'case_tag': 'ham',
         'parent_tag': 'eggs',
         'parent_reference_id': 'spam',
         'relationship': 'extension',
     })
     self.assertEqual(action.case_indices[0].tag, 'eggs')
     self.assertEqual(action.case_indices[0].reference_id, 'spam')
     self.assertEqual(action.case_indices[0].relationship, 'extension')