Exemplo n.º 1
0
def test_ProtocolsIcmpTimeout():
    c = ContextConfig(IConfig("example.json"))
    c.GetWorkingConfigClass(True)
    c.ReadConfig()

    if c.configuration.protocols.icmp.timeout == 0:
        assert True
Exemplo n.º 2
0
def test_LoadConfigTwice():
    c = ContextConfig(IConfig('example.json'))
    c.GetWorkingConfigClass(True)
    c.ReadConfig()
    c.ReadConfig()

    if c.configuration.nodes.__len__() == 4:
        assert True
Exemplo n.º 3
0
def test_JsonContainsSleepInterval():
    i = IConfig("example.json")
    j = JsonConfig(i)
    c = ContextConfig(j)
    c.ReadConfig()

    if c.configuration.sleepInterval.minutes >= 2:
        assert True
Exemplo n.º 4
0
def test_YamlContainsSleepInterval():
    i = IConfig("example.yaml")
    y = YamlConfig(i)
    c = ContextConfig(y)
    c.ReadConfig()

    if c.configuration.sleepInterval.minutes == 2:
        assert True
Exemplo n.º 5
0
def test_FindValidClassToInject():
    c = ContextConfig(IConfig("example.json"))
    c.GetWorkingConfigClass(True)
    c.ReadConfig()

    if c.configuration.sleepInterval.minutes == 2:
        assert True

    pass
Exemplo n.º 6
0
def test_YamlReturnsData():
    i = IConfig("example.yaml")
    y = YamlConfig(i)
    cc = ContextConfig(y)
    cc.ReadConfig()

    if cc.configuration.nodes.__len__() >= 1:
        assert True
    pass
Exemplo n.º 7
0
def test_JsonRead():
    # Add info into interface
    i = IConfig("example.json")
    j = JsonConfig(i)

    # Generate our context that will handle the work
    c = ContextConfig(j)
    c.ReadConfig()

    if c.configuration.nodes.__len__() >= 1:
        assert True
    pass
Exemplo n.º 8
0
def test_NewConfig():

    j = JsonConfig(IConfig("delete.json"))
    c = ContextConfig(j)
    c.NewConfig()
    c.ReadConfig()

    os.remove("delete.json")

    if c.configuration.sleepInterval.minutes == 2:
        assert True

    pass
Exemplo n.º 9
0
def test_JsonNodesContainProtocol():
    # Each node needs to contain a Name:
    i = IConfig("example.json")
    j = JsonConfig(i)
    c = ContextConfig(j)
    c.ReadConfig()

    for item in c.configuration.nodes:
        if item.protocol == None:
            # Object is missing Name:
            assert False
        pass

    assert True
Exemplo n.º 10
0
def test_YamlNodesContainAddress():
    # Each node needs to contain a Name:
    i = IConfig("example.yaml")
    y = YamlConfig(i)
    c = ContextConfig(y)
    c.ReadConfig()

    for item in c.configuration.nodes:
        if item.address == None:
            # Object is missing Name:
            assert False
        pass

    assert True
Exemplo n.º 11
0
def test_ProtocolsIcmpTimeoutNewConfig():
    f = 'delete.yaml'
    try:
        os.remove(f)
    except:
        pass

    c = ContextConfig(IConfig(f))
    c.GetWorkingConfigClass(True)
    c.NewConfig()
    c.ReadConfig()

    os.remove(f)
    if c.configuration.protocols.icmp.timeout == 0:
        assert True
Exemplo n.º 12
0
def test_GenerateNewYaml():
    f = 'delete.yaml'
    try:
        os.remove(f)
    except:
        pass

    i = IConfig(f)
    y = YamlConfig(i)
    c = ContextConfig(y)
    c.NewConfig()
    c.ReadConfig()

    os.remove(f)

    if c.configuration.sleepInterval.minutes == 2:
        assert True

    pass
Exemplo n.º 13
0
def init(config: str, newconfig: bool):
    """
        NetworkMonitor is a curses tool to monitor network nodes.
        Currently supports ping(icmp), Http: Get and Post.

        To get started:
        'networkmonitor --config "demo.yaml" --newconfig'

    """

    # Pass all the requested info into the interface
    cfg = IConfig(config, newconfig)

    # Once interfaces has been made, we will send them to the CLI worker class
    cli = CLI(cfg)

    # Check if NewConfig was requested
    cli.NewConfig()

    main = uiMain(cfg)
    main.Start()