1+ ################################################################################
2+ # Copyright IBM Corporation 2024
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ ################################################################################
16+
17+ """
18+ Global Test Fixtures
19+ """
20+
121import toml
222import shutil
323import pytest
828
929@pytest .fixture (scope = "session" , autouse = True )
1030def analysis_json_fixture ():
31+ """Fixture to get the path of the analysis.json file for testing
32+
33+ Returns:
34+ Path: The folder that contains the analysis.json file
35+ """
1136 # Path to your pyproject.toml
1237 pyproject_path = Path (__file__ ).parent .parent / "pyproject.toml"
1338
@@ -19,6 +44,11 @@ def analysis_json_fixture():
1944
2045@pytest .fixture (scope = "session" , autouse = True )
2146def codeanalyzer_jar_path ():
47+ """Fixture to get the path to the codeanalyzer.jar file
48+
49+ Returns:
50+ Path: The path to the codeanalyzer.jar file
51+ """
2252 # Path to your pyproject.toml
2353 pyproject_path = Path (__file__ ).parent .parent / "pyproject.toml"
2454
@@ -45,19 +75,22 @@ def test_fixture():
4575
4676 # Access the test data path
4777 test_data_path = config ["tool" ]["cldk" ]["testing" ]["sample-application" ]
78+ filename = Path (test_data_path ).absolute () / "daytrader8-1.2.zip"
4879
49- if not Path (test_data_path ).exists ():
50- Path (test_data_path ).mkdir (parents = True )
51- url = "https://github.com/OpenLiberty/sample.daytrader8/archive/refs/tags/v1.2.zip"
52- filename = Path (test_data_path ).absolute () / "v1.2.zip"
53- urlretrieve (url , filename )
80+ # If the file doesn't exist, download it
81+ if not Path (filename ).exists ():
82+ # If the path doesn't exist, create it
83+ if not Path (test_data_path ).exists ():
84+ Path (test_data_path ).mkdir (parents = True )
85+ url = "https://github.com/OpenLiberty/sample.daytrader8/archive/refs/tags/v1.2.zip"
86+ urlretrieve (url , filename )
5487
5588 # Extract the zip file to the test data path
5689 with zipfile .ZipFile (filename , "r" ) as zip_ref :
5790 zip_ref .extractall (test_data_path )
5891
5992 # Remove the zip file
60- filename .unlink ()
93+ # filename.unlink()
6194 # --------------------------------------------------------------------------------
6295 # Daytrader8 sample application path
6396 yield Path (test_data_path ) / "sample.daytrader8-1.2"
0 commit comments