Source code for cis_interface.drivers.tests.test_FileOutputDriver

import os
import nose.tools as nt
import cis_interface.drivers.tests.test_IODriver as parent


[docs]class TestFileOutputParam(parent.TestIOParam): r"""Test parameters for FileOutputDriver. Attributes (in addition to parent class's): filepath (str): Full path to test file. """ def __init__(self, *args, **kwargs): super(TestFileOutputParam, self).__init__(*args, **kwargs) self.driver = 'FileOutputDriver' self.filepath = os.path.abspath('ascii_input.txt') self.args = self.filepath self.attr_list += ['args', 'fd', 'lock']
[docs]class TestFileOutputDriverNoStart(TestFileOutputParam, parent.TestIODriverNoStart): r"""Test runner for FileOutputDriver without start. Attributes (in addition to parent class's): - """ pass
[docs]class TestFileOutputDriver(TestFileOutputParam, parent.TestIODriver): r"""Test runner for FileOutputDriver. Attributes (in addition to parent class's): - """
[docs] def setup(self): r"""Create a driver instance and start the driver.""" super(TestFileOutputDriver, self).setup() self.instance.ipc_send(self.file_contents)
[docs] def teardown(self): r"""Remove the instance, stoppping it.""" super(TestFileOutputDriver, self).teardown() if os.path.isfile(self.filepath): os.remove(self.filepath)
[docs] def assert_after_stop(self): r"""Assertions to make after stopping the driver instance.""" super(TestFileOutputDriver, self).assert_after_stop() assert(os.path.isfile(self.filepath)) with open(self.filepath, 'rb') as fd: data = fd.read() nt.assert_equal(data, self.file_contents)
[docs] def assert_after_terminate(self): r"""Assertions to make after terminating the driver instance.""" super(TestFileOutputDriver, self).assert_after_terminate() assert(self.instance.fd is None)
# These are disabled to prevent writting extraneous data
[docs] def test_send_recv(self): r"""Test sending/receiving small message.""" pass
[docs] def test_send_recv_nolimit(self): r"""Test sending/receiving large message.""" pass
[docs] def run_before_terminate(self): r"""Commands to run while the instance is running, before terminate.""" pass