<commit_before># Copyright 2015 The Capirca Project Authors All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""UnitTest class for nsxv.py"""


import unittest
from xml.etree import ElementTree as ET

from lib import naming
from lib import nsxv
from lib import policy
import nsxv_mocktest


class TermTest(unittest.TestCase):

  def setUp(self):
    """Call before every test case."""
    _parser = OptionParser()
    _parser.add_option('-d', '--def', dest='definitions',
                      help='definitions directory', default='../def')
    (FLAGS, args) = _parser.parse_args()
    self.defs = naming.Naming(FLAGS.definitions)

  def tearDown(self):
    pass

  def runTest(self):
    pass

  def test_init_forinet(self):
    """ Test for Term._init_ """
    inet_term = nsxv.Term(nsxv_mocktest.INET_TERM, 'inet')
    self.assertEqual(inet_term.af, 4)
    self.assertEqual(inet_term.text_af, 'inet')
    self.assertEqual(inet_term.filter_type, 'inet')

  def test_init_forinet6(self):
    """ Test for Term._init_ """
    inet6_term = nsxv.Term(nsxv_mocktest.INET6_TERM, 'inet6', 6)
    self.assertEqual(inet6_term.af, 6)
    self.assertEqual(inet6_term.text_af, 'inet6')
    self.assertEqual(inet6_term.filter_type, 'inet6')

  def test_ServiceToStr(self):
    """ Test for Term._ServiceToStr """

    proto = 6
    icmp_types = []
    dports = [(1024, 65535)]
    spots = [(123, 123)]<commit_msg>Fix nsxv unittest<commit_after># Copyright 2015 The Capirca Project Authors All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""UnitTest class for nsxv.py"""


import unittest
from xml.etree import ElementTree as ET

from lib import naming
from lib import nsxv
from lib import policy
import nsxv_mocktest


class TermTest(unittest.TestCase):

  def setUp(self):
    """Call before every test case."""
    _parser = OptionParser()
    _parser.add_option('-d', '--def', dest='definitions',
                      help='definitions directory', default='../def')
    (FLAGS, args) = _parser.parse_args()
    self.defs = naming.Naming(FLAGS.definitions)

  def tearDown(self):
    pass

  def runTest(self):
    pass

  def test_init_forinet(self):
    """ Test for Term._init_ """
    inet_term = nsxv.Term(nsxv_mocktest.INET_TERM, 'inet')
    self.assertEqual(inet_term.af, 4)
    self.assertEqual(inet_term.filter_type, 'inet')

  def test_init_forinet6(self):
    """ Test for Term._init_ """
    inet6_term = nsxv.Term(nsxv_mocktest.INET6_TERM, 'inet6', 6)
    self.assertEqual(inet6_term.af, 6)
    self.assertEqual(inet6_term.filter_type, 'inet6')

  def test_ServiceToStr(self):
    """ Test for Term._ServiceToStr """

    proto = 6
    icmp_types = []
    dports = [(1024, 65535)]
    spots = [(123, 123)]
{'fraction_non_alphanumeric': 0.10980810234541578, 'fraction_numerical': 0.018656716417910446, 'mean_word_length': 3.793103448275862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5186951', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1157, 'n_words': 367}