Пример #1
0
 def setup(self):
     self.configuration = DeviceConfiguration.get(sample_configuration, is_file_path=False)
     self.configuration['commands'][3]['delay'] = 0
     self.terminal = MockTerminal()
     self.context_manager = ContextManager()
     base_ctx = DeviceContext('base')
     base_ctx.prompt = 'device#'
     self.context_manager.add(base_ctx)
     self.command_manager = CommandManager(self.configuration)
     self.run = partial(self.command_manager.run, self.terminal, self.context_manager)
Пример #2
0
class TestDeviceContext(object):
    def setup(self):
        self.ctx01 = DeviceContext('ctx01')

    def test_initialization(self):
        assert_equals(self.ctx01.name, 'ctx01')
        assert_equals(self.ctx01.prompt, None)
        assert_raises(TypeError, DeviceContext, 20)

    def test_equality(self):
        ctx01 = DeviceContext('ctx01')
        ctx02 = DeviceContext('ctx02')
        ctx03 = DeviceContext('ctx03')
        assert_equals(self.ctx01, ctx01)
        assert_not_equals(self.ctx01, ctx03)
        assert_not_equals(ctx02, ctx03)

    def test_repr(self):
        expected_repr = '<{} {}>'.format(DeviceContext.__name__, self.ctx01.name)
        assert_equals(self.ctx01.__repr__(), expected_repr)
Пример #3
0
 def setup(self):
     self.ctx01 = DeviceContext('ctx01')