示例#1
0
 def test_tag_is_completed(self):
     # Test tag with isCompleted set to True
     self.assertTrue(Tag.from_json({
         "targetType": 0,
         "target": "Test",
         "action": Tag.Action.ASSIGN,
         "location": 0,
         "isCompleted": True
     }).is_completed)
示例#2
0
    def test_tag_decoration(self):
        tag = Tag(Tag.TargetType.USER, "Test", Tag.Action.ASSIGN, 0)
        self.assertEqual("<span class=\"assign\">@Test</span>", tag.decorate())

        tag = Tag(Tag.TargetType.GROUP, "Test2", Tag.Action.NOTIFY, 0)
        self.assertEqual("<span class=\"notify\">!Test2</span>", tag.decorate())

        tag = Tag(Tag.TargetType.CATEGORY, "Test3", Tag.Action.CATEGORIZE, 0)
        self.assertEqual("<span class=\"categorize\">#Test3</span>", tag.decorate())
示例#3
0
    def test_tag_parsing_type_validation(self):
        # Test valid JSON
        self.assertIsInstance(Tag.from_json({
            "targetType": 0,
            "target": "Test",
            "action": Tag.Action.ASSIGN,
            "location": 0
        }), Tag)

        # Test tag targetType property type validation
        self.assertRaises(InvalidJSONException, Tag.from_json, {
            "targetType": "",
            "target": "Test",
            "action": Tag.Action.ASSIGN,
            "location": 0
        })

        # Test tag target type validation
        self.assertRaises(InvalidJSONException, Tag.from_json, {
            "targetType": 0,
            "target": 0,
            "action": Tag.Action.ASSIGN,
            "location": 0
        })

        # Test tag value type validation
        self.assertRaises(InvalidJSONException, Tag.from_json, {
            "targetType": 0,
            "target": "Test",
            "action": 0,
            "location": 0
        })

        # Test tag location type validation
        self.assertRaises(InvalidJSONException, Tag.from_json, {
            "targetType": 0,
            "target": "Test",
            "action": Tag.Action.ASSIGN,
            "location": ""
        })