KissMock.add_read_from_interface()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 2
rs 10
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
# These imports are for python3 compatibility inside python2
5
from __future__ import absolute_import
6
from __future__ import division
7
from __future__ import print_function
8
9
import apex.kiss.constants
10
11
__author__ = 'Jeffrey Phillips Freeman (WI2ARD)'
12
__maintainer__ = 'Jeffrey Phillips Freeman (WI2ARD)'
13
__email__ = '[email protected]'
14
__license__ = 'Apache License, Version 2.0'
15
__copyright__ = 'Copyright 2016, Syncleus, Inc. and contributors'
16
__credits__ = []
17
18
19
class KissMock(apex.kiss.Kiss):
20
21
    def __init__(self,
22
                 strip_df_start=True):
23
        super(KissMock, self).__init__(strip_df_start)
24
        self.read_from_interface = []
25
        self.sent_to_interface = []
26
27
    def _read_interface(self):
28
        if not len(self.read_from_interface):
29
            return None
30
        raw_frame = self.read_from_interface[0]
31
        del self.read_from_interface[0]
32
        return raw_frame
33
34
    def _write_interface(self, data):
35
        self.sent_to_interface.append(data)
36
37
    def clear_interface(self):
38
        self.read_from_interface = []
39
        self.sent_to_interface = []
40
41
    def add_read_from_interface(self, raw_frame):
42
        self.read_from_interface.append(raw_frame)
43
44
    def get_sent_to_interface(self):
45
        return self.sent_to_interface
46