コード例 #1
0
def test_ProtocolsIcmpTimeout():
    c = ContextConfig(IConfig("example.json"))
    c.GetWorkingConfigClass(True)
    c.ReadConfig()

    if c.configuration.protocols.icmp.timeout == 0:
        assert True
コード例 #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
コード例 #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
コード例 #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
コード例 #5
0
def test_FindValidClassToInject():
    c = ContextConfig(IConfig("example.json"))
    c.GetWorkingConfigClass(True)
    c.ReadConfig()

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

    pass
コード例 #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
コード例 #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
コード例 #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
コード例 #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
コード例 #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
コード例 #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
コード例 #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