# Path: capirca/lib/policy_simple.py
# class Field:
# class IntegerField(Field):
# class NamingField(Field):
# class Action(Field):
# class Address(NamingField):
# class Port(NamingField):
# class Comment(Field):
# class Counter(Field):
# class Encapsulate(Field):
# class DestinationAddress(Address):
# class DestinationExclude(Address):
# class DestinationInterface(Field):
# class DestinationPort(Port):
# class DestinationPrefix(Field):
# class DestinationPrefixExcept(Field):
# class DestinationTag(Field):
# class DscpMatch(Field):
# class DscpSet(Field):
# class EtherType(Field):
# class Expiration(Field):
# class FragmentOffset(Field):
# class ForwardingClass(Field):
# class ForwardingClassExcept(Field):
# class IcmpCode(Field):
# class IcmpType(Field):
# class Logging(Field):
# class LossPriority(Field):
# class Option(Field):
# class Owner(Field):
# class NextIP(Field):
# class PacketLength(Field):
# class Platform(Field):
# class PlatformExclude(Field):
# class Policer(Field):
# class Precedence(Field):
# class Protocol(Field):
# class ProtocolExcept(Field):
# class Qos(Field):
# class PANApplication(Field):
# class RoutingInstance(Field):
# class SourceAddress(Address):
# class SourceExclude(Address):
# class SourceInterface(Field):
# class SourcePort(Port):
# class SourcePrefix(Field):
# class SourcePrefixExcept(Field):
# class SourceTag(Field):
# class Target(Field):
# class Timeout(IntegerField):
# class TrafficType(Field):
# class TrafficClassCount(Field):
# class Verbatim(Field):
# class Vpn(Field):
# class Block:
# class Header(Block):
# class Term(Block):
# class BlankLine:
# class CommentLine:
# class Include:
# class Policy:
# class PolicyParser:
#   def __init__(self, value):
#   def __str__(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def Append(self, value):
#   def ValueStr(self):
#   def __init__(self, value):
#   def __init__(self, value):
#   def ParseString(self, value):
#   def ValidatePart(self, part):
#   def Append(self, value):
#   def ValueStr(self):
#   def ValueStr(self):
#   def __init__(self):
#   def __iter__(self):
#   def __getitem__(self, i):
#   def __str__(self):
#   def AddField(self, field):
#   def FieldsWithType(self, f_type):
#   def Match(self, match_fn):
#   def Name(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def __init__(self, name):
#   def Name(self):
#   def __eq__(self, o):
#   def Describe(self):
#   def __str__(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def __init__(self, data):
#   def __str__(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def __init__(self, identifier):
#   def __str__(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def __init__(self, identifier):
#   def AddMember(self, member):
#   def __str__(self):
#   def __iter__(self):
#   def __getitem__(self, i):
#   def Match(self, match_fn):
#   def MatchFields(self, block_match_fn, field_match_fn):
#   def __init__(self, data, identifier):
#   def Parse(self):
#   def ParseTopLevel(self, line):
#   def ParseCommentLine(self, line):
#   def ParseIncludeLine(self, line):
#   def ParseHeaderLine(self, line):
#   def ParseTermLine(self, line):
#   def ParseInBlock(self, line):
#   def ParseField(self, line):


from absl.testing import absltest
from absl import logging
from capirca.lib import policy_simple
    s = policy_simple.SourceAddress('ABC')
    for field in (c1, d, c2, s):
      b.AddField(field)

    self.assertEqual([c1, d, c2, s], b.fields)
    self.assertEqual([c1, c2], b.FieldsWithType(policy_simple.Comment))

  def testIter(self):
    a = object()
    b = object()
    c = object()
    block = policy_simple.Block()
    block.fields = (a, b, c)

    self.assertEqual([a, b, c], list(block))


class PolicyTest(absltest.TestCase):

  def setUp(self):
    super().setUp()
    logging.debug('======> %s <======', self.id())

  def testAddMember(self):
    p = policy_simple.Policy('test')
    good = [policy_simple.Header(), policy_simple.Term('test'),
            policy_simple.BlankLine(), policy_simple.CommentLine('test'),
            policy_simple.Include('other_pol')]
    bad = ('', 3, lambda x: x, policy_simple.Field('test'))


# Path: capirca/lib/policy_simple.py
# class Field:
# class IntegerField(Field):
# class NamingField(Field):
# class Action(Field):
# class Address(NamingField):
# class Port(NamingField):
# class Comment(Field):
# class Counter(Field):
# class Encapsulate(Field):
# class DestinationAddress(Address):
# class DestinationExclude(Address):
# class DestinationInterface(Field):
# class DestinationPort(Port):
# class DestinationPrefix(Field):
# class DestinationPrefixExcept(Field):
# class DestinationTag(Field):
# class DscpMatch(Field):
# class DscpSet(Field):
# class EtherType(Field):
# class Expiration(Field):
# class FragmentOffset(Field):
# class ForwardingClass(Field):
# class ForwardingClassExcept(Field):
# class IcmpCode(Field):
# class IcmpType(Field):
# class Logging(Field):
# class LossPriority(Field):
# class Option(Field):
# class Owner(Field):
# class NextIP(Field):
# class PacketLength(Field):
# class Platform(Field):
# class PlatformExclude(Field):
# class Policer(Field):
# class Precedence(Field):
# class Protocol(Field):
# class ProtocolExcept(Field):
# class Qos(Field):
# class PANApplication(Field):
# class RoutingInstance(Field):
# class SourceAddress(Address):
# class SourceExclude(Address):
# class SourceInterface(Field):
# class SourcePort(Port):
# class SourcePrefix(Field):
# class SourcePrefixExcept(Field):
# class SourceTag(Field):
# class Target(Field):
# class Timeout(IntegerField):
# class TrafficType(Field):
# class TrafficClassCount(Field):
# class Verbatim(Field):
# class Vpn(Field):
# class Block:
# class Header(Block):
# class Term(Block):
# class BlankLine:
# class CommentLine:
# class Include:
# class Policy:
# class PolicyParser:
#   def __init__(self, value):
#   def __str__(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def Append(self, value):
#   def ValueStr(self):
#   def __init__(self, value):
#   def __init__(self, value):
#   def ParseString(self, value):
#   def ValidatePart(self, part):
#   def Append(self, value):
#   def ValueStr(self):
#   def ValueStr(self):
#   def __init__(self):
#   def __iter__(self):
#   def __getitem__(self, i):
#   def __str__(self):
#   def AddField(self, field):
#   def FieldsWithType(self, f_type):
#   def Match(self, match_fn):
#   def Name(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def __init__(self, name):
#   def Name(self):
#   def __eq__(self, o):
#   def Describe(self):
#   def __str__(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def __init__(self, data):
#   def __str__(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def __init__(self, identifier):
#   def __str__(self):
#   def __eq__(self, o):
#   def __ne__(self, o):
#   def __init__(self, identifier):
#   def AddMember(self, member):
#   def __str__(self):
#   def __iter__(self):
#   def __getitem__(self, i):
#   def Match(self, match_fn):
#   def MatchFields(self, block_match_fn, field_match_fn):
#   def __init__(self, data, identifier):
#   def Parse(self):
#   def ParseTopLevel(self, line):
#   def ParseCommentLine(self, line):
#   def ParseIncludeLine(self, line):
#   def ParseHeaderLine(self, line):
#   def ParseTermLine(self, line):
#   def ParseInBlock(self, line):
#   def ParseField(self, line):


# Path: tests/lib/policy_simple_test.py
from absl.testing import absltest
from absl import logging
from capirca.lib import policy_simple

    s = policy_simple.SourceAddress('ABC')
    for field in (c1, d, c2, s):
      b.AddField(field)

    self.assertEqual([c1, d, c2, s], b.fields)
    self.assertEqual([c1, c2], b.FieldsWithType(policy_simple.Comment))

  def testIter(self):
    a = object()
    b = object()
    c = object()
    block = policy_simple.Block()
    block.fields = (a, b, c)

    self.assertEqual([a, b, c], list(block))


class PolicyTest(absltest.TestCase):

  def setUp(self):
    super().setUp()
    logging.debug('======> %s <======', self.id())

  def testAddMember(self):
    p = policy_simple.Policy('test')
    good = [policy_simple.Header(), policy_simple.Term('test'),
            policy_simple.BlankLine(), policy_simple.CommentLine('test'),
            policy_simple.Include('other_pol')]
    bad = ('', 3, lambda x: x, policy_simple.Field('test'))


    for member in good: