diff --git a/.pylintrc b/.pylintrc index 75aef11..b413deb 100644 --- a/.pylintrc +++ b/.pylintrc @@ -43,97 +43,7 @@ confidence=HIGH # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use "--disable=all --enable=classes # --disable=W". -disable=too-many-arguments, - too-many-public-methods, - too-few-public-methods, - too-many-instance-attributes, - too-many-locals, - too-many-branches, - too-many-lines, - line-too-long, - bad-continuation, - similarities, - print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-error, - import-star-module-level, - non-ascii-bytes-literal, - raw-checker-failed, - bad-inline-option, - locally-disabled, - file-ignored, - suppressed-message, - useless-suppression, - deprecated-pragma, - use-symbolic-message-instead, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - deprecated-itertools-function, - deprecated-types-field, - next-method-defined, - dict-items-not-iterating, - dict-keys-not-iterating, - dict-values-not-iterating, - deprecated-operator-function, - deprecated-urllib-function, - xreadlines-attribute, - deprecated-sys-function, - exception-escape, - comprehension-escape, - invalid-name +disable=C0103,W0603 # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -572,5 +482,4 @@ valid-metaclass-classmethod-first-arg=cls # Exceptions that will emit a warning when being caught. Defaults to # "BaseException, Exception". -overgeneral-exceptions=BaseException, - Exception +overgeneral-exceptions=builtins.BaseException diff --git a/Makefile b/Makefile index f7f9f15..46d67be 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,10 @@ install_project: test: test-unit test-int test-unit: - python -m pytest test/unit + python -m pytest tests/unit test-int: - python -m pytest test/integration + python -m pytest tests/integration lint: ./pylint.sh diff --git a/build/testScript.sh b/build/testScript.sh index 059ad97..80369c8 100755 --- a/build/testScript.sh +++ b/build/testScript.sh @@ -1,4 +1,4 @@ #!/bin/bash set -euo pipefail echo "${SCC_ENV}" | base64 -d >> security_and_compliance_center_api_v3.env -python -m pytest test/integration +python -m pytest tests/integration diff --git a/examples/test_security_and_compliance_center_api_v3_examples.py b/examples/test_security_and_compliance_center_api_v3_examples.py index a4ad40f..4c31cc2 100644 --- a/examples/test_security_and_compliance_center_api_v3_examples.py +++ b/examples/test_security_and_compliance_center_api_v3_examples.py @@ -563,7 +563,7 @@ def test_get_profile_example(self): # begin-get_profile response = security_and_compliance_center_api_service.get_profile( - profiles_id=profile_id_link, + profile_id=profile_id_link, ) profile = response.get_result() @@ -598,7 +598,7 @@ def test_replace_profile_example(self): } response = security_and_compliance_center_api_service.replace_profile( - profiles_id=profile_id_link, + profile_id=profile_id_link, profile_name='test_profile1', profile_description='test_description1', profile_type='custom', @@ -752,7 +752,7 @@ def test_create_attachment_example(self): } response = security_and_compliance_center_api_service.create_attachment( - profiles_id=profile_id_link, + profile_id=profile_id_link, attachments=[attachments_prototype_model], ) attachment_prototype = response.get_result() @@ -777,7 +777,7 @@ def test_list_attachments_example(self): all_results = [] pager = AttachmentsPager( client=security_and_compliance_center_api_service, - profiles_id=profile_id_link, + profile_id=profile_id_link, x_correlation_id='testString', x_request_id='testString', limit=10, @@ -804,7 +804,7 @@ def test_get_profile_attachment_example(self): response = security_and_compliance_center_api_service.get_profile_attachment( attachment_id=attachment_id_link, - profiles_id=profile_id_link, + profile_id=profile_id_link, ) attachment_item = response.get_result() @@ -857,7 +857,7 @@ def test_replace_profile_attachment_example(self): response = security_and_compliance_center_api_service.replace_profile_attachment( attachment_id=attachment_id_link, - profiles_id=profile_id_link, + profile_id=profile_id_link, scope=[multi_cloud_scope_model], status='enabled', schedule='every_30_days', @@ -1340,7 +1340,7 @@ def test_delete_profile_attachment_example(self): response = security_and_compliance_center_api_service.delete_profile_attachment( attachment_id=attachment_id_link, - profiles_id=profile_id_link, + profile_id=profile_id_link, ) attachment_item = response.get_result() @@ -1361,7 +1361,7 @@ def test_delete_custom_profile_example(self): # begin-delete_custom_profile response = security_and_compliance_center_api_service.delete_custom_profile( - profiles_id=profile_id_link, + profile_id=profile_id_link, ) profile = response.get_result() diff --git a/ibm_scc/security_and_compliance_center_api_v3.py b/ibm_scc/security_and_compliance_center_api_v3.py index 2ea1d90..afcd680 100644 --- a/ibm_scc/security_and_compliance_center_api_v3.py +++ b/ibm_scc/security_and_compliance_center_api_v3.py @@ -901,7 +901,7 @@ def create_profile( def delete_custom_profile( self, - profiles_id: str, + profile_id: str, *, x_correlation_id: str = None, x_request_id: str = None, @@ -915,7 +915,7 @@ def delete_custom_profile( profiles, see [Building custom profiles](https://test.cloud.ibm.com/docs/security-compliance?topic=security-compliance-build-custom-profiles&interface=api). - :param str profiles_id: The profile ID. + :param str profile_id: The profile ID. :param str x_correlation_id: (optional) The supplied or generated value of this header is logged for a request and repeated in a response header for the corresponding response. The same value is used for downstream requests @@ -931,8 +931,8 @@ def delete_custom_profile( :rtype: DetailedResponse with `dict` result representing a `Profile` object """ - if not profiles_id: - raise ValueError('profiles_id must be provided') + if not profile_id: + raise ValueError('profile_id must be provided') headers = { 'X-Correlation-ID': x_correlation_id, 'X-Request-ID': x_request_id, @@ -949,10 +949,10 @@ def delete_custom_profile( del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['profiles_id'] - path_param_values = self.encode_path_vars(profiles_id) + path_param_keys = ['profile_id'] + path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/profiles/{profiles_id}'.format(**path_param_dict) + url = '/profiles/{profile_id}'.format(**path_param_dict) request = self.prepare_request( method='DELETE', url=url, @@ -964,7 +964,7 @@ def delete_custom_profile( def get_profile( self, - profiles_id: str, + profile_id: str, *, x_correlation_id: str = None, x_request_id: str = None, @@ -978,7 +978,7 @@ def get_profile( [Building custom profiles](https://test.cloud.ibm.com/docs/security-compliance?topic=security-compliance-build-custom-profiles&interface=api). - :param str profiles_id: The profile ID. + :param str profile_id: The profile ID. :param str x_correlation_id: (optional) The supplied or generated value of this header is logged for a request and repeated in a response header for the corresponding response. The same value is used for downstream requests @@ -994,8 +994,8 @@ def get_profile( :rtype: DetailedResponse with `dict` result representing a `Profile` object """ - if not profiles_id: - raise ValueError('profiles_id must be provided') + if not profile_id: + raise ValueError('profile_id must be provided') headers = { 'X-Correlation-ID': x_correlation_id, 'X-Request-ID': x_request_id, @@ -1012,10 +1012,10 @@ def get_profile( del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['profiles_id'] - path_param_values = self.encode_path_vars(profiles_id) + path_param_keys = ['profile_id'] + path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/profiles/{profiles_id}'.format(**path_param_dict) + url = '/profiles/{profile_id}'.format(**path_param_dict) request = self.prepare_request( method='GET', url=url, @@ -1027,7 +1027,7 @@ def get_profile( def replace_profile( self, - profiles_id: str, + profile_id: str, profile_name: str, profile_description: str, profile_type: str, @@ -1046,7 +1046,7 @@ def replace_profile( library as a starting point. For more information, see [Building custom profiles](https://test.cloud.ibm.com/docs/security-compliance?topic=security-compliance-build-custom-profiles&interface=api). - :param str profiles_id: The profile ID. + :param str profile_id: The profile ID. :param str profile_name: The name of the profile. :param str profile_description: The description of the profile. :param str profile_type: The profile type. @@ -1069,8 +1069,8 @@ def replace_profile( :rtype: DetailedResponse with `dict` result representing a `Profile` object """ - if not profiles_id: - raise ValueError('profiles_id must be provided') + if not profile_id: + raise ValueError('profile_id must be provided') if profile_name is None: raise ValueError('profile_name must be provided') if profile_description is None: @@ -1110,10 +1110,10 @@ def replace_profile( del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['profiles_id'] - path_param_values = self.encode_path_vars(profiles_id) + path_param_keys = ['profile_id'] + path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/profiles/{profiles_id}'.format(**path_param_dict) + url = '/profiles/{profile_id}'.format(**path_param_dict) request = self.prepare_request( method='PUT', url=url, @@ -1534,7 +1534,7 @@ def replace_rule( def list_attachments( self, - profiles_id: str, + profile_id: str, *, x_correlation_id: str = None, x_request_id: str = None, @@ -1551,7 +1551,7 @@ def list_attachments( information, see [Running an evaluation for IBM Cloud](https://test.cloud.ibm.com/docs/security-compliance?topic=security-compliance-scan-resources). - :param str profiles_id: The profile ID. + :param str profile_id: The profile ID. :param str x_correlation_id: (optional) The supplied or generated value of this header is logged for a request and repeated in a response header for the corresponding response. The same value is used for downstream requests @@ -1571,8 +1571,8 @@ def list_attachments( :rtype: DetailedResponse with `dict` result representing a `AttachmentCollection` object """ - if not profiles_id: - raise ValueError('profiles_id must be provided') + if not profile_id: + raise ValueError('profile_id must be provided') headers = { 'X-Correlation-ID': x_correlation_id, 'X-Request-ID': x_request_id, @@ -1594,10 +1594,10 @@ def list_attachments( del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['profiles_id'] - path_param_values = self.encode_path_vars(profiles_id) + path_param_keys = ['profile_id'] + path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/profiles/{profiles_id}/attachments'.format(**path_param_dict) + url = '/profiles/{profile_id}/attachments'.format(**path_param_dict) request = self.prepare_request( method='GET', url=url, @@ -1610,10 +1610,9 @@ def list_attachments( def create_attachment( self, - profiles_id: str, + profile_id: str, attachments: List['AttachmentsPrototype'], *, - profile_id: str = None, x_correlation_id: str = None, x_request_id: str = None, **kwargs, @@ -1626,7 +1625,7 @@ def create_attachment( [Running an evaluation for IBM Cloud](https://test.cloud.ibm.com/docs/security-compliance?topic=security-compliance-scan-resources). - :param str profiles_id: The profile ID. + :param str profile_id: The profile ID. :param List[AttachmentsPrototype] attachments: The array that displays all of the available attachments. :param str profile_id: (optional) The ID of the profile that is specified @@ -1646,8 +1645,8 @@ def create_attachment( :rtype: DetailedResponse with `dict` result representing a `AttachmentPrototype` object """ - if not profiles_id: - raise ValueError('profiles_id must be provided') + if not profile_id: + raise ValueError('profile_id must be provided') if attachments is None: raise ValueError('attachments must be provided') attachments = [convert_model(x) for x in attachments] @@ -1675,10 +1674,10 @@ def create_attachment( del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['profiles_id'] - path_param_values = self.encode_path_vars(profiles_id) + path_param_keys = ['profile_id'] + path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/profiles/{profiles_id}/attachments'.format(**path_param_dict) + url = '/profiles/{profile_id}/attachments'.format(**path_param_dict) request = self.prepare_request( method='POST', url=url, @@ -1692,7 +1691,7 @@ def create_attachment( def delete_profile_attachment( self, attachment_id: str, - profiles_id: str, + profile_id: str, *, x_correlation_id: str = None, x_request_id: str = None, @@ -1707,7 +1706,7 @@ def delete_profile_attachment( Cloud](https://test.cloud.ibm.com/docs/security-compliance?topic=security-compliance-scan-resources). :param str attachment_id: The attachment ID. - :param str profiles_id: The profile ID. + :param str profile_id: The profile ID. :param str x_correlation_id: (optional) The supplied or generated value of this header is logged for a request and repeated in a response header for the corresponding response. The same value is used for downstream requests @@ -1725,8 +1724,8 @@ def delete_profile_attachment( if not attachment_id: raise ValueError('attachment_id must be provided') - if not profiles_id: - raise ValueError('profiles_id must be provided') + if not profile_id: + raise ValueError('profile_id must be provided') headers = { 'X-Correlation-ID': x_correlation_id, 'X-Request-ID': x_request_id, @@ -1743,10 +1742,10 @@ def delete_profile_attachment( del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['attachment_id', 'profiles_id'] - path_param_values = self.encode_path_vars(attachment_id, profiles_id) + path_param_keys = ['attachment_id', 'profile_id'] + path_param_values = self.encode_path_vars(attachment_id, profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/profiles/{profiles_id}/attachments/{attachment_id}'.format(**path_param_dict) + url = '/profiles/{profile_id}/attachments/{attachment_id}'.format(**path_param_dict) request = self.prepare_request( method='DELETE', url=url, @@ -1759,7 +1758,7 @@ def delete_profile_attachment( def get_profile_attachment( self, attachment_id: str, - profiles_id: str, + profile_id: str, *, x_correlation_id: str = None, x_request_id: str = None, @@ -1774,7 +1773,7 @@ def get_profile_attachment( Cloud](https://test.cloud.ibm.com/docs/security-compliance?topic=security-compliance-scan-resources). :param str attachment_id: The attachment ID. - :param str profiles_id: The profile ID. + :param str profile_id: The profile ID. :param str x_correlation_id: (optional) The supplied or generated value of this header is logged for a request and repeated in a response header for the corresponding response. The same value is used for downstream requests @@ -1792,8 +1791,8 @@ def get_profile_attachment( if not attachment_id: raise ValueError('attachment_id must be provided') - if not profiles_id: - raise ValueError('profiles_id must be provided') + if not profile_id: + raise ValueError('profile_id must be provided') headers = { 'X-Correlation-ID': x_correlation_id, 'X-Request-ID': x_request_id, @@ -1810,10 +1809,10 @@ def get_profile_attachment( del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['attachment_id', 'profiles_id'] - path_param_values = self.encode_path_vars(attachment_id, profiles_id) + path_param_keys = ['attachment_id', 'profile_id'] + path_param_values = self.encode_path_vars(attachment_id, profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/profiles/{profiles_id}/attachments/{attachment_id}'.format(**path_param_dict) + url = '/profiles/{profile_id}/attachments/{attachment_id}'.format(**path_param_dict) request = self.prepare_request( method='GET', url=url, @@ -1826,10 +1825,9 @@ def get_profile_attachment( def replace_profile_attachment( self, attachment_id: str, - profiles_id: str, + profile_id: str, *, id: str = None, - profile_id: str = None, account_id: str = None, instance_id: str = None, scope: List['MultiCloudScope'] = None, @@ -1858,7 +1856,7 @@ def replace_profile_attachment( Cloud](https://test.cloud.ibm.com/docs/security-compliance?topic=security-compliance-scan-resources). :param str attachment_id: The attachment ID. - :param str profiles_id: The profile ID. + :param str profile_id: The profile ID. :param str id: (optional) The ID of the attachment. :param str profile_id: (optional) The ID of the profile that is specified in the attachment. @@ -1902,8 +1900,8 @@ def replace_profile_attachment( if not attachment_id: raise ValueError('attachment_id must be provided') - if not profiles_id: - raise ValueError('profiles_id must be provided') + if not profile_id: + raise ValueError('profile_id must be provided') if scope is not None: scope = [convert_model(x) for x in scope] if created_on is not None: @@ -1957,10 +1955,10 @@ def replace_profile_attachment( del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['attachment_id', 'profiles_id'] - path_param_values = self.encode_path_vars(attachment_id, profiles_id) + path_param_keys = ['attachment_id', 'profile_id'] + path_param_values = self.encode_path_vars(attachment_id, profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/profiles/{profiles_id}/attachments/{attachment_id}'.format(**path_param_dict) + url = '/profiles/{profile_id}/attachments/{attachment_id}'.format(**path_param_dict) request = self.prepare_request( method='PUT', url=url, @@ -12798,14 +12796,14 @@ def __init__( self, *, client: SecurityAndComplianceCenterApiV3, - profiles_id: str, + profile_id: str, x_correlation_id: str = None, x_request_id: str = None, limit: int = None, ) -> None: """ Initialize a AttachmentsPager object. - :param str profiles_id: The profile ID. + :param str profile_id: The profile ID. :param str x_correlation_id: (optional) The supplied or generated value of this header is logged for a request and repeated in a response header for the corresponding response. The same value is used for downstream requests @@ -12822,7 +12820,7 @@ def __init__( self._has_next = True self._client = client self._page_context = {'next': None} - self._profiles_id = profiles_id + self._profile_id = profile_id self._x_correlation_id = x_correlation_id self._x_request_id = x_request_id self._limit = limit @@ -12843,7 +12841,7 @@ def get_next(self) -> List[dict]: raise StopIteration(message='No more results available') result = self._client.list_attachments( - profiles_id=self._profiles_id, + profile_id=self._profile_id, x_correlation_id=self._x_correlation_id, x_request_id=self._x_request_id, limit=self._limit, diff --git a/pylint.sh b/pylint.sh index 0fc1705..acad535 100755 --- a/pylint.sh +++ b/pylint.sh @@ -1,3 +1,3 @@ #!/bin/bash -python -m pylint ibm_scc test --exit-zero +python -m pylint ibm_scc tests --exit-zero diff --git a/requirements-dev.txt b/requirements-dev.txt index b4468e3..849251e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,4 +5,5 @@ pylint>=2.6.0,<3.0.0 pytest>=6.2.1,<7.0.0 pytest-cov>=2.2.1,<3.0.0 pytest-rerunfailures>=3.1 -tox>=3.2.0,<4.0.0 +tox>=3.14.6,<4.0.0 +virtualenv>=20.0.20 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/__init__.py b/tests/integration/__init__.py similarity index 100% rename from test/integration/__init__.py rename to tests/integration/__init__.py diff --git a/test/integration/test_security_and_compliance_center_api_v3.py b/tests/integration/test_security_and_compliance_center_api_v3.py similarity index 94% rename from test/integration/test_security_and_compliance_center_api_v3.py rename to tests/integration/test_security_and_compliance_center_api_v3.py index a1e8e80..cf487f3 100644 --- a/test/integration/test_security_and_compliance_center_api_v3.py +++ b/tests/integration/test_security_and_compliance_center_api_v3.py @@ -26,26 +26,27 @@ config_file = 'security_and_compliance_center_api_v3.env' # Variables to hold link values -account_id_for_report_link = None -attachment_id_for_report_link = None -attachment_id_link = None -control_library_id_link = None -e_tag_link = None -event_notifications_crn_for_update_settings_link = None -group_id_for_report_link = None -object_storage_bucket_for_update_settings_link = None -object_storage_crn_for_update_settings_link = None -object_storage_location_for_update_settings_link = None -profile_id_for_report_link = None -profile_id_link = None -provider_type_id_link = None -provider_type_instance_id_link = None -report_id_for_report_link = None -rule_id_link = None -type_for_report_link = None -account_id = None -instance_id = None -create_scan_attachment_id = None +account_id_for_report_link = "" +attachment_id_for_report_link = "" +attachment_id_link = "" +control_library_id_link = "" +e_tag_link = "" +event_notifications_crn_for_update_settings_link = "" +group_id_for_report_link = "" +object_storage_bucket_for_update_settings_link = "" +object_storage_crn_for_update_settings_link = "" +object_storage_location_for_update_settings_link = "" +profile_id_for_report_link = "" +profile_id_link = "" +provider_type_id_link = "" +provider_type_instance_id_link = "" +report_id_for_report_link = "" +rule_id_link = "" +type_for_report_link = "" +account_id = "" +instance_id = "" +create_scan_attachment_id = "" + class TestSecurityAndComplianceCenterApiV3: """ @@ -60,11 +61,13 @@ def setup_class(cls): ) assert cls.security_and_compliance_center_api_service is not None - cls.config = read_external_sources(SecurityAndComplianceCenterApiV3.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources( + SecurityAndComplianceCenterApiV3.DEFAULT_SERVICE_NAME) assert cls.config is not None - cls.account_id=cls.config['ACCOUNTID'] + cls.account_id = cls.config['ACCOUNTID'] cls.instance_id = cls.config['INSTANCEID'] - if cls.instance_id == "": print("Unable to load instanceID configuration property, skipping tests") + if cls.instance_id == "": + print("Unable to load instanceID configuration property, skipping tests") cls.create_scan_attachment_id = cls.config['ATTACHMENTID'] cls.security_and_compliance_center_api_service.enable_retries() @@ -90,10 +93,12 @@ def test_get_settings(self): settings = response.get_result() assert settings is not None - event_notifications_crn_for_update_settings_link = settings['event_notifications']['instance_crn'] + event_notifications_crn_for_update_settings_link = settings[ + 'event_notifications']['instance_crn'] object_storage_crn_for_update_settings_link = settings['object_storage']['instance_crn'] object_storage_bucket_for_update_settings_link = settings['object_storage']['bucket'] - object_storage_location_for_update_settings_link = settings['object_storage']['bucket_location'] + object_storage_location_for_update_settings_link = settings[ + 'object_storage']['bucket_location'] @needscredentials def test_create_rule(self): @@ -346,7 +351,8 @@ def test_list_control_libraries_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_control_libraries() returned a total of {len(all_results)} items(s) using ControlLibrariesPager.') + print( + f'\nlist_control_libraries() returned a total of {len(all_results)} items(s) using ControlLibrariesPager.') @needscredentials def test_get_control_library(self): @@ -509,12 +515,13 @@ def test_list_profiles_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_profiles() returned a total of {len(all_results)} items(s) using ProfilesPager.') + print( + f'\nlist_profiles() returned a total of {len(all_results)} items(s) using ProfilesPager.') @needscredentials def test_get_profile(self): response = self.security_and_compliance_center_api_service.get_profile( - profiles_id=profile_id_link, + profile_id=profile_id_link, x_correlation_id='testString', x_request_id='testString', ) @@ -541,7 +548,7 @@ def test_replace_profile(self): } response = self.security_and_compliance_center_api_service.replace_profile( - profiles_id=profile_id_link, + profile_id=profile_id_link, profile_name='test_profile1', profile_description='test_description1', profile_type='custom', @@ -675,14 +682,12 @@ def test_create_attachment(self): 'attachment_parameters': [attachment_parameter_prototype_model], } response = self.security_and_compliance_center_api_service.create_attachment( - profiles_id=profile_id_link, - attachments=[attachments_prototype_model], profile_id=profile_id_link, + attachments=[attachments_prototype_model], x_correlation_id='testString', x_request_id='testString', ) - assert response.get_status_code() == 201 attachment_prototype = response.get_result() assert attachment_prototype is not None @@ -692,7 +697,7 @@ def test_create_attachment(self): @needscredentials def test_list_attachments(self): response = self.security_and_compliance_center_api_service.list_attachments( - profiles_id=profile_id_link, + profile_id=profile_id_link, x_correlation_id='testString', x_request_id='testString', limit=50, @@ -708,7 +713,7 @@ def test_list_attachments_with_pager(self): # Test get_next(). pager = AttachmentsPager( client=self.security_and_compliance_center_api_service, - profiles_id=profile_id_link, + profile_id=profile_id_link, x_correlation_id='testString', x_request_id='testString', limit=10, @@ -721,7 +726,7 @@ def test_list_attachments_with_pager(self): # Test get_all(). pager = AttachmentsPager( client=self.security_and_compliance_center_api_service, - profiles_id=profile_id_link, + profile_id=profile_id_link, x_correlation_id='testString', x_request_id='testString', limit=10, @@ -730,13 +735,14 @@ def test_list_attachments_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_attachments() returned a total of {len(all_results)} items(s) using AttachmentsPager.') + print( + f'\nlist_attachments() returned a total of {len(all_results)} items(s) using AttachmentsPager.') @needscredentials def test_get_profile_attachment(self): response = self.security_and_compliance_center_api_service.get_profile_attachment( attachment_id=attachment_id_link, - profiles_id=profile_id_link, + profile_id=profile_id_link, x_correlation_id='testString', x_request_id='testString', ) @@ -789,9 +795,8 @@ def test_replace_profile_attachment(self): response = self.security_and_compliance_center_api_service.replace_profile_attachment( attachment_id=attachment_id_link, - profiles_id=profile_id_link, - id='testString', profile_id=profile_id_link, + id='testString', account_id=account_id, instance_id=instance_id, scope=[multi_cloud_scope_model], @@ -823,8 +828,8 @@ def test_create_scan(self): x_correlation_id='testString', x_request_id='testString', ) - except Exception as e: - if 'another scan is currently in progress' in str(e).lower(): + except Exception as e: + if 'another scan is currently in progress' in str(e).lower(): return assert response.get_status_code() == 201 scan = response.get_result() @@ -867,7 +872,8 @@ def test_list_attachments_account_with_pager(self): all_items = pager.get_all() assert all_items is not None - print(f'\nlist_attachments_account() returned a total of {len(all_results)} items(s) using AttachmentsAccountPager.') + print( + f'\nlist_attachments_account() returned a total of {len(all_results)} items(s) using AttachmentsAccountPager.') @needscredentials def test_list_reports(self): @@ -922,7 +928,8 @@ def test_list_reports_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_reports() returned a total of {len(all_results)} items(s) using ReportsPager.') + print( + f'\nlist_reports() returned a total of {len(all_results)} items(s) using ReportsPager.') @needscredentials def test_get_report(self): @@ -1040,24 +1047,25 @@ def test_list_report_evaluations_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_report_evaluations() returned a total of {len(all_results)} items(s) using ReportEvaluationsPager.') - - @needscredentials - def test_list_report_resources(self): - response = self.security_and_compliance_center_api_service.list_report_resources( - report_id=report_id_for_report_link, - x_correlation_id='testString', - x_request_id='testString', - id='testString', - resource_name='testString', - account_id=account_id_for_report_link, - component_id='testString', - status='compliant', - sort='account_id', - limit=50, - ) - assert response.get_status_code() == 200 - resource_page = response.get_result() + print( + f'\nlist_report_evaluations() returned a total of {len(all_results)} items(s) using ReportEvaluationsPager.') + + @needscredentials + def test_list_report_resources(self): + response = self.security_and_compliance_center_api_service.list_report_resources( + report_id=report_id_for_report_link, + x_correlation_id='testString', + x_request_id='testString', + id='testString', + resource_name='testString', + account_id=account_id_for_report_link, + component_id='testString', + status='compliant', + sort='account_id', + limit=50, + ) + assert response.get_status_code() == 200 + resource_page = response.get_result() assert resource_page is not None @needscredentials @@ -1098,7 +1106,8 @@ def test_list_report_resources_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_report_resources() returned a total of {len(all_results)} items(s) using ReportResourcesPager.') + print( + f'\nlist_report_resources() returned a total of {len(all_results)} items(s) using ReportResourcesPager.') @needscredentials def test_get_report_tags(self): @@ -1222,12 +1231,12 @@ def test_get_provider_types_instances(self): assert response.get_status_code() == 200 provider_types_instances_response = response.get_result() assert provider_types_instances_response is not None - + @needscredentials def test_delete_profile_attachment(self): response = self.security_and_compliance_center_api_service.delete_profile_attachment( attachment_id=attachment_id_link, - profiles_id=profile_id_link, + profile_id=profile_id_link, x_correlation_id='testString', x_request_id='testString', ) @@ -1239,7 +1248,7 @@ def test_delete_profile_attachment(self): @needscredentials def test_delete_custom_profile(self): response = self.security_and_compliance_center_api_service.delete_custom_profile( - profiles_id=profile_id_link, + profile_id=profile_id_link, x_correlation_id='testString', x_request_id='testString', ) diff --git a/test/unit/__init__.py b/tests/unit/__init__.py similarity index 100% rename from test/unit/__init__.py rename to tests/unit/__init__.py diff --git a/test/unit/test_common.py b/tests/unit/test_common.py similarity index 100% rename from test/unit/test_common.py rename to tests/unit/test_common.py diff --git a/test/unit/test_security_and_compliance_center_api_v3.py b/tests/unit/test_security_and_compliance_center_api_v3.py similarity index 99% rename from test/unit/test_security_and_compliance_center_api_v3.py rename to tests/unit/test_security_and_compliance_center_api_v3.py index 98bb3ef..70b5ea6 100644 --- a/test/unit/test_security_and_compliance_center_api_v3.py +++ b/tests/unit/test_security_and_compliance_center_api_v3.py @@ -1962,13 +1962,13 @@ def test_delete_custom_profile_all_params(self): ) # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' x_correlation_id = 'testString' x_request_id = 'testString' # Invoke method response = _service.delete_custom_profile( - profiles_id, + profile_id, x_correlation_id=x_correlation_id, x_request_id=x_request_id, headers={}, @@ -2004,11 +2004,11 @@ def test_delete_custom_profile_required_params(self): ) # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' # Invoke method response = _service.delete_custom_profile( - profiles_id, + profile_id, headers={}, ) @@ -2042,11 +2042,11 @@ def test_delete_custom_profile_value_error(self): ) # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { - "profiles_id": profiles_id, + "profile_id": profile_id, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} @@ -2085,13 +2085,13 @@ def test_get_profile_all_params(self): ) # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' x_correlation_id = 'testString' x_request_id = 'testString' # Invoke method response = _service.get_profile( - profiles_id, + profile_id, x_correlation_id=x_correlation_id, x_request_id=x_request_id, headers={}, @@ -2127,11 +2127,11 @@ def test_get_profile_required_params(self): ) # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' # Invoke method response = _service.get_profile( - profiles_id, + profile_id, headers={}, ) @@ -2165,11 +2165,11 @@ def test_get_profile_value_error(self): ) # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { - "profiles_id": profiles_id, + "profile_id": profile_id, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} @@ -2222,7 +2222,7 @@ def test_replace_profile_all_params(self): default_parameters_prototype_model['parameter_type'] = 'numeric' # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' profile_name = 'test_profile1' profile_description = 'test_description1' profile_type = 'custom' @@ -2233,7 +2233,7 @@ def test_replace_profile_all_params(self): # Invoke method response = _service.replace_profile( - profiles_id, + profile_id, profile_name, profile_description, profile_type, @@ -2295,7 +2295,7 @@ def test_replace_profile_required_params(self): default_parameters_prototype_model['parameter_type'] = 'numeric' # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' profile_name = 'test_profile1' profile_description = 'test_description1' profile_type = 'custom' @@ -2304,7 +2304,7 @@ def test_replace_profile_required_params(self): # Invoke method response = _service.replace_profile( - profiles_id, + profile_id, profile_name, profile_description, profile_type, @@ -2364,7 +2364,7 @@ def test_replace_profile_value_error(self): default_parameters_prototype_model['parameter_type'] = 'numeric' # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' profile_name = 'test_profile1' profile_description = 'test_description1' profile_type = 'custom' @@ -2373,7 +2373,7 @@ def test_replace_profile_value_error(self): # Pass in all but one required param and check for a ValueError req_param_dict = { - "profiles_id": profiles_id, + "profile_id": profile_id, "profile_name": profile_name, "profile_description": profile_description, "profile_type": profile_type, @@ -3396,7 +3396,7 @@ def test_list_attachments_all_params(self): ) # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' x_correlation_id = 'testString' x_request_id = 'testString' limit = 50 @@ -3404,7 +3404,7 @@ def test_list_attachments_all_params(self): # Invoke method response = _service.list_attachments( - profiles_id, + profile_id, x_correlation_id=x_correlation_id, x_request_id=x_request_id, limit=limit, @@ -3447,11 +3447,11 @@ def test_list_attachments_required_params(self): ) # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' # Invoke method response = _service.list_attachments( - profiles_id, + profile_id, headers={}, ) @@ -3485,11 +3485,11 @@ def test_list_attachments_value_error(self): ) # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { - "profiles_id": profiles_id, + "profile_id": profile_id, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} @@ -3533,7 +3533,7 @@ def test_list_attachments_with_pager_get_next(self): all_results = [] pager = AttachmentsPager( client=_service, - profiles_id='testString', + profile_id='testString', x_correlation_id='testString', x_request_id='testString', limit=10, @@ -3571,7 +3571,7 @@ def test_list_attachments_with_pager_get_all(self): # Exercise the pager class for this operation pager = AttachmentsPager( client=_service, - profiles_id='testString', + profile_id='testString', x_correlation_id='testString', x_request_id='testString', limit=10, @@ -3643,7 +3643,7 @@ def test_create_attachment_all_params(self): attachments_prototype_model['attachment_parameters'] = [attachment_parameter_prototype_model] # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' attachments = [attachments_prototype_model] profile_id = 'testString' x_correlation_id = 'testString' @@ -3651,9 +3651,8 @@ def test_create_attachment_all_params(self): # Invoke method response = _service.create_attachment( - profiles_id, + profile_id, attachments, - profile_id=profile_id, x_correlation_id=x_correlation_id, x_request_id=x_request_id, headers={}, @@ -3733,15 +3732,14 @@ def test_create_attachment_required_params(self): attachments_prototype_model['attachment_parameters'] = [attachment_parameter_prototype_model] # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' attachments = [attachments_prototype_model] profile_id = 'testString' # Invoke method response = _service.create_attachment( - profiles_id, + profile_id, attachments, - profile_id=profile_id, headers={}, ) @@ -3819,13 +3817,13 @@ def test_create_attachment_value_error(self): attachments_prototype_model['attachment_parameters'] = [attachment_parameter_prototype_model] # Set up parameter values - profiles_id = 'testString' + profile_id = 'testString' attachments = [attachments_prototype_model] profile_id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { - "profiles_id": profiles_id, + "profile_id": profile_id, "attachments": attachments, } for param in req_param_dict.keys(): @@ -3866,14 +3864,14 @@ def test_delete_profile_attachment_all_params(self): # Set up parameter values attachment_id = 'testString' - profiles_id = 'testString' + profile_id = 'testString' x_correlation_id = 'testString' x_request_id = 'testString' # Invoke method response = _service.delete_profile_attachment( attachment_id, - profiles_id, + profile_id, x_correlation_id=x_correlation_id, x_request_id=x_request_id, headers={}, @@ -3910,12 +3908,12 @@ def test_delete_profile_attachment_required_params(self): # Set up parameter values attachment_id = 'testString' - profiles_id = 'testString' + profile_id = 'testString' # Invoke method response = _service.delete_profile_attachment( attachment_id, - profiles_id, + profile_id, headers={}, ) @@ -3950,12 +3948,12 @@ def test_delete_profile_attachment_value_error(self): # Set up parameter values attachment_id = 'testString' - profiles_id = 'testString' + profile_id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { "attachment_id": attachment_id, - "profiles_id": profiles_id, + "profile_id": profile_id, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} @@ -3995,14 +3993,14 @@ def test_get_profile_attachment_all_params(self): # Set up parameter values attachment_id = 'testString' - profiles_id = 'testString' + profile_id = 'testString' x_correlation_id = 'testString' x_request_id = 'testString' # Invoke method response = _service.get_profile_attachment( attachment_id, - profiles_id, + profile_id, x_correlation_id=x_correlation_id, x_request_id=x_request_id, headers={}, @@ -4039,12 +4037,12 @@ def test_get_profile_attachment_required_params(self): # Set up parameter values attachment_id = 'testString' - profiles_id = 'testString' + profile_id = 'testString' # Invoke method response = _service.get_profile_attachment( attachment_id, - profiles_id, + profile_id, headers={}, ) @@ -4079,12 +4077,12 @@ def test_get_profile_attachment_value_error(self): # Set up parameter values attachment_id = 'testString' - profiles_id = 'testString' + profile_id = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { "attachment_id": attachment_id, - "profiles_id": profiles_id, + "profile_id": profile_id, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} @@ -4159,9 +4157,8 @@ def test_replace_profile_attachment_all_params(self): # Set up parameter values attachment_id = 'testString' - profiles_id = 'testString' - id = 'testString' profile_id = 'testString' + id = 'testString' account_id = 'testString' instance_id = 'testString' scope = [multi_cloud_scope_model] @@ -4183,9 +4180,8 @@ def test_replace_profile_attachment_all_params(self): # Invoke method response = _service.replace_profile_attachment( attachment_id, - profiles_id, + profile_id, id=id, - profile_id=profile_id, account_id=account_id, instance_id=instance_id, scope=scope, @@ -4291,7 +4287,7 @@ def test_replace_profile_attachment_required_params(self): # Set up parameter values attachment_id = 'testString' - profiles_id = 'testString' + profile_id = 'testString' id = 'testString' profile_id = 'testString' account_id = 'testString' @@ -4313,9 +4309,8 @@ def test_replace_profile_attachment_required_params(self): # Invoke method response = _service.replace_profile_attachment( attachment_id, - profiles_id, + profile_id, id=id, - profile_id=profile_id, account_id=account_id, instance_id=instance_id, scope=scope, @@ -4419,7 +4414,7 @@ def test_replace_profile_attachment_value_error(self): # Set up parameter values attachment_id = 'testString' - profiles_id = 'testString' + profile_id = 'testString' id = 'testString' profile_id = 'testString' account_id = 'testString' @@ -4441,7 +4436,7 @@ def test_replace_profile_attachment_value_error(self): # Pass in all but one required param and check for a ValueError req_param_dict = { "attachment_id": attachment_id, - "profiles_id": profiles_id, + "profile_id": profile_id, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} diff --git a/tox.ini b/tox.ini index 35cf731..8da3198 100644 --- a/tox.ini +++ b/tox.ini @@ -7,15 +7,15 @@ python = 3.10: py310 3.11: py311 -[testenv:py37-lint] +[testenv:py39-lint] basepython = python3.9 deps = pylint -commands = pylint --rcfile=.pylintrc ibm_scc test/unit test/integration examples +commands = pylint --rcfile=.pylintrc ibm_scc tests/unit tests/integration examples [testenv] passenv = TOXENV CI TRAVIS* ACCOUNT_ID PROVIDER_ID commands = - py.test --reruns 3 --cov=ibm_scc {posargs} test/unit --cov-report=xml + py.test --reruns 3 --cov=ibm_scc {posargs} tests/unit --cov-report=xml deps = -r{toxinidir}/requirements.txt -r{toxinidir}/requirements-dev.txt