Skip to content

Commit

Permalink
Fix test suite
Browse files Browse the repository at this point in the history
Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek committed Aug 19, 2024
1 parent efe6b52 commit b891c2f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 69 deletions.
11 changes: 6 additions & 5 deletions ocp-stream-generator/ocp_stream_generator/distribution_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@
"CentOS Stream 10": "el10",
}

latest_description = """
WARNING: By selecting this tag, your application will automatically update
to use the latest version available on OpenShift, including major version updates.
"""
latest_description = (
"\n\nWARNING: By selecting this tag,"
" your application will automatically"
" update to use the latest version available on OpenShift,"
" including major version updates.\n"
)
2 changes: 1 addition & 1 deletion ocp-stream-generator/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]
pythonpath = ocp-stream-generator
pythonpath = ocp_stream_generator
testpaths = tests
112 changes: 51 additions & 61 deletions ocp-stream-generator/tests/data/data_json_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"annotations": {
"openshift.io/display-name": "Test 1 (Latest)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "test description\n\nWARNING: By selecting this tag, your"
"application will automatically update"
"to use the latest version"
"available on OpenShift, including major version updates.\n",
"description": "test description\n\nWARNING: By selecting this tag,"
" your application will automatically update"
" to use the latest version available on OpenShift,"
" including major version updates.\n",
"iconClass": "icon-test",
"tags": "test,test",
"version": "1",
Expand Down Expand Up @@ -79,10 +79,11 @@
create_annotation_latest_result = {
"openshift.io/display-name": "Test 1 (Latest)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "test description\n\nWARNING: By selecting this tag,"
"your application will automatically update to use"
"the latest version available on OpenShift,"
"including major version updates.\n",
"description": (
"test description\n\nWARNING: By selecting this tag,"
" your application will automatically update to use "
"the latest version available on OpenShift, including major version updates.\n"
),
"iconClass": "icon-test",
"tags": "test,test",
"version": "1",
Expand All @@ -95,58 +96,47 @@
"spec": {"tags": []},
}

description_msg = (
"test description\n\n"
"WARNING: By selecting this tag, your application will automatically"
" update to use the latest version available on OpenShift, including major version updates.\n"
)

generate_json_result = """
{
"kind": "ImageStream",
"apiVersion": "image.openshift.io/v1",
"metadata": {
"name": "test",
"annotations": {
"openshift.io/display-name": "Test"
}
},
"spec": {
"tags": [
{
"name": "1-el8",
"annotations": {
"openshift.io/display-name": "Test 1 (RHEL 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "test description",
"iconClass": "icon-test",
"tags": "test,test",
"version": "1"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/rhel8/test-1:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "latest",
"annotations": {
"openshift.io/display-name": "Test 1 (Latest)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "test description\n\nWARNING: By selecting this tag,
your application will automatically update to use the latest version
available on OpenShift, including major version updates.\n",
"iconClass": "icon-test",
"tags": "test,test",
"version": "1"
},
"from": {
"kind": "ImageStreamTag",
"name": "1-el8"
},
"referencePolicy": {
"type": "Local"
}
}
]
}
generate_json_result = {
"kind": "ImageStream",
"apiVersion": "image.openshift.io/v1",
"metadata": {"name": "test", "annotations": {"openshift.io/display-name": "Test"}},
"spec": {
"tags": [
{
"name": "1-el8",
"annotations": {
"openshift.io/display-name": "Test 1 (RHEL 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "test description",
"iconClass": "icon-test",
"tags": "test,test",
"version": "1",
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/rhel8/test-1:latest",
},
"referencePolicy": {"type": "Local"},
},
{
"name": "latest",
"annotations": {
"openshift.io/display-name": "Test 1 (Latest)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": f"{description_msg}",
"iconClass": "icon-test",
"tags": "test,test",
"version": "1",
},
"from": {"kind": "ImageStreamTag", "name": "1-el8"},
"referencePolicy": {"type": "Local"},
},
]
},
}
"""
4 changes: 2 additions & 2 deletions ocp-stream-generator/tests/test_json_builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3

import json
import re
from stream_generator import JsonBuilder
from stream_generator import Tag
Expand Down Expand Up @@ -86,5 +86,5 @@ def test_generate_json():
}
isf_data = ImagestreamFile(file, header)
stripped_json = re.sub(r"[\n\t\s\\n]*", "", builder.generate_json(isf_data))
stripped_result = re.sub(r"[\n\t\s\\n]*", "", generate_json_result)
stripped_result = re.sub(r"[\n\t\s\\n]*", "", json.dumps(generate_json_result))
assert stripped_json == stripped_result

0 comments on commit b891c2f

Please sign in to comment.