Пример #1
0
def test_fingerprint_eq():
    """Check fingerprint __eq__ function."""
    f1 = Fingerprint()
    f1.add("1", "1")
    assert f1 != 1

    f2 = Fingerprint()
    f2.add("1", "1")
    f2.add("2", "2")
    assert f1 != f2
    assert f1.checksum() != f2.checksum()

    assert f1.compare_to(f1) is None
Пример #2
0
def test_fingerprint():
    f1 = Fingerprint()
    f1.add("foo", "2")

    f2 = Fingerprint()
    f2.add("foo", "4")

    f12_diff = f2.compare_to(f1)
    assert f12_diff["new"] == set()
    assert f12_diff["updated"] == {"foo"}
    assert f12_diff["obsolete"] == set()

    f3 = Fingerprint()
    f3.add_file(__file__)

    f23_diff = f3.compare_to(f2)
    assert f23_diff["new"] == {"foo"}
    assert f23_diff["updated"] == set()
    assert f23_diff["obsolete"] == {os.path.abspath(__file__)}

    assert f1.checksum() != f2.checksum() != f3.checksum()

    assert Env().build.os.version in str(f3)

    f4 = Fingerprint()
    f4.add_file(__file__)
    assert f4 == f3

    f5 = Fingerprint()
    with pytest.raises(E3Error) as err:
        f5.add("f4", f4)
    assert "f4 should be a string" in str(err.value)

    f6 = Fingerprint()
    f6.add("unicode", "6")
    assert len(f6.checksum()) == 64
Пример #3
0
def test_fingerprint():
    f1 = Fingerprint()
    f1.add('foo', '2')

    f2 = Fingerprint()
    f2.add('foo', '4')

    f12_diff = f2.compare_to(f1)
    assert f12_diff['new'] == set([])
    assert f12_diff['updated'] == {'foo'}
    assert f12_diff['obsolete'] == set([])

    f3 = Fingerprint()
    f3.add_file(__file__)

    f23_diff = f3.compare_to(f2)
    assert f23_diff['new'] == {'foo'}
    assert f23_diff['updated'] == set([])
    assert f23_diff['obsolete'] == {os.path.basename(__file__)}

    assert f1.checksum() != f2.checksum() != f3.checksum()

    assert Env().build.os.version in str(f3)

    f4 = Fingerprint()
    f4.add_file(__file__)
    assert f4 == f3

    f5 = Fingerprint()
    with pytest.raises(E3Error) as err:
        f5.add('f4', f4)
    assert 'f4 should be a string' in str(err.value)

    f6 = Fingerprint()
    f6.add('unicode', u'6')
    assert len(f6.checksum()) == 64