# Path: tutelary/engine.py
# class Action(SimpleSeparated):
#     """Actions are represented by period-separated sequences of elements
#     (e.g. ``parcel.edit``, ``admin.assign-role``) with wildcard
#     elements indicated by ``*`` (e.g. ``party.*``).  A list of
#     *registered* actions is maintained to support permissions set
#     queries to find the set of actions that are permitted on a
#     specified object pattern.
# 
#     """
#     separator = '.'
# 
#     registered = set()
# 
#     def register(action):
#         """Action registration is used to support generating lists of
#         permitted actions from a permission set and an object pattern.
#         Only registered actions will be returned by such queries.
# 
#         """
#         if isinstance(action, str):
#             Action.register(Action(action))
#         elif isinstance(action, Action):
#             Action.registered.add(action)
#         else:
#             for a in action:
#                 Action.register(a)
# 
# class Object(EscapeSeparated):
#     """Objects are represented by slash-separated sequences of elements
#     (e.g. ``Cadasta/Batangas/parcel/123``, ``H4H/PaP/party/118``) with
#     wildcard elements indicated by ``*``
#     (e.g. ``Cadasta/*/parcel/*``).  Slashes can be backslash-escaped,
#     as can backslashes (e.g. ``Cadasta/Village-X\/Y/parcel/943``).
# 
#     """
#     separator = '/'
# 
# class SimpleSeparated(Sequence):
#     """Simple sequences of strings delimited by a separator, with
#     wildcarding.
# 
#     A wildcard component is represented by a ``*`` string and matches
#     any single string component.  Equality comparison between
#     sequences is exact comparison of components; matching between
#     wildcarded components can be tested using the ``match`` method.
# 
#     """
#     def __init__(self, s):
#         if s is None:
#             self.components = []
#         elif isinstance(s, str):
#             self.components = self._split_components(s)
#         elif isinstance(s, Sequence):
#             self.components = s
#         else:
#             raise ValueError('invalid initialiser for separated sequence')
# 
#     def _split_components(self, s):
#         return s.split(self.separator)
# 
#     def __len__(self):
#         return len(self.components)
# 
#     def __getitem__(self, idx):
#         return self.components[idx]
# 
#     def __str__(self):
#         return self.separator.join(self.components)
# 
#     def __repr__(self):
#         return '{}({!r})'.format(self.__class__.__name__, str(self))
# 
#     def __eq__(self, other):
#         return self.components == other.components
# 
#     def __hash__(self):
#         return hash(str(self))
# 
#     def match(self, other):
#         # Two sequences match if they are the same length and
#         # corresponding components are either equal, or at least one
#         # is a wildcard.
#         if len(self) != len(other):
#             return False
#         for cself, cother in zip(self.components, other.components):
#             if not (cself == cother or cself == '*' or cother == '*'):
#                 return False
#         return True


import pytest
from tutelary.engine import Action, Object, SimpleSeparated



def test_sequence_creation_empty():
    seq1 = SimpleSeparated(None)
    assert len(seq1) == 0
    assert seq1.components == []


def test_sequence_creation_components():

# Path: tutelary/engine.py
# class Action(SimpleSeparated):
#     """Actions are represented by period-separated sequences of elements
#     (e.g. ``parcel.edit``, ``admin.assign-role``) with wildcard
#     elements indicated by ``*`` (e.g. ``party.*``).  A list of
#     *registered* actions is maintained to support permissions set
#     queries to find the set of actions that are permitted on a
#     specified object pattern.
# 
#     """
#     separator = '.'
# 
#     registered = set()
# 
#     def register(action):
#         """Action registration is used to support generating lists of
#         permitted actions from a permission set and an object pattern.
#         Only registered actions will be returned by such queries.
# 
#         """
#         if isinstance(action, str):
#             Action.register(Action(action))
#         elif isinstance(action, Action):
#             Action.registered.add(action)
#         else:
#             for a in action:
#                 Action.register(a)
# 
# class Object(EscapeSeparated):
#     """Objects are represented by slash-separated sequences of elements
#     (e.g. ``Cadasta/Batangas/parcel/123``, ``H4H/PaP/party/118``) with
#     wildcard elements indicated by ``*``
#     (e.g. ``Cadasta/*/parcel/*``).  Slashes can be backslash-escaped,
#     as can backslashes (e.g. ``Cadasta/Village-X\/Y/parcel/943``).
# 
#     """
#     separator = '/'
# 
# class SimpleSeparated(Sequence):
#     """Simple sequences of strings delimited by a separator, with
#     wildcarding.
# 
#     A wildcard component is represented by a ``*`` string and matches
#     any single string component.  Equality comparison between
#     sequences is exact comparison of components; matching between
#     wildcarded components can be tested using the ``match`` method.
# 
#     """
#     def __init__(self, s):
#         if s is None:
#             self.components = []
#         elif isinstance(s, str):
#             self.components = self._split_components(s)
#         elif isinstance(s, Sequence):
#             self.components = s
#         else:
#             raise ValueError('invalid initialiser for separated sequence')
# 
#     def _split_components(self, s):
#         return s.split(self.separator)
# 
#     def __len__(self):
#         return len(self.components)
# 
#     def __getitem__(self, idx):
#         return self.components[idx]
# 
#     def __str__(self):
#         return self.separator.join(self.components)
# 
#     def __repr__(self):
#         return '{}({!r})'.format(self.__class__.__name__, str(self))
# 
#     def __eq__(self, other):
#         return self.components == other.components
# 
#     def __hash__(self):
#         return hash(str(self))
# 
#     def match(self, other):
#         # Two sequences match if they are the same length and
#         # corresponding components are either equal, or at least one
#         # is a wildcard.
#         if len(self) != len(other):
#             return False
#         for cself, cother in zip(self.components, other.components):
#             if not (cself == cother or cself == '*' or cother == '*'):
#                 return False
#         return True


# Path: tests/test_engine.py
import pytest
from tutelary.engine import Action, Object, SimpleSeparated




def test_sequence_creation_empty():
    seq1 = SimpleSeparated(None)
    assert len(seq1) == 0
    assert seq1.components == []


def test_sequence_creation_components():

    seq2 = SimpleSeparated(['parcel', 'list'])