Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
def test_named():
    """Tests named HFOS base components"""

    a = pytest.TestComponent(uniquename="BERTRAM")
    pytest.clean_test_components()

    assert a.uniquename == "BERTRAM"
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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']
Ejemplo n.º 8
0
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"]
Ejemplo n.º 9
0
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']
Ejemplo n.º 10
0
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"]
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
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
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
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
Ejemplo n.º 16
0
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
Ejemplo n.º 17
0
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
Ejemplo n.º 18
0
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
Ejemplo n.º 19
0
==================



"""

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