Exemplo n.º 1
0
def test_AitConfig():
    config = cfg.AitConfig(data=YAML())
    path = "bin/ait-orbits"
    assert_AitConfig(config, path)

    with TestFile(YAML(), "w+") as filename:
        config = cfg.AitConfig(filename)
        assert_AitConfig(config, path, filename)
        config.reload()
        assert_AitConfig(config, path, filename)
Exemplo n.º 2
0
    def test_successful_outbound_stream_creation(self, create_handler_mock,
                                                 server_init_mock,
                                                 broker_class_mock):
        """ Tests that all types of outbound streams are successfully created """
        # Testing creation of outbound stream with ZMQ input/output
        server = Server()
        server.broker = ait.core.server.broker.Broker()

        config = {
            'name': 'some_stream',
            'handlers': [{
                'name': 'some-handler'
            }]
        }
        created_stream = server._create_outbound_stream(config)
        assert type(created_stream) == ait.core.server.stream.ZMQStream
        assert created_stream.name == 'some_stream'
        assert type(created_stream.handlers) == list

        # Testing creation of outbound stream with port output
        config = cfg.AitConfig(config={'name': 'some_stream', 'output': 3333})
        created_stream = server._create_outbound_stream(config)
        assert type(created_stream) == ait.core.server.stream.PortOutputStream
        assert created_stream.name == 'some_stream'
        assert created_stream.out_port == 3333
        assert created_stream.handlers == []
Exemplo n.º 3
0
    def test_successful_outbound_stream_creation(
            self, create_handler_mock, server_stream_plugin_mock_mock,
            broker_class_mock):
        """Tests that all types of outbound streams are successfully created"""
        # Testing creation of outbound stream with ZMQ input/output
        server = Server()
        server.broker = ait.core.server.broker.Broker()

        config = {
            "name": "some_stream",
            "handlers": [{
                "name": "some-handler"
            }]
        }
        created_stream = server._create_outbound_stream(config)
        assert type(created_stream) == ait.core.server.stream.ZMQStream
        assert created_stream.name == "some_stream"
        assert type(created_stream.handlers) == list

        # Testing creation of outbound stream with port output
        config = cfg.AitConfig(config={"name": "some_stream", "output": 3333})
        created_stream = server._create_outbound_stream(config)
        assert type(created_stream) == ait.core.server.stream.PortOutputStream
        assert created_stream.name == "some_stream"
        assert created_stream.out_port == 3333
        assert created_stream.handlers == []
Exemplo n.º 4
0
def get_packet_and_defn():
    first_stream = ait.config.get('gui.telemetry')[0]
    stream = cfg.AitConfig(config=first_stream).get('stream')
    name = stream.get('name', '<unnamed>')
    pkt_defn = tlm.getDefaultDict().get(name, None)
    pkt = tlm.Packet(pkt_defn)

    return pkt_defn, pkt
Exemplo n.º 5
0
def test_datapaths ():
    """
    default:
        ISS:
            apiport: 9090
            bticard: 0
            desc:    ISS PL/MDM Simulator
            path:    bin/ait-orbits
            rtaddr:  15
    """
    # check data paths work from YAML()
    config = cfg.AitConfig(data=YAML())
    assert len(config._datapaths) > 0

    # check if data paths do not exist
    config = cfg.AitConfig(data=test_datapaths.__doc__)
    try:
        paths = config._datapaths
        assert False
    except cfg.AitConfigMissing as e:
        assert True
Exemplo n.º 6
0
def test_addPathVariables():
    config = cfg.AitConfig(data=YAML())
    before = config._pathvars
    before_len = len(before.keys())

    pathvars = {'x': 'test-x', 'y': 'test-y'}
    config.addPathVariables(pathvars)
    after = config._pathvars
    after_len = len(after.keys())

    assert before_len < after_len
    assert 'x' in after.keys()
    assert 'y' in after.keys()
Exemplo n.º 7
0
def test_add_path_variables():
    config = cfg.AitConfig(data=YAML())
    before = config._pathvars
    before_len = len(before.keys())

    pathvars = {"x": "test-x", "y": "test-y"}
    config.add_path_variables(pathvars)
    after = config._pathvars
    after_len = len(after.keys())

    assert before_len < after_len
    assert "x" in after.keys()
    assert "y" in after.keys()
Exemplo n.º 8
0
def testGetDefaultDictWithExtension_setup_teardown():
    cfg_yml = '''
default:
    extensions:
        ait.core.cmd.CmdDict: tests.ait.core.test_cmd.TestCmdDict
    '''
    saved_config = ait.config
    ait.config = cfg.AitConfig(data=cfg_yml)
    setattr(cmd, 'DefaultDict', None)  # Reset DefaultDict being cached
    importlib.reload(cmd)  # Recreate createCmdDict method
    yield
    ait.config = saved_config
    setattr(cmd, 'DefaultDict', None)  # Reset DefaultDict being cached
    importlib.reload(cmd)  # Recreate createCmdDict method
    importlib.reload(tlm)  # Also reload tlm default schema
Exemplo n.º 9
0
    def tearDown(self):
        ait.config = cfg.AitConfig()

        if os.path.exists(self.test_yaml_file):
            os.remove(self.test_yaml_file)