def test_addosbreed():
    # Arrange
    os_signatures = Signatures()

    # Act
    os_signatures.addosbreed("Test")

    # Assert
    assert len(os_signatures.osbreeds) == 1
def test_addosversion_empty():
    # Arrange
    os_signatures = Signatures()
    os_signatures.addosbreed("suse")

    # Act
    os_signatures.addosversion(0, "sles", None)

    # Assert
    assert os_signatures.osbreeds[0].osversions["sles"] == Osversion()
def test_get_breed_index_by_name():
    # Arrange
    os_signatures = Signatures()
    name_to_get = "suse"
    os_signatures.addosbreed(name_to_get)

    # Act
    result = os_signatures.get_breed_index_by_name(name_to_get)

    # Assert
    assert result == 0
def test_removeosversion():
    # Arrange
    os_signatures = Signatures()
    os_signatures.addosbreed("suse")
    os_signatures.addosversion(0, "sles", Osversion())

    # Act
    os_signatures.removeosversion(0, "sles")

    # Assert
    assert os_signatures.osbreeds[0].osversions == {}
def test_exportsignatures_string():
    # Arrange
    os_signatures = Signatures()
    os_signatures.addosbreed("suse")
    expected = "{\"breeds\": {\"suse\": {}}}"

    # Act
    result = os_signatures.exportsignatures(ExportTypes.STRING)

    # Assert
    assert expected == result
def test_exportsignatures_file(testpath):
    # Arrange
    os_signatures = Signatures()
    os_signatures.addosbreed("suse")
    expected = "{\"breeds\": {\"suse\": {}}}"

    # Act
    os_signatures.exportsignatures(ExportTypes.FILE, testpath)
    with open(testpath, "r") as f:
        result = f.read()

    # Assert
    assert expected == result
def test_removeosbreed():
    # Arrange
    os_signatures = Signatures()
    os_signatures.addosbreed("Test")
    len_before = len(os_signatures.osbreeds)

    # Act
    os_signatures.removeosbreed(0)
    len_after = len(os_signatures.osbreeds)

    # Assert
    assert len_before == 1
    assert len_after == 0