@@ -165,6 +165,60 @@ def test_validate_invalid_ocp_version_failure(self):
165165 self .assertIn ("Invalid semver in ocpfournine" , playbook_command .stdout .decode ("utf-8" ))
166166 self .assertIn ("Error collecting OCP version range from Pyxis" , playbook_command .stdout .decode ("utf-8" ))
167167
168+ def test_extract_operator_bundle_no_subscription (self ):
169+ operator_work_dir = "{}/test_extract_operator_bundle_no_subscription" .format (self .test_dir )
170+ work_dir = operator_work_dir
171+ operator_dir = "{}/test-operator" .format (operator_work_dir )
172+ operator_bundle_dir = "{}/operator-bundle" .format (operator_work_dir )
173+ bundle_image = "quay.io/cvpops/test-operator:test-430-channel-positive-v1"
174+ exec_cmd = "ansible-playbook -vvv -i localhost, --connection local \
175+ operator-test-playbooks/extract-operator-bundle.yml \
176+ -e 'operator_dir={operator_dir}' \
177+ -e 'bundle_image={bundle_image}' \
178+ -e 'operator_work_dir={operator_work_dir}' \
179+ -e 'operator_bundle_dir={operator_bundle_dir}' \
180+ -e 'work_dir={work_dir}'" .format (operator_dir = operator_dir ,
181+ operator_work_dir = operator_work_dir ,
182+ operator_bundle_dir = operator_bundle_dir ,
183+ bundle_image = bundle_image ,
184+ work_dir = work_dir )
185+ playbook_command = subprocess .run (exec_cmd , shell = True )
186+
187+ print (playbook_command .returncode )
188+ self .assertTrue (playbook_command .returncode == 0 )
189+ self .assertTrue (path .exists ("{}/parsed_operator_data.yml" .format (work_dir )))
190+ with open ("{}/parsed_operator_data.yml" .format (work_dir ), "r" ) as fd :
191+ parsed_output = fd .read ()
192+ print (parsed_output )
193+ self .assertIn ('operator_valid_subscription: []' , parsed_output )
194+
195+ def test_extract_operator_bundle_with_subscription (self ):
196+ operator_work_dir = "{}/test_extract_operator_bundle_with_subscription" .format (self .test_dir )
197+ work_dir = operator_work_dir
198+ operator_dir = "{}/test-operator" .format (operator_work_dir )
199+ operator_bundle_dir = "{}/operator-bundle" .format (operator_work_dir )
200+ bundle_image = "quay.io/cvpops/test-operator:with-subscription"
201+ exec_cmd = "ansible-playbook -vvv -i localhost, --connection local \
202+ operator-test-playbooks/extract-operator-bundle.yml \
203+ -e 'operator_dir={operator_dir}' \
204+ -e 'bundle_image={bundle_image}' \
205+ -e 'operator_work_dir={operator_work_dir}' \
206+ -e 'operator_bundle_dir={operator_bundle_dir}' \
207+ -e 'work_dir={work_dir}'" .format (operator_dir = operator_dir ,
208+ operator_work_dir = operator_work_dir ,
209+ operator_bundle_dir = operator_bundle_dir ,
210+ bundle_image = bundle_image ,
211+ work_dir = work_dir )
212+ playbook_command = subprocess .run (exec_cmd , shell = True )
213+
214+ print (playbook_command .returncode )
215+ self .assertTrue (playbook_command .returncode == 0 )
216+ self .assertTrue (path .exists ("{}/parsed_operator_data.yml" .format (work_dir )))
217+ with open ("{}/parsed_operator_data.yml" .format (work_dir ), "r" ) as fd :
218+ parsed_output = fd .read ()
219+ print (parsed_output )
220+ self .assertIn ('operator_valid_subscription:\n - "Test Subscription One"\n - "Test Subscription Two"' , parsed_output )
221+
168222
169223if __name__ == '__main__' :
170224 unittest .main ()
0 commit comments