|
1 | | -import os |
2 | | -import sys |
3 | | - |
4 | | -import pytest |
5 | | - |
6 | | -from pathlib import Path |
7 | | - |
8 | 1 | from container_ci_suite.helm import HelmChartsAPI |
9 | | -from container_ci_suite.utils import check_variables |
10 | | - |
11 | | -from constants import TAGS |
12 | | - |
13 | | -if not check_variables(): |
14 | | - print("At least one variable from IMAGE_NAME, OS, VERSION is missing.") |
15 | | - sys.exit(1) |
16 | | - |
17 | 2 |
|
18 | | -test_dir = Path(os.path.abspath(os.path.dirname(__file__))) |
19 | | - |
20 | | - |
21 | | -VERSION = os.getenv("VERSION") |
22 | | -IMAGE_NAME = os.getenv("IMAGE_NAME") |
23 | | -OS = os.getenv("TARGET") |
24 | | - |
25 | | - |
26 | | -TAG = TAGS.get(OS) |
| 3 | +from conftest import VARS |
27 | 4 |
|
28 | 5 |
|
29 | 6 | class TestHelmCakePHPTemplate: |
| 7 | + """ |
| 8 | + Test checks if Helm imagestream and Helm ruby rails application |
| 9 | + works properly and response is as expected. |
| 10 | + """ |
30 | 11 |
|
31 | 12 | def setup_method(self): |
| 13 | + """ |
| 14 | + Setup the test environment. |
| 15 | + """ |
32 | 16 | package_name = "redhat-ruby-rails-application" |
33 | | - path = test_dir |
34 | | - self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir, shared_cluster=True) |
| 17 | + self.hc_api = HelmChartsAPI( |
| 18 | + path=VARS.TEST_DIR, |
| 19 | + package_name=package_name, |
| 20 | + tarball_dir=VARS.TEST_DIR, |
| 21 | + shared_cluster=True, |
| 22 | + ) |
35 | 23 | self.hc_api.clone_helm_chart_repo( |
36 | | - repo_url="https://github.com/sclorg/helm-charts", repo_name="helm-charts", |
37 | | - subdir="charts/redhat" |
| 24 | + repo_url="https://github.com/sclorg/helm-charts", |
| 25 | + repo_name="helm-charts", |
| 26 | + subdir="charts/redhat", |
38 | 27 | ) |
39 | 28 |
|
40 | 29 | def teardown_method(self): |
| 30 | + """ |
| 31 | + Teardown the test environment. |
| 32 | + """ |
41 | 33 | self.hc_api.delete_project() |
42 | 34 |
|
43 | 35 | def test_by_helm_test(self): |
44 | | - rails_ex_branch = "master" |
45 | | - if VERSION == "3.3": |
46 | | - rails_ex_branch = VERSION |
| 36 | + """ |
| 37 | + Test checks if Helm imagestream and Helm ruby rails application |
| 38 | + works properly and response is as expected. |
| 39 | + """ |
47 | 40 | self.hc_api.package_name = "redhat-ruby-imagestreams" |
48 | 41 | assert self.hc_api.helm_package() |
49 | 42 | assert self.hc_api.helm_installation() |
50 | 43 | self.hc_api.package_name = "redhat-ruby-rails-application" |
51 | 44 | assert self.hc_api.helm_package() |
52 | 45 | assert self.hc_api.helm_installation( |
53 | 46 | values={ |
54 | | - "ruby_version": f"{VERSION}{TAG}", |
| 47 | + "ruby_version": f"{VARS.VERSION}{VARS.TAG}", |
55 | 48 | "namespace": self.hc_api.namespace, |
56 | | - "source_repository_ref": rails_ex_branch, |
| 49 | + "source_repository_ref": VARS.BRANCH_TO_TEST, |
57 | 50 | } |
58 | 51 | ) |
59 | 52 | assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example") |
60 | | - assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Rails application"]) |
| 53 | + assert self.hc_api.test_helm_chart( |
| 54 | + expected_str=["Welcome to your Rails application"] |
| 55 | + ) |
0 commit comments