@@ -21,6 +21,65 @@ def test_analyze_no_information(pypi_package_json: MagicMock) -> None:
2121 analyzer .analyze (pypi_package_json )
2222
2323
24+ def test_analyze_no_releases (pypi_package_json : MagicMock ) -> None :
25+ """Test for when there are no release entries, so error."""
26+ analyzer = AnomalousVersionAnalyzer ()
27+
28+ pypi_package_json .get_releases .return_value = {}
29+ pypi_package_json .get_latest_version .return_value = None
30+
31+ with pytest .raises (HeuristicAnalyzerValueError ):
32+ analyzer .analyze (pypi_package_json )
33+
34+
35+ def test_analyze_missing_release (pypi_package_json : MagicMock ) -> None :
36+ """Test for when there is a release entry, but no actual release information, so error."""
37+ analyzer = AnomalousVersionAnalyzer ()
38+ version = "1.1"
39+
40+ pypi_package_json .get_releases .return_value = {version : []}
41+ pypi_package_json .get_latest_version .return_value = version
42+
43+ with pytest .raises (HeuristicAnalyzerValueError ):
44+ analyzer .analyze (pypi_package_json )
45+
46+
47+ def test_analyze_missing_time (pypi_package_json : MagicMock ) -> None :
48+ """Test for when the supplied upload time does not conform with PEP 440, so error."""
49+ analyzer = AnomalousVersionAnalyzer ()
50+ version = "1.1"
51+ release = {
52+ version : [
53+ {
54+ "comment_text" : "" ,
55+ "digests" : {
56+ "blake2b_256" : "defa2fbcebaeeb909511139ce28dac4a77ab2452ba72b49a22b12981b2f375b3" ,
57+ "md5" : "9203bbb130f8ddb38269f4861c170d04" ,
58+ "sha256" : "168bcccbf5106132e90b85659297700194369b8f6b3e5a03769614f0d200e370" ,
59+ },
60+ "downloads" : - 1 ,
61+ "filename" : "ttttttttest_nester.py-0.1.0.tar.gz" ,
62+ "has_sig" : False ,
63+ "md5_digest" : "9203bbb130f8ddb38269f4861c170d04" ,
64+ "packagetype" : "sdist" ,
65+ "python_version" : "source" ,
66+ "requires_python" : None ,
67+ "size" : 546 ,
68+ "url" : "https://files.pythonhosted.org/packages/de/fa/"
69+ + "2fbcebaeeb909511139ce28dac4a77ab2452ba72b49a22b12981b2f375b3/ttttttttest_nester.py-0.1.0.tar.gz" ,
70+ "yanked" : False ,
71+ "yanked_reason" : None ,
72+ }
73+ ]
74+ }
75+
76+ pypi_package_json .get_releases .return_value = release
77+ pypi_package_json .get_latest_version .return_value = version
78+
79+ with pytest .raises (HeuristicAnalyzerValueError ):
80+ analyzer .analyze (pypi_package_json )
81+
82+
2483def test_analyze_invalid_time (pypi_package_json : MagicMock ) -> None :
2584 """Test for when the supplied upload time does not conform with PEP 440, so error."""
2685 analyzer = AnomalousVersionAnalyzer ()
0 commit comments