# Path: pubs/commands/tag_cmd.py
# def _parse_tag_seq(s):
#     """Transform 'math-ai' in ['+math', '-ai']"""
#     tags = []
#     if s[0] == ':':
#         s = '-' + s[1:]
#     if s[0] not in ['+', '-']:
#         s = '+' + s
#     last = 0
#     for m in re.finditer(r'[+-]', s):
#         if m.start() == last:
#             if last != 0:
#                 raise ValueError('could not match tag expression')
#         else:
#             tag = s[last:(m.start())]
#             if len(tag) > 0:
#                 tags.append(s[last:(m.start())])
#         last = m.start()
#     if last == len(s):
#         raise ValueError('could not match tag expression')
#     else:
#         tags.append(s[last:])
#     return tags
# 
# def _tag_groups(tags):
#     plus_tags, minus_tags = [], []
#     for tag in tags:
#         if tag[0] == '+':
#             plus_tags.append(tag[1:])
#         else:
#             assert tag[0] == '-'
#             minus_tags.append(tag[1:])
#     return set(plus_tags), set(minus_tags)


import unittest
import dotdot
from pubs.commands.tag_cmd import _parse_tag_seq, _tag_groups
# -*- coding: utf-8 -*-


class TestTag(unittest.TestCase):

    def test_parse_tags(self):
        self.assertEqual(['+abc', '+def9'], _parse_tag_seq('abc+def9'))
        self.assertEqual(['+abc', '-def9'], _parse_tag_seq('abc-def9'))

# Path: pubs/commands/tag_cmd.py
# def _parse_tag_seq(s):
#     """Transform 'math-ai' in ['+math', '-ai']"""
#     tags = []
#     if s[0] == ':':
#         s = '-' + s[1:]
#     if s[0] not in ['+', '-']:
#         s = '+' + s
#     last = 0
#     for m in re.finditer(r'[+-]', s):
#         if m.start() == last:
#             if last != 0:
#                 raise ValueError('could not match tag expression')
#         else:
#             tag = s[last:(m.start())]
#             if len(tag) > 0:
#                 tags.append(s[last:(m.start())])
#         last = m.start()
#     if last == len(s):
#         raise ValueError('could not match tag expression')
#     else:
#         tags.append(s[last:])
#     return tags
# 
# def _tag_groups(tags):
#     plus_tags, minus_tags = [], []
#     for tag in tags:
#         if tag[0] == '+':
#             plus_tags.append(tag[1:])
#         else:
#             assert tag[0] == '-'
#             minus_tags.append(tag[1:])
#     return set(plus_tags), set(minus_tags)


# Path: tests/test_tag.py
import unittest
import dotdot
from pubs.commands.tag_cmd import _parse_tag_seq, _tag_groups

# -*- coding: utf-8 -*-


class TestTag(unittest.TestCase):

    def test_parse_tags(self):
        self.assertEqual(['+abc', '+def9'], _parse_tag_seq('abc+def9'))
        self.assertEqual(['+abc', '-def9'], _parse_tag_seq('abc-def9'))

        self.assertEqual(['-abc', '-def9'], _parse_tag_seq('-abc-def9'))