<commit_before>import unittest

from malcolm.core import Process
from malcolm.modules.stats.controllers import StatsController

from malcolm.version import __version__
from cothread import catools
import time
import os
from math import floor


class TestBasicController(unittest.TestCase):
    prefix = "unitTest:%s" % floor(time.time()).__repr__()[:-2]

    def setUp(self):
        self.process = Process("proc")
        self.o = StatsController("MyMRI", prefix=self.prefix)
        self.process.add_controller(self.o)
        self.process.start()
        self.b = self.process.block_view("MyMRI")

    def tearDown(self):
        self.process.stop(timeout=2)

    def test_sets_stats(self):
        assert self.b.pymalcolmVer.value == __version__
        assert self.b.hostname.value == os.uname()[1]

    def test_starts_ioc(self):
        assert catools.caget(self.prefix + ":PYMALCOLM:VER") == __version__

    def test_ioc_ticks(self):
        uptime = catools.caget(self.prefix + ":UPTIME:RAW")
        assert uptime >= 0
        time.sleep(5)
        assert catools.caget(self.prefix + ":UPTIME:RAW") >= uptime + 5<commit_msg>updated unit test to reflect hostname truncation<commit_after>import unittest

from malcolm.core import Process
from malcolm.modules.stats.controllers import StatsController

from malcolm.version import __version__
from cothread import catools
import time
import os
from math import floor


class TestBasicController(unittest.TestCase):
    prefix = "unitTest:%s" % floor(time.time()).__repr__()[:-2]

    def setUp(self):
        self.process = Process("proc")
        self.o = StatsController("MyMRI", prefix=self.prefix)
        self.process.add_controller(self.o)
        self.process.start()
        self.b = self.process.block_view("MyMRI")

    def tearDown(self):
        self.process.stop(timeout=2)

    def test_sets_stats(self):
        assert self.b.pymalcolmVer.value == __version__
        hostname = os.uname()[1]
        hostname = hostname if len(hostname) < 39 else hostname[:35] + '...'
        assert self.b.hostname.value == hostname

    def test_starts_ioc(self):
        assert catools.caget(self.prefix + ":PYMALCOLM:VER") == __version__

    def test_ioc_ticks(self):
        uptime = catools.caget(self.prefix + ":UPTIME:RAW")
        assert uptime >= 0
        time.sleep(5)
        assert catools.caget(self.prefix + ":UPTIME:RAW") >= uptime + 5
{'fraction_non_alphanumeric': 0.11784232365145228, 'fraction_numerical': 0.006639004149377593, 'mean_word_length': 3.305357142857143, 'pattern_counts': {'":': 6, '<': 4, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7378838', 'n_tokens_mistral': 790, 'n_tokens_neox': 760, 'n_words': 160}