def test_tag_config_insert_tag_group_missing_tag_not_unique( cfg: tags.TagConfig) -> None: with pytest.raises(MKGeneralException, match="must be unique"): tg = tags.TagGroup.from_config({ "id": "tgid4", "topic": "Topics", "title": "titlor", "tags": [ { "id": "ding", "title": "tagid2", "aux_tags": [] }, { "id": "ding", "title": "tagid3", "aux_tags": [] }, ], }) cfg.insert_tag_group(tg) cfg.validate_config()
def test_tag_config_insert_tag_group_aux_tag_id_conflict(cfg: tags.TagConfig) -> None: cfg.aux_tag_list.append(tags.AuxTag(("bla", "BLAAAA"))) tg = tags.TagGroup( ( "tgid6", "Topics/titlor", [ ("bla", "tagid2", []), ], ) ) cfg.insert_tag_group(tg) cfg.validate_config() with pytest.raises(MKGeneralException, match="is used twice"): tg = tags.TagGroup( ( "bla", "Topics/titlor", [ ("tagid2", "tagid2", []), ], ) ) cfg.insert_tag_group(tg) cfg.validate_config()
def test_tag_config_insert_tag_group_missing_multiple_tags_empty( cfg: tags.TagConfig) -> None: with pytest.raises(MKGeneralException, match="Only one tag may be empty"): tg = tags.TagGroup.from_config({ "id": "tgid3", "topic": "Topics", "title": "titlor", "tags": [ { "id": None, "title": "tagid2", "aux_tags": [] }, { "id": "", "title": "tagid3", "aux_tags": [] }, ], }) cfg.insert_tag_group(tg) cfg.validate_config()
def test_tag_config_insert_tag_group_missing_title(cfg: tags.TagConfig) -> None: with pytest.raises(MKGeneralException, match="Please specify"): tg = tags.TagGroup() tg.id = "abc" tg.title = "" cfg.insert_tag_group(tg) cfg.validate_config()
def test_tag_config_insert_tag_group_missing_id(cfg: tags.TagConfig) -> None: with pytest.raises(MKGeneralException, match="Please specify"): tg = tags.TagGroup(group_id="", title="title", help=None, topic=None, tags=[]) cfg.insert_tag_group(tg) cfg.validate_config()
def test_tag_config_insert_tag_group_missing_tag_not_unique( cfg: tags.TagConfig) -> None: with pytest.raises(MKGeneralException, match="must be unique"): tg = tags.TagGroup(("tgid4", "Topics/titlor", [ ("ding", "tagid2", []), ("ding", "tagid3", []), ])) cfg.insert_tag_group(tg) cfg.validate_config()
def test_tag_config_insert_tag_group_missing_multiple_tags_empty( cfg: tags.TagConfig) -> None: with pytest.raises(MKGeneralException, match="Only one tag may be empty"): tg = tags.TagGroup(("tgid3", "Topics/titlor", [ (None, "tagid2", []), ("", "tagid3", []), ])) cfg.insert_tag_group(tg) cfg.validate_config()
def test_tag_config_insert_tag_group_no_tag(cfg: tags.TagConfig) -> None: with pytest.raises(MKGeneralException, match="at least one tag"): tg = tags.TagGroup.from_config({ "id": "tgid7", "topic": "Topics", "title": "titlor", "tags": [] }) cfg.insert_tag_group(tg) cfg.validate_config()
def test_tag_config_insert_tag_group_aux_tag_id_conflict( cfg: tags.TagConfig) -> None: cfg.aux_tag_list.append( tags.AuxTag.from_config({ "id": "bla", "title": "BLAAAA" })) tg = tags.TagGroup.from_config({ "id": "tgid6", "topic": "Topics", "title": "titlor", "tags": [ { "id": "bla", "title": "tagid2", "aux_tags": [] }, ], }) cfg.insert_tag_group(tg) cfg.validate_config() with pytest.raises(MKGeneralException, match="is used twice"): tg = tags.TagGroup.from_config({ "id": "bla", "topic": "Topics", "title": "titlor", "tags": [ { "id": "tagid2", "title": "tagid2", "aux_tags": [] }, ], }) cfg.insert_tag_group(tg) cfg.validate_config()
def test_tag_config_insert_tag_group_twice(cfg: tags.TagConfig) -> None: cfg.insert_tag_group(tags.TagGroup(("tgid2", "Topics/titlor", [("tgid2", "tagid2", [])]))) assert cfg.tag_groups[-1].id == "tgid2" cfg.insert_tag_group(tags.TagGroup(("tgidX", "Topics/titlor", [("tgid2", "tagid2", [])]))) cfg.validate_config() with pytest.raises(MKGeneralException, match="is used twice"): cfg.insert_tag_group(tags.TagGroup(("tgid2", "Topics/titlor", [("tgid3", "tagid3", [])]))) cfg.validate_config()
def test_tag_config_insert_tag_group_twice(cfg: tags.TagConfig) -> None: cfg.insert_tag_group( tags.TagGroup.from_config({ "id": "tgid2", "topic": "Topics", "title": "titlor", "tags": [{ "id": "tgid2", "title": "tagid2", "aux_tags": [] }], })) assert cfg.tag_groups[-1].id == "tgid2" cfg.insert_tag_group( tags.TagGroup.from_config({ "id": "tgidX", "topic": "Topics", "title": "titlor", "tags": [{ "id": "tgid2", "title": "tagid2", "aux_tags": [] }], })) cfg.validate_config() with pytest.raises(MKGeneralException, match="is used twice"): cfg.insert_tag_group( tags.TagGroup.from_config({ "id": "tgid2", "topic": "Topics", "title": "titlor", "tags": [{ "id": "tgid3", "title": "tagid3", "aux_tags": [] }], })) cfg.validate_config()
def test_tag_config_insert_tag_group_no_tag(cfg: tags.TagConfig) -> None: with pytest.raises(MKGeneralException, match="at least one tag"): tg = tags.TagGroup(("tgid7", "Topics/titlor", [])) cfg.insert_tag_group(tg) cfg.validate_config()