def test_version_info_iter():
    obj = VersionInfo(**FAKE_VERSION_INFO_WITH_CHECKER)
    obj.updated = datetime.now()
    test_dict = {
        "version": "1.1",
        "version_type": "upstream",
        "source": {
            "uri": "https://test.uri",
            "repository": "test_repository",
            "tool": "test_tool",
            "provider": "test_provider",
            "method": "test_release",
            "suite": "test_suite",
            "origin": True,
            "docker_origin": True,
            "version": "1.1",
            "extra_info": "Test information",
        },
        "tags": ["latest", "latest-stable"],
        "updated": format_time(obj.updated),
        "origin": True,
        "size": "3.95 MB",
    }
    assert dict(obj) == test_dict
    obj = VersionInfo(**FAKE_VERSION_INFO_NO_CHECKER)
    obj.updated = datetime.now()
    test_dict2 = {
        "version": "0.9",
        "version_type": "remote",
        "source": "no_checker_case",
        "tags": ["latest", "latest-stable"],
        "updated": format_time(obj.updated),
        "origin": False,
        "size": "39.53 MB",
    }
    assert dict(obj) == test_dict2

    assert json.dumps(test_dict)
    assert json.dumps(test_dict2)
def test_setters_version_info_no_checker():
    obj = VersionInfo(**FAKE_VERSION_INFO_NO_CHECKER)
    assert obj.source == "no_checker_case"
    obj.source = "new case"
    assert obj.source == "new case"
    assert obj.version == "0.9"
    obj.version = 1.2
    assert obj.version == "1.2"
    with pytest.raises(ValueError):
        obj.version = ""

    obj.updated = datetime(2020, 1, 1, 11, 11)
    obj.updated == datetime(2020, 1, 1, 11, 11)
    # Test invalid time format
    with pytest.raises(ValueError):
        obj.updated = ""

    # size
    with pytest.raises(ValueError):
        obj.size = "16062006"

    obj._size = None
    assert obj.size == "NaN"
    obj.size = 900
    assert obj.size == "900 bytes"
    obj.size = 1001
    assert obj.size == "1.00 KB"
    obj.size = 16062
    assert obj.size == "16.06 KB"
    obj.size = 16062006
    assert obj.size == "16.06 MB"
    obj.size = 1606200600
    assert obj.size == "1.61 GB"

    obj_c = FAKE_VERSION_INFO_NO_CHECKER.copy()
    obj_c["size"] = "This is something"
    obj = VersionInfo(**obj_c)
    assert obj.size == "NaN"