1
|
|
|
#!/usr/bin/env python |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
|
4
|
|
|
"""Tests for KISS Util Module.""" |
5
|
|
|
|
6
|
|
|
# These imports are for python3 compatability inside python2 |
7
|
|
|
from __future__ import absolute_import |
8
|
|
|
from __future__ import division |
9
|
|
|
from __future__ import print_function |
10
|
|
|
|
11
|
|
|
import sys |
12
|
|
|
import unittest |
13
|
|
|
|
14
|
|
|
import apex.kiss |
15
|
|
|
import apex.kiss.constants |
16
|
|
|
import apex.kiss.util |
17
|
|
|
from . import constants |
18
|
|
|
|
19
|
|
|
__author__ = 'Jeffrey Phillips Freeman (WI2ARD)' |
20
|
|
|
__maintainer__ = "Jeffrey Phillips Freeman (WI2ARD)" |
21
|
|
|
__email__ = "[email protected]" |
22
|
|
|
__license__ = 'Apache License, Version 2.0' |
23
|
|
|
__copyright__ = 'Copyright 2016, Syncleus, Inc. and contributors' |
24
|
|
|
__credits__ = [] |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
# pylint: disable=R0904,C0103 |
28
|
|
|
class KissUtilTestCase(unittest.TestCase): |
29
|
|
|
|
30
|
|
|
"""Test class for KISS Python Module.""" |
31
|
|
|
|
32
|
|
|
# All other tests only work on python2 |
33
|
|
|
if sys.version_info < (3, 0): |
34
|
|
|
def setUp(self): |
35
|
|
|
"""Setup.""" |
36
|
|
|
self.test_frames = open(constants.TEST_FRAMES, 'r') |
37
|
|
|
self.test_frame = self.test_frames.readlines()[0].strip() |
38
|
|
|
|
39
|
|
|
def tearDown(self): |
40
|
|
|
"""Teardown.""" |
41
|
|
|
self.test_frames.close() |
42
|
|
|
|
43
|
|
|
def test_escape_special_codes_fend(self): |
44
|
|
|
""" |
45
|
|
|
Tests `kiss.util.escape_special_codes` util function. |
46
|
|
|
""" |
47
|
|
|
# fend = apex.kiss.util.escape_special_codes(apex.kiss.constants.FEND) |
48
|
|
|
fend = apex.kiss.Kiss._Kiss__escape_special_codes([apex.kiss.constants.FEND]) # pylint: disable=E1101 |
49
|
|
|
self.assertEqual(fend, apex.kiss.constants.FESC_TFEND) |
50
|
|
|
|
51
|
|
|
def test_escape_special_codes_fesc(self): |
52
|
|
|
""" |
53
|
|
|
Tests `kiss.util.escape_special_codes` util function. |
54
|
|
|
""" |
55
|
|
|
fesc = apex.kiss.Kiss._Kiss__escape_special_codes([apex.kiss.constants.FESC]) # pylint: disable=E1101 |
56
|
|
|
self.assertEqual(fesc, apex.kiss.constants.FESC_TFESC) |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
|
60
|
|
|
if __name__ == '__main__': |
61
|
|
|
unittest.main() |
62
|
|
|
|