Ejemplo n.º 1
0
def test___eq__():
    db = Database()
    addr1 = 'localhost'
    addr2 = '127.0.0.1'
    addr3 = 'x011?!-\n/\\nw#!/.,x;{test}[lol]'
    host1 = Host(addr1, db)
    host2 = Host(addr2, db)
    host3 = Host(addr2, db)

    assert (host1 == host1) == True
    assert (host1 == host2) == False
    assert (host2 == host3) == True

    host3._Host__alive = True
    assert (host2 == host3) == False

    host3._Host__alive = False
    assert (host2 == host3) == True

    host3._Host__timestamp = 1
    assert (host2 == host3) == False
Ejemplo n.º 2
0
def test___error_equal():
    db = Database()
    addr1 = 'localhost'
    addr2 = '127.0.0.1'
    addr3 = 'x011?!-\n/\\nw#!/.,x;{test}[lol]'
    host1 = Host(addr1, db)
    host2 = Host(addr2, db)
    host3 = Host(addr2, db)

    assert db._Database__error_equal(host1.get_json(),
                                     host1.get_json()) == True
    assert db._Database__error_equal(host1.get_json(),
                                     host2.get_json()) == False

    host3._Host__alive = True
    assert db._Database__error_equal(host2.get_json(),
                                     host3.get_json()) == False