1111
1212def test_cli_help ():
1313 """Test that the CLI help command works"""
14- result = subprocess .run ([sys .executable , "-m" , "pygetpapers.pygetpapers" , "--help" ],
15- capture_output = True , text = True , timeout = 30 )
14+ result = subprocess .run (
15+ [sys .executable , "-m" , "pygetpapers.pygetpapers" , "--help" ], capture_output = True , text = True , timeout = 30
16+ )
1617 assert result .returncode == 0
1718 assert "usage:" in result .stdout .lower ()
1819 assert "pygetpapers" in result .stdout
1920
2021
2122def test_cli_version ():
2223 """Test that the CLI version command works"""
23- result = subprocess .run ([sys .executable , "-m" , "pygetpapers.pygetpapers" , "--version" ],
24- capture_output = True , text = True , timeout = 30 )
24+ result = subprocess .run (
25+ [sys .executable , "-m" , "pygetpapers.pygetpapers" , "--version" ], capture_output = True , text = True , timeout = 30
26+ )
2527 assert result .returncode == 0
2628 assert "pygetpapers" in result .stdout .lower ()
2729
2830
2931def test_cli_noexecute ():
3032 """Test the --noexecute flag (should not download anything)"""
31- result = subprocess .run ([
32- sys .executable , "-m" , "pygetpapers.pygetpapers" ,
33- "-q" , "test query" ,
34- "--noexecute" ,
35- "-k" , "1"
36- ], capture_output = True , text = True , timeout = 60 )
37-
33+ result = subprocess .run (
34+ [ sys .executable , "-m" , "pygetpapers.pygetpapers" , "-q" , "test query" , "--noexecute" , "-k" , "1" ],
35+ capture_output = True ,
36+ text = True ,
37+ timeout = 60 ,
38+ )
39+
3840 # Should complete without error (even if no results found)
3941 assert result .returncode in [0 , 1 ] # 0 = success, 1 = no results found
4042 assert "Total" in result .stdout or "hits" in result .stdout .lower ()
@@ -43,13 +45,13 @@ def test_cli_noexecute():
4345def test_cli_syntax ():
4446 """Test that basic CLI syntax is valid"""
4547 # Test with invalid API (should fail gracefully)
46- result = subprocess .run ([
47- sys .executable , "-m" , "pygetpapers.pygetpapers" ,
48- "--api" , "invalid_api" ,
49- "-q" , "test" ,
50- "--noexecute"
51- ], capture_output = True , text = True , timeout = 30 )
52-
48+ result = subprocess .run (
49+ [ sys .executable , "-m" , "pygetpapers.pygetpapers" , "--api" , "invalid_api" , "-q" , "test" , "--noexecute" ],
50+ capture_output = True ,
51+ text = True ,
52+ timeout = 30 ,
53+ )
54+
5355 # Should handle invalid API gracefully
5456 assert result .returncode != 0 # Should fail with invalid API
5557
@@ -59,6 +61,7 @@ def test_imports():
5961 try :
6062 import pygetpapers
6163 import pygetpapers .pygetpapers
64+
6265 print ("✅ All pygetpapers modules imported successfully" )
6366 except ImportError as e :
6467 assert False , f"Failed to import pygetpapers: { e } "
@@ -68,9 +71,9 @@ def test_config_file():
6871 """Test that config file exists and is readable"""
6972 config_path = Path ("pygetpapers/config.ini" )
7073 assert config_path .exists (), "config.ini should exist"
71-
74+
7275 # Test that it can be read
73- with open (config_path , 'r' ) as f :
76+ with open (config_path , "r" ) as f :
7477 content = f .read ()
7578 assert "[DEFAULT]" in content or "api" in content .lower ()
7679
@@ -83,4 +86,4 @@ def test_config_file():
8386 test_cli_syntax ()
8487 test_imports ()
8588 test_config_file ()
86- print ("✅ All CI tests passed!" )
89+ print ("✅ All CI tests passed!" )
0 commit comments