def test_categorize_versions_without_affected_ranges(): all_versions = {"1.0", "1.1", "2.0", "2.1", "3.0", "3.1"} unaffected_ranges = [ VersionSpecifier.from_scheme_version_spec_string("semver", "< 1.2") ] affected_ranges = [] resolved_ranges = [ VersionSpecifier.from_scheme_version_spec_string("semver", ">= 3.0") ] unaffected_versions, affected_versions = categorize_versions( all_versions, unaffected_ranges, affected_ranges, resolved_ranges, ) assert len(unaffected_versions) == 4 assert "1.0" in unaffected_versions assert "1.1" in unaffected_versions assert "3.0" in unaffected_versions assert "3.1" in unaffected_versions assert len(affected_versions) == 2 assert "2.0" in affected_versions assert "2.1" in affected_versions
def test_categorize_versions(): flatbuffers_versions = MOCKED_CRATES_API_VERSIONS["flatbuffers"] unaffected_ranges = [ VersionSpecifier.from_scheme_version_spec_string("semver", "< 0.4.0") ] affected_ranges = [ VersionSpecifier.from_scheme_version_spec_string("semver", ">= 0.4.0"), VersionSpecifier.from_scheme_version_spec_string("semver", "<= 0.6.0"), ] resolved_ranges = [ VersionSpecifier.from_scheme_version_spec_string("semver", ">= 0.6.1") ] unaffected_versions, affected_versions = categorize_versions( set(flatbuffers_versions), unaffected_ranges, affected_ranges, resolved_ranges, ) assert len(unaffected_versions) == 2 assert "0.3.0" in unaffected_versions assert "0.6.5" in unaffected_versions assert len(affected_versions) == 1 assert "0.5.0" in affected_versions
def test_categorize_versions_without_any_ranges(): all_versions = {"1.0", "1.1", "2.0", "2.1", "3.0", "3.1"} unaffected, affected = categorize_versions(all_versions, [], [], []) assert len(unaffected) == 0 assert len(affected) == 0
def test_categorize_versions_without_any_ranges(): all_versions = {'1.0', '1.1', '2.0', '2.1', '3.0', '3.1'} unaffected, affected = categorize_versions(all_versions, set(), set(), set()) assert len(unaffected) == 0 assert len(affected) == 0
def test_categorize_versions(): flatbuffers_versions = MOCKED_CRATES_API_VERSIONS['flatbuffers'] unaffected_ranges = {RangeSpecifier('< 0.4.0')} affected_ranges = {RangeSpecifier('>= 0.4.0'), RangeSpecifier('<= 0.6.0')} resolved_ranges = {RangeSpecifier('>= 0.6.1')} unaffected_versions, affected_versions = categorize_versions( set(flatbuffers_versions), unaffected_ranges, affected_ranges, resolved_ranges, ) assert len(unaffected_versions) == 2 assert '0.3.0' in unaffected_versions assert '0.6.5' in unaffected_versions assert len(affected_versions) == 1 assert '0.5.0' in affected_versions
def test_categorize_versions(): flatbuffers_versions = MOCKED_CRATES_API_VERSIONS["flatbuffers"] unaffected_ranges = {RangeSpecifier("< 0.4.0")} affected_ranges = {RangeSpecifier(">= 0.4.0"), RangeSpecifier("<= 0.6.0")} resolved_ranges = {RangeSpecifier(">= 0.6.1")} unaffected_versions, affected_versions = categorize_versions( set(flatbuffers_versions), unaffected_ranges, affected_ranges, resolved_ranges, ) assert len(unaffected_versions) == 2 assert "0.3.0" in unaffected_versions assert "0.6.5" in unaffected_versions assert len(affected_versions) == 1 assert "0.5.0" in affected_versions
def test_categorize_versions_with_only_affected_ranges(): all_versions = {'1.0', '1.1', '2.0', '2.1', '3.0', '3.1'} unaffected_ranges = set() affected_ranges = {RangeSpecifier('> 1.2'), RangeSpecifier('<= 2.1')} resolved_ranges = set() unaffected_versions, affected_versions = categorize_versions( all_versions, unaffected_ranges, affected_ranges, resolved_ranges, ) assert len(unaffected_versions) == 4 assert '1.0' in unaffected_versions assert '1.1' in unaffected_versions assert '3.0' in unaffected_versions assert '3.1' in unaffected_versions assert len(affected_versions) == 2 assert '2.0' in affected_versions assert '2.1' in affected_versions
def test_categorize_versions_with_only_affected_ranges(): all_versions = {"1.0", "1.1", "2.0", "2.1", "3.0", "3.1"} unaffected_ranges = set() affected_ranges = {RangeSpecifier("> 1.2"), RangeSpecifier("<= 2.1")} resolved_ranges = set() unaffected_versions, affected_versions = categorize_versions( all_versions, unaffected_ranges, affected_ranges, resolved_ranges, ) assert len(unaffected_versions) == 4 assert "1.0" in unaffected_versions assert "1.1" in unaffected_versions assert "3.0" in unaffected_versions assert "3.1" in unaffected_versions assert len(affected_versions) == 2 assert "2.0" in affected_versions assert "2.1" in affected_versions