예제 #1
0
def get_and_validate_tags(addition_string):
    if not addition_string:
        return []

    taglist = TagList([])
    taglist.populate_add_list(addition_string)
    tagops.validate_additions(taglist)

    return taglist.additions
예제 #2
0
def get_and_validate_tags(addition_string):
    if not addition_string:
        return []

    taglist = TagList([])
    taglist.populate_add_list(addition_string)
    tagops.validate_additions(taglist)

    return taglist.additions
    def test_validate_additions__attempt_to_add_preexisting_tag__raises_exception(
            self):
        taglist = TagList(self.current_list)
        taglist.populate_add_list("key1=value2")

        with self.assertRaises(
                tagops.InvalidAttemptToModifyTagsError) as context_manager:
            tagops.validate_additions(taglist)

        print(context_manager.exception.message)
        expected_error_message = "Tags with the following keys can't be added because they already exist:{0}{0}  key1{0}".format(
            linesep)
        self.assertEqual(expected_error_message,
                         context_manager.exception.message)
    def test_validate___attempt_to_add_new_tag__passes_validation(self):
        taglist = TagList(self.current_list)
        taglist.populate_add_list("key2=value2")

        tagops.validate_additions(taglist)