コード例 #1
0
 def test_get_output_name(self):
     _id = bson.ObjectId()
     service = content_types.ContentTypesService()
     with mock.patch.object(service,
                            'find_one',
                            return_value={'label': 'Test Label 123 *#$'}):
         self.assertEqual('TestLabel123', service.get_output_name(_id))
コード例 #2
0
 def test_get_output_name(self):
     _id = bson.ObjectId()
     service = content_types.ContentTypesService()
     with mock.patch.object(service,
                            "find_one",
                            return_value={"label": "Test Label 123 *#$"}):
         self.assertEqual("TestLabel123", service.get_output_name(_id))
コード例 #3
0
    def test_minlength(self):
        """Check that minlength is not modified when it is set

        check is done with required set
        """
        original = {
            "schema": {
                "body_html": {
                    "required": True,
                    "enabled": True
                },
            }
        }
        updates = copy.deepcopy(original)
        updates['schema']['body_html']['minlength'] = '99'
        content_types.ContentTypesService().on_update(updates, original)
        self.assertEqual(updates['schema']['body_html']['minlength'], '99')
コード例 #4
0
    def test_subject(self):
        """Check that subject is not set if it's not present in editor (SDESK-3745)

        If we had custom vocabularies in schema, subject was added to "schema" even if not
        present if "editor", resulting in validation error.
        """
        original = {
            "_id": "5b1a4774b10de731297716ad",
            "editor": {
                "hashtags": {
                    "order": 5,
                    "enabled": True,
                    "field_name": "Hashtags"
                },
                "subject": {
                    "order": 1,
                    "sdWidth": "full",
                    "required": True,
                    "enabled": True
                },
            },
            "schema": {
                "subject": {
                    "mandatory_in_list": {
                        "scheme": {}
                    },
                    "schema": {},
                    "type": "list",
                    "required": True,
                    "default": [],
                    "nullable": False,
                },
                "hashtags": {
                    "type": "list",
                    "required": False,
                    "default": []
                },
            },
        }

        updates = copy.deepcopy(original)
        # the updates are only removing the "subject" field
        updates['schema']['subject'] = updates['editor']['subject'] = None
        content_types.ContentTypesService().on_update(updates, original)
        self.assertFalse(updates['schema']['subject']['required'])