KissMock   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 27
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A add_read_from_interface() 0 2 1
A clear_interface() 0 3 1
A _write_interface() 0 2 1
A _read_interface() 0 6 2
A get_sent_to_interface() 0 2 1
A __init__() 0 5 1
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