Skip to content

Commit

Permalink
Naming and Docstring Updates
Browse files Browse the repository at this point in the history
Signed-off-by: Elijah Swift <elijah.swift@ibm.com>
  • Loading branch information
ElijahSwiftIBM committed Dec 4, 2023
1 parent 000b71f commit 04c028d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions pyracf/common/downstream_fatal_error.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Exception to use when no data is returned by IRRSMO00."""
"""Exception to use when IRRSMO00 returns with an error."""
from typing import Union


class DownstreamFatalError(Exception):
"""
Raised when no xml string is returned by IRRSMO00.
Raised IRRSMO00 returns with a return code of 8, indicating an error occured prior to request.
"""

def __init__(
Expand Down
6 changes: 3 additions & 3 deletions tests/common/test_common_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ def get_sample(sample_file: str, function_group: str) -> Union[str, bytes]:
"add_resource_result_precheck_uacc_none_success.json", "resource"
)

TEST_INSTALL_PRECHECK_VALIDATED_ACCESS_TEXT = (
TEST_SETUP_PRECHECK_VALIDATED_ACCESS_TEXT = (
"IRR.IRRSMO00.PRECHECK is already defined, and you already have alter access!"
+ "\nYou are ready to start using pyRACF!"
+ "\nPlease ensure other users of pyRACF also have at least read access."
+ "\nReview our documentation at https://ambitus.github.io/pyracf/ as well!\n"
)

TEST_INSTALL_PRECHECK_FOUND_NO_ACCESS_TEXT = (
TEST_SETUP_PRECHECK_FOUND_NO_ACCESS_TEXT = (
"IRR.IRRSMO00.PRECHECK is already defined, but you have no access."
+ "\nContact your security administrator for READ access before using pyRACF."
+ "\nReview our documentation at https://ambitus.github.io/pyracf/ as well!\n"
)

TEST_INSTALL_PRECHECK_DEFINED_PROFILE_TEXT = (
TEST_SETUP_PRECHECK_DEFINED_PROFILE_TEXT = (
"IRR.IRRSMO00.PRECHECK is now defined with a `Universal Access` of None."
+ "\nContact your security administrator for READ access before using pyRACF."
+ "\nOther users of pyRACF will also need to have at least read access."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@


@patch("pyracf.common.irrsmo00.IRRSMO00.call_racf")
class TestInstallPrecheckScript(unittest.TestCase):
class TestSetupPrecheck(unittest.TestCase):
maxDiff = None
IRRSMO00.__init__ = Mock(return_value=None)
ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")

def test_install_precheck_works_when_no_setup_done(
def test_setup_precheck_works_when_no_setup_done(
self,
call_racf_mock: Mock,
):
Expand All @@ -36,14 +36,14 @@ def test_install_precheck_works_when_no_setup_done(
result = setup_precheck()
precheck_log = self.ansi_escape.sub("", stdout.getvalue())
self.assertEqual(
precheck_log, TestCommonConstants.TEST_INSTALL_PRECHECK_DEFINED_PROFILE_TEXT
precheck_log, TestCommonConstants.TEST_SETUP_PRECHECK_DEFINED_PROFILE_TEXT
)
self.assertEqual(
result,
TestCommonConstants.TEST_ADD_RESOURCE_PRECHECK_UACC_NONE_SUCCESS_DICTIONARY,
)

def test_install_precheck_works_when_alter_access_exists(
def test_setup_precheck_works_when_alter_access_exists(
self,
call_racf_mock: Mock,
):
Expand All @@ -56,11 +56,11 @@ def test_install_precheck_works_when_alter_access_exists(
precheck_log = self.ansi_escape.sub("", stdout.getvalue())
self.assertEqual(
precheck_log,
TestCommonConstants.TEST_INSTALL_PRECHECK_VALIDATED_ACCESS_TEXT,
TestCommonConstants.TEST_SETUP_PRECHECK_VALIDATED_ACCESS_TEXT,
)
self.assertEqual(result, True)

def test_install_precheck_works_when_control_access_exists(
def test_setup_precheck_works_when_control_access_exists(
self,
call_racf_mock: Mock,
):
Expand All @@ -73,7 +73,7 @@ def test_install_precheck_works_when_control_access_exists(
)
call_racf_mock.return_value = extract_with_control_access
validated_control_access = (
TestCommonConstants.TEST_INSTALL_PRECHECK_VALIDATED_ACCESS_TEXT
TestCommonConstants.TEST_SETUP_PRECHECK_VALIDATED_ACCESS_TEXT
)
validated_control_access = validated_control_access.replace(
"you already have alter access!", "you already have control access!"
Expand All @@ -85,7 +85,7 @@ def test_install_precheck_works_when_control_access_exists(
self.assertEqual(precheck_log, validated_control_access)
self.assertEqual(result, True)

def test_install_precheck_works_when_read_access_exists(
def test_setup_precheck_works_when_read_access_exists(
self,
call_racf_mock: Mock,
):
Expand All @@ -98,7 +98,7 @@ def test_install_precheck_works_when_read_access_exists(
)
call_racf_mock.return_value = extract_with_read_access
validated_read_access = (
TestCommonConstants.TEST_INSTALL_PRECHECK_VALIDATED_ACCESS_TEXT
TestCommonConstants.TEST_SETUP_PRECHECK_VALIDATED_ACCESS_TEXT
)
validated_read_access = validated_read_access.replace(
"you already have alter access!", "you already have read access!"
Expand All @@ -110,7 +110,7 @@ def test_install_precheck_works_when_read_access_exists(
self.assertEqual(precheck_log, validated_read_access)
self.assertEqual(result, True)

def test_install_precheck_works_when_update_access_exists(
def test_setup_precheck_works_when_update_access_exists(
self,
call_racf_mock: Mock,
):
Expand All @@ -123,7 +123,7 @@ def test_install_precheck_works_when_update_access_exists(
)
call_racf_mock.return_value = extract_with_update_access
validated_update_access = (
TestCommonConstants.TEST_INSTALL_PRECHECK_VALIDATED_ACCESS_TEXT
TestCommonConstants.TEST_SETUP_PRECHECK_VALIDATED_ACCESS_TEXT
)
validated_update_access = validated_update_access.replace(
"you already have alter access!", "you already have update access!"
Expand All @@ -135,7 +135,7 @@ def test_install_precheck_works_when_update_access_exists(
self.assertEqual(precheck_log, validated_update_access)
self.assertEqual(result, True)

def test_install_precheck_works_when_none_access_exists(
def test_setup_precheck_works_when_none_access_exists(
self,
call_racf_mock: Mock,
):
Expand All @@ -152,6 +152,6 @@ def test_install_precheck_works_when_none_access_exists(
result = setup_precheck()
precheck_log = self.ansi_escape.sub("", stdout.getvalue())
self.assertEqual(
precheck_log, TestCommonConstants.TEST_INSTALL_PRECHECK_FOUND_NO_ACCESS_TEXT
precheck_log, TestCommonConstants.TEST_SETUP_PRECHECK_FOUND_NO_ACCESS_TEXT
)
self.assertEqual(result, False)
4 changes: 2 additions & 2 deletions tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from tests.access.test_access_request_builder import TestAccessRequestBuilder
from tests.access.test_access_result_parser import TestAccessResultParser
from tests.common.test_customize_segment_traits import TestCustomizeSegmentTraits
from tests.common.test_install_precheck_script import TestInstallPrecheckScript
from tests.common.test_logger import TestLogger
from tests.common.test_run_as_userid import TestRunAsUserId
from tests.common.test_security_request_error import TestDownstreamFatalError
from tests.common.test_setup_precheck import TestSetupPrecheck
from tests.connection.test_connection_debug_logging import TestConnectionDebugLogging
from tests.connection.test_connection_request_builder import (
TestConnectionRequestBuilder,
Expand Down Expand Up @@ -67,7 +67,7 @@ def __test_suite() -> unittest.TestSuite:
TestAccessRequestBuilder,
TestAccessDebugLogging,
TestCustomizeSegmentTraits,
TestInstallPrecheckScript,
TestSetupPrecheck,
TestLogger,
TestDownstreamFatalError,
TestRunAsUserId,
Expand Down

0 comments on commit 04c028d

Please sign in to comment.