Skip to content

Commit 9b012a8

Browse files
committed
fixes for sanity and sap_company unit
1 parent 7c678da commit 9b012a8

12 files changed

Lines changed: 74 additions & 113 deletions

File tree

.github/workflows/ansible-test.yml

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ name: CI
22
on:
33
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
44
push:
5+
branches:
6+
- main
7+
- dev
58
pull_request:
69
# Run CI once per day (at 06:00 UTC)
710
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version
811
schedule:
912
- cron: '0 6 * * *'
13+
workflow_dispatch:
1014
env:
1115
NAMESPACE: community
1216
COLLECTION_NAME: sap_libs
@@ -17,8 +21,6 @@ jobs:
1721
strategy:
1822
matrix:
1923
ansible:
20-
- stable-2.13
21-
- stable-2.14
2224
- stable-2.15
2325
- stable-2.16
2426
- stable-2.17
@@ -35,7 +37,7 @@ jobs:
3537
- name: Check out code
3638
uses: actions/checkout@v4
3739

38-
- name: Perform sanity testing with ansible-test
40+
- name: Perform sanity testing
3941
uses: ansible-community/ansible-test-gh-action@release/v1
4042
with:
4143
ansible-core-version: ${{ matrix.ansible }}
@@ -53,8 +55,6 @@ jobs:
5355
fail-fast: true
5456
matrix:
5557
ansible:
56-
- stable-2.13
57-
- stable-2.14
5858
- stable-2.15
5959
- stable-2.16
6060
- stable-2.17
@@ -63,62 +63,14 @@ jobs:
6363
- devel
6464

6565
steps:
66+
6667
- name: Check out code
6768
uses: actions/checkout@v4
6869

69-
- name: Perform unit testing with ansible-test
70+
- name: Perform unit testing
7071
uses: ansible-community/ansible-test-gh-action@release/v1
7172
with:
7273
ansible-core-version: ${{ matrix.ansible }}
7374
testing-type: units
74-
# test-deps: >-
75-
# ansible.netcommon
76-
# ansible.utils
77-
78-
# Please consult the Readme for information on why we disabled integration tests temporarily.
79-
80-
# integration:
81-
# runs-on: ubuntu-latest
82-
# name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }})
83-
# strategy:
84-
# fail-fast: false
85-
# matrix:
86-
# ansible:
87-
# - stable-2.9 # Only if your collection supports Ansible 2.9
88-
# - stable-2.10
89-
# - stable-2.11
90-
# - stable-2.12
91-
# - stable-2.13
92-
# - devel
93-
# python:
94-
# - 2.6
95-
# - 2.7
96-
# - 3.5
97-
# - 3.6
98-
# - 3.7
99-
# - 3.8
100-
# - 3.9
101-
# exclude:
102-
# # Because ansible-test doesn't support python3.9 for Ansible 2.9
103-
# - ansible: stable-2.9
104-
# python: 3.9
105-
# - ansible: devel
106-
# python: 2.6
107-
108-
# steps:
109-
# - name: Check out code
110-
# uses: actions/checkout@v3
11175

112-
# - name: Perform integration testing with ansible-test
113-
# uses: ansible-community/ansible-test-gh-action@release/v1
114-
# with:
115-
# ansible-core-version: ${{ matrix.ansible }}
116-
# python-version: 3.8
117-
# pre-test-cmd: >-
118-
# mkdir -p tests/output/
119-
# touch tests/output/coverage
120-
# target-python-version: ${{ matrix.python }}
121-
# testing-type: integration
122-
# test-deps: >-
123-
# ansible.netcommon
124-
# ansible.utils
76+
# Please consult the Readme for information on why we disabled integration tests temporarily.

changelogs/changelog.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ releases:
123123
in this collection that have been made after the previous release.
124124
fragments:
125125
- 30-fix-lint-issues.yml
126-
release_date: '2024-23-01'
126+
release_date: '2024-01-23'

plugins/modules/sap_hdbsql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152

153153
import csv
154154
from ansible.module_utils.basic import AnsibleModule
155-
from ansible.module_utils.six import StringIO
155+
from io import StringIO
156156
from ansible.module_utils.common.text.converters import to_native
157157

158158

tests/sanity/ignore-2.17.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed u
66
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
77
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
88
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
9-
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
10-
tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2
9+
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0

tests/sanity/ignore-2.18.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed u
66
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
77
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
88
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
9-
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
10-
tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2
9+
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0

tests/sanity/ignore-2.19.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
2+
plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
3+
plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
4+
plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
5+
plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
6+
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
7+
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
8+
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
9+
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0

tests/sanity/ignore-2.20.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
2+
plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
3+
plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
4+
plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
5+
plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
6+
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
7+
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
8+
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
9+
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0

tests/unit/compat/mock.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def _iterate_read_data(read_data):
5151
# newline that our naive format() added
5252
data_as_list[-1] = data_as_list[-1][:-1]
5353

54-
for line in data_as_list:
55-
yield line
54+
yield from data_as_list
5655

5756
def mock_open(mock=None, read_data=''):
5857
"""
@@ -80,8 +79,7 @@ def _readline_side_effect():
8079
if handle.readline.return_value is not None:
8180
while True:
8281
yield handle.readline.return_value
83-
for line in _data:
84-
yield line
82+
yield from _data
8583

8684
global file_spec
8785
if file_spec is None:

tests/unit/mock/procenv.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from contextlib import contextmanager
1313
from io import BytesIO, StringIO
1414
from ansible_collections.community.general.tests.unit.compat import unittest
15-
from ansible.module_utils.six import PY3
1615
from ansible.module_utils.common.text.converters import to_bytes
1716

1817

@@ -24,11 +23,8 @@ def swap_stdin_and_argv(stdin_data='', argv_data=tuple()):
2423
real_stdin = sys.stdin
2524
real_argv = sys.argv
2625

27-
if PY3:
28-
fake_stream = StringIO(stdin_data)
29-
fake_stream.buffer = BytesIO(to_bytes(stdin_data))
30-
else:
31-
fake_stream = BytesIO(to_bytes(stdin_data))
26+
fake_stream = StringIO(stdin_data)
27+
fake_stream.buffer = BytesIO(to_bytes(stdin_data))
3228

3329
try:
3430
sys.stdin = fake_stream
@@ -47,10 +43,7 @@ def swap_stdout():
4743
"""
4844
old_stdout = sys.stdout
4945

50-
if PY3:
51-
fake_stream = StringIO()
52-
else:
53-
fake_stream = BytesIO()
46+
fake_stream = StringIO()
5447

5548
try:
5649
sys.stdout = fake_stream

tests/unit/mock/yaml_helper.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ def _loader(self, stream):
2121

2222
def _dump_stream(self, obj, stream, dumper=None):
2323
"""Dump to a py2-unicode or py3-string stream."""
24-
if PY3:
25-
return yaml.dump(obj, stream, Dumper=dumper)
26-
else:
27-
return yaml.dump(obj, stream, Dumper=dumper, encoding=None)
24+
return yaml.dump(obj, stream, Dumper=dumper)
2825

2926
def _dump_string(self, obj, dumper=None):
3027
"""Dump to a py2-unicode or py3-string"""
31-
if PY3:
32-
return yaml.dump(obj, Dumper=dumper)
33-
else:
34-
return yaml.dump(obj, Dumper=dumper, encoding=None)
28+
return yaml.dump(obj, Dumper=dumper)
3529

3630
def _dump_load_cycle(self, obj):
3731
# Each pass though a dump or load revs the 'generation'
@@ -89,25 +83,17 @@ def _old_dump_load_cycle(self, obj):
8983
stream_obj_from_stream = io.StringIO()
9084
stream_obj_from_string = io.StringIO()
9185

92-
if PY3:
93-
yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
94-
yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)
95-
else:
96-
yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper, encoding=None)
97-
yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper, encoding=None)
86+
yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
87+
yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)
9888

9989
yaml_string_stream_obj_from_stream = stream_obj_from_stream.getvalue()
10090
yaml_string_stream_obj_from_string = stream_obj_from_string.getvalue()
10191

10292
stream_obj_from_stream.seek(0)
10393
stream_obj_from_string.seek(0)
10494

105-
if PY3:
106-
yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
107-
yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)
108-
else:
109-
yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper, encoding=None)
110-
yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper, encoding=None)
95+
yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
96+
yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)
11197

11298
assert yaml_string == yaml_string_obj_from_stream
11399
assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string

0 commit comments

Comments
 (0)