Skip to content

Commit 86c8195

Browse files
committed
extracted constants and fixtures
1 parent 4702fb7 commit 86c8195

File tree

3 files changed

+118
-105
lines changed

3 files changed

+118
-105
lines changed

tests/constants.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# -*- coding: utf-8 -*-
22

3+
import os
4+
from pathlib import Path
5+
36
from gardenlinux.git import Repository
47

58
TEST_DATA_DIR = "test-data"
@@ -12,6 +15,8 @@
1215
REPO_NAME = "gardenlinux-example"
1316
CONTAINER_NAME_ZOT_EXAMPLE = f"{REGISTRY}/{REPO_NAME}"
1417
GARDENLINUX_ROOT_DIR_EXAMPLE = f"{TEST_DATA_DIR}/gardenlinux/.build"
18+
GLVD_BASE_URL = "https://glvd.ingress.glvd.gardnlinux.shoot.canary.k8s-hana.ondemand.com/v1"
19+
GL_REPO_BASE_URL = "https://packages.gardenlinux.io/gardenlinux"
1520

1621
TEST_PLATFORMS = ["aws", "azure", "gcp", "openstack", "openstackbaremetal", "metal"]
1722
TEST_ARCHITECTURES = ["arm64", "amd64"]
@@ -20,3 +25,11 @@
2025
TEST_COMMIT = Repository(GL_ROOT_DIR).commit_id[:8]
2126
TEST_VERSION = "1000.0"
2227
TEST_VERSION_STABLE = "1000"
28+
29+
TEST_GARDENLINUX_RELEASE = "1877.3"
30+
TEST_GARDENLINUX_COMMIT = "75df9f401a842914563f312899ec3ce34b24515c"
31+
TEST_GARDENLINUX_COMMIT_SHORT = TEST_GARDENLINUX_COMMIT[:8]
32+
33+
TEST_DATA_DIR = Path(os.path.dirname(__file__)) / ".." / "test-data" / "release_notes"
34+
S3_ARTIFACTS_DIR = TEST_DATA_DIR / "s3_bucket_artifacts"
35+
S3_DOWNLOADS_DIR = Path(os.path.dirname(__file__)) / ".." / "s3_downloads"

tests/github/conftest.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import os
2+
import shutil
3+
from pathlib import Path
4+
5+
import boto3
6+
import pytest
7+
from moto import mock_aws
8+
9+
from gardenlinux.github.__main__ import (
10+
GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME, RELEASE_ID_FILE)
11+
12+
from ..constants import S3_DOWNLOADS_DIR
13+
14+
15+
@pytest.fixture
16+
def downloads_dir():
17+
os.makedirs(S3_DOWNLOADS_DIR, exist_ok=True)
18+
yield
19+
shutil.rmtree(S3_DOWNLOADS_DIR)
20+
21+
22+
@pytest.fixture
23+
def release_id_file():
24+
f = Path(RELEASE_ID_FILE)
25+
yield f
26+
f.unlink()
27+
28+
29+
@pytest.fixture
30+
def github_token():
31+
os.environ["GITHUB_TOKEN"] = "foobarbazquux"
32+
yield
33+
del os.environ["GITHUB_TOKEN"]
34+
35+
36+
@pytest.fixture
37+
def release_s3_bucket():
38+
with mock_aws():
39+
s3 = boto3.resource("s3", region_name="eu-central-1")
40+
s3.create_bucket(Bucket=GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME,
41+
CreateBucketConfiguration={
42+
'LocationConstraint': 'eu-central-1'})
43+
yield s3.Bucket(GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME)
44+
45+
46+
@pytest.fixture
47+
def artifact_for_upload(downloads_dir):
48+
artifact = S3_DOWNLOADS_DIR / "artifact.log"
49+
artifact.touch()
50+
yield artifact
51+
artifact.unlink()

0 commit comments

Comments
 (0)