Skip to content

Commit f8f0cca

Browse files
committed
Added DayTrader 8 v1.2 sample as a permanent zip file.
Signed-off-by: John Rofrano <johnnyroy@johnrofrano.com>
1 parent 4b91ed2 commit f8f0cca

3 files changed

Lines changed: 42 additions & 6 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
*.tar.gz
2727
*.rar
2828

29+
# Don't ignore test fixture zip files
30+
!tests/resources/java/application/daytrader8-1.2.zip
31+
2932
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
3033
hs_err_pid*
3134

tests/conftest.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
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+
121
import toml
222
import shutil
323
import pytest
@@ -8,6 +28,11 @@
828

929
@pytest.fixture(scope="session", autouse=True)
1030
def 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)
2146
def 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"
2.12 MB
Binary file not shown.

0 commit comments

Comments
 (0)