<commit_before>__author__ = '<NAME>'

import datetime

from blitz.io.boards import BaseExpansionBoard
from blitz.io.tcp import TcpClient

time0 = datetime.datetime.now()
time1 = datetime.datetime.now() - datetime.timedelta(seconds=1)
time2 = datetime.datetime.now() - datetime.timedelta(seconds=2)
time3 = datetime.datetime.now() - datetime.timedelta(seconds=3)
time4 = datetime.datetime.now() - datetime.timedelta(seconds=4)

READING_FIXTURES = [
    {"sessionId": 1, "timeLogged": time3, "categoryId": 1, "value": 3.75},
    {"sessionId": 1, "timeLogged": time2, "categoryId": 1, "value": 9.12},
    {"sessionId": 1, "timeLogged": time1, "categoryId": 2, "value": 5.2},
    {"sessionId": 1, "timeLogged": time0, "categoryId": 2, "value": 4.3}
]

CACHE_FIXTURES = [
    {"timeLogged": time3, "categoryId": 1, "value": 3.75},
    {"timeLogged": time2, "categoryId": 1, "value": 9.12},
    {"timeLogged": time1, "categoryId": 2, "value": 5.2},
    {"timeLogged": time0, "categoryId": 2, "value": 4.3}
]

CATEGORY_FIXTURES = [
    {"variableName": "Accelerator"},
    {"variableName": "Brake"},
    {"variableName": "Third"}
]

SESSION_FIXTURES = [
    {"available": True, "timeStarted": time4, "timeStopped": time2, "numberOfReadings": 2},
    {"available": False, "timeStarted": time2, "timeStopped": time0, "numberOfReadings": 2}
]

CONFIG_FIXTURES = [
    {"key": "loggerPort", "value": "8989"},
    {"key": "loggerIp", "value": "192.168.1.79"},
    {"key": "clientPort", "value": "8988"},
    {"key": "clientIp", "value": "192.168.1.79"},
    {"key": "sampleRate", "value": "50"},
    {"key": "clientRefreshRate", "value": "2"}
]


def generate_objects(model, fixtures):
    """
    Generate a list of objects of the provided model type with the data
    given in the fixtures list of dictionaries
    """
    res = []
    for f in fixtures:
        res.append(model(**f))
    return res


class TcpClientMock(TcpClient):
    """
    A class for mocking TCP operations (client side) during unit testing
    """

    def send(self, msg):
        """Mocks sending a TCP message by printing to stdout"""
        print "[SEND] ", msg

    def parse_reading(self, msg):
        """Mocks processing a data message by printing message to stdout, then pass to super class"""
        print "[PARSE] ", msg
        super(TcpClientMock, self).parse_reading(msg)

    def process_message(self, msg):
        """Log then process the message using the super class"""
        print "[RECEIVE] ", msg
        super(TcpClientMock, self).process_message(msg)
<commit_msg>Add additional fixtures and sort out TcpMockClient<commit_after>__author__ = '<NAME>'

import datetime

from blitz.io.boards import BaseExpansionBoard
from blitz.io.tcp import TcpClient

time0 = datetime.datetime.now()
time1 = datetime.datetime.now() - datetime.timedelta(seconds=1)
time2 = datetime.datetime.now() - datetime.timedelta(seconds=2)
time3 = datetime.datetime.now() - datetime.timedelta(seconds=3)
time4 = datetime.datetime.now() - datetime.timedelta(seconds=4)
time5 = datetime.datetime.now() - datetime.timedelta(seconds=5)
time6 = datetime.datetime.now() - datetime.timedelta(seconds=6)

READING_FIXTURES = [
    {"sessionId": 1, "timeLogged": time3, "categoryId": 1, "value": 3.75},
    {"sessionId": 1, "timeLogged": time2, "categoryId": 1, "value": 9.12},
    {"sessionId": 1, "timeLogged": time4, "categoryId": 1, "value": 7.56},
    {"sessionId": 1, "timeLogged": time1, "categoryId": 2, "value": 5.2},
    {"sessionId": 1, "timeLogged": time0, "categoryId": 2, "value": 4.3},
    {"sessionId": 1, "timeLogged": time5, "categoryId": 2, "value": 1.23}
]

CACHE_FIXTURES = [
    {"timeLogged": time3, "categoryId": 1, "value": 3.75},
    {"timeLogged": time2, "categoryId": 1, "value": 9.12},
    {"timeLogged": time4, "categoryId": 1, "value": 7.56},
    {"timeLogged": time1, "categoryId": 2, "value": 5.2},
    {"timeLogged": time0, "categoryId": 2, "value": 4.3},
    {"timeLogged": time5, "categoryId": 2, "value": 1.23}

]

CATEGORY_FIXTURES = [
    {"variableName": "adc_channel_one"},
    {"variableName": "adc_channel_two"},
    {"variableName": "adc_channel_three"}
]

SESSION_FIXTURES = [
    {"available": True, "timeStarted": time4, "timeStopped": time2, "numberOfReadings": 2},
    {"available": False, "timeStarted": time2, "timeStopped": time0, "numberOfReadings": 2}
]

CONFIG_FIXTURES = [
    {"key": "loggerPort", "value": "8989"},
    {"key": "loggerIp", "value": "192.168.1.79"},
    {"key": "clientPort", "value": "8988"},
    {"key": "clientIp", "value": "192.168.1.79"},
    {"key": "sampleRate", "value": "50"},
    {"key": "clientRefreshRate", "value": "2"}
]


def generate_objects(model, fixtures):
    """
    Generate a list of objects of the provided model type with the data
    given in the fixtures list of dictionaries
    """
    res = []
    for f in fixtures:
        res.append(model(**f))
    return res


class TcpClientMock(TcpClient):
    """
    A class for mocking TCP operations (client side) during unit testing
    """

    def _do_send(self, msg):
        """Mocks sending a TCP message by printing to stdout"""
        print "[SEND] ", msg

    def parse_reading(self, msg):
        """Mocks processing a data message by printing message to stdout, then pass to super class"""
        print "[PARSE] ", msg
        super(TcpClientMock, self).parse_reading(msg)

    def process_message(self, msg):
        """Log then process the message using the super class"""
        print "[RECEIVE] ", msg
        super(TcpClientMock, self).process_message(msg)

{'fraction_non_alphanumeric': 0.17467718794835008, 'fraction_numerical': 0.03479196556671449, 'mean_word_length': 4.006283662477558, 'pattern_counts': {'":': 116, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '4474254', 'n_tokens_mistral': 2004, 'n_tokens_neox': 1867, 'n_words': 504}