def test_uniquename(): """Tests uniquename functionality of HFOS base components""" a = pytest.TestComponent() b = pytest.TestComponent() pytest.clean_test_components() assert a.uniquename != b.uniquename
def test_uniquename(): """Tests uniquename functionality of Isomer base components""" a = pytest.TestComponent("FOO") b = pytest.TestComponent("FOO") pytest.clean_test_components() assert a.uniquename != b.uniquename assert a.uniquename in pytest.TestComponent.names
def test_unique_warning(): log = logger.LiveLog logger.live = True c = pytest.TestComponent(uniquename='FOO') d = pytest.TestComponent(uniquename='FOO') pytest.clean_test_components() assert "Unique component added twice: " in str(log)
def test_unique_warning(): """Test for uniqueness of generated components""" log = logger.LiveLog logger.live = True c = pytest.TestComponent("FOO") d = pytest.TestComponent("FOO") pytest.clean_test_components() assert "Unique component added twice: " in str(log)
def test_named(): """Tests named HFOS base components""" a = pytest.TestComponent(uniquename="BERTRAM") pytest.clean_test_components() assert a.uniquename == "BERTRAM"
def test_config_uuid(): """Tests if ConfigurableComponents configurations get an UUID assigned""" c = pytest.TestComponent() pytest.clean_test_components() assert type(c.config.uuid) == str
def test_configschema(): """Tests if ConfigurableComponents obtain a configuration schema""" c = pytest.TestComponent() pytest.clean_test_components() assert type(c.configschema) == dict assert 'schema' in c.configschema assert 'properties' in c.configschema['schema']
def test_configschema(): """Tests if ConfigurableComponents obtain a configuration schema""" c = pytest.TestComponent("FOO") pytest.clean_test_components() assert type(c.configschema) == dict assert "schema" in c.configschema assert "properties" in c.configschema["schema"]
def test_put(): test_component = pytest.TestComponent() test_uuid = test_component.config.uuid packet = transmit('put', { 'obj': test_component.config.serializablefields(), 'uuid': test_uuid }) assert packet['data']
def test_put(): """Tests if storing a new component config works""" test_component = pytest.TestComponent("FOO") test_uuid = test_component.config.uuid packet = transmit( "put", {"obj": test_component.config.serializablefields(), "uuid": test_uuid} ) assert packet["data"]
def test_write_none_config(): log = logger.LiveLog logger.live = True c = pytest.TestComponent() c.config = None c._write_config() pytest.clean_test_components() assert "Unable to write non existing configuration" in str(log)
def test_unregister(): name = "test_unregister" m = Manager() c = pytest.TestComponent(uniquename=name) c.register(m) assert name in pytest.TestComponent.names c.unregister() assert name not in pytest.TestComponent.names
def test_component_log(): """Tests if a component logs correctly""" c = pytest.TestComponent() unique = str(uuid4()) log = logger.LiveLog logger.live = True c.log(unique) pytest.clean_test_components() assert unique in str(log)
def test_unregister(): """Test if component cleanly unregisters from namespace""" name = "test_unregister" m = Manager() c = pytest.TestComponent(name) c.register(m) assert name in pytest.TestComponent.names c.unregister() assert name not in pytest.TestComponent.names
def test_get_object(): """Tests if a component config can be retrieved""" test_component = pytest.TestComponent("FOO") test_uuid = test_component.config.uuid packet = transmit("get", {"uuid": test_uuid}) assert packet["action"] == "get" assert "data" in packet obj = packet["data"] assert obj["uuid"] == test_uuid
def test_get_object(): """Tests if a systemconfig can be retrieved""" test_component = pytest.TestComponent() test_uuid = test_component.config.uuid packet = transmit('get', { 'uuid': test_uuid }) assert packet['action'] == 'get' assert 'data' in packet obj = packet['data'] assert obj['uuid'] == test_uuid
def test_get_permission_error(): """Tests if a systemconfig cannot be retrieved if the user has insufficient roles assigned""" test_component = pytest.TestComponent() test_uuid = test_component.config.uuid account = AccountMock() account.roles.remove('admin') packet = transmit('get', { 'uuid': test_uuid }, account) assert packet['action'] == 'get' assert 'data' in packet assert packet['data'] is False
Test HFOS Launcher ================== """ from circuits import Manager import pytest from hfos import logger from time import sleep from pprint import pprint m = Manager() component = pytest.TestComponent() component.register(m) def test_component_logging(): """Throws an exception inside the system and tests if the debugger picks it up correctly""" m.start() logger.live = True component.log('FOOBAR') lastlog = "".join(logger.LiveLog[-1:]) assert "FOOBAR" in lastlog
================== """ from circuits import Manager import pytest from isomer import logger # from time import sleep # from pprint import pprint m = Manager() component = pytest.TestComponent("FOO") component.register(m) def test_component_logging(): """Throws an exception inside the c_system and tests if the debugger picks it up correctly""" m.start() logger.live = True component.log("FOOBAR") lastlog = logger.LiveLog[-1][-1] assert "FOOBAR" in lastlog