def test__auth_token_setter_invalid(capsys): """ GithubReports Class 'auth_token' Property Setter Invalid Value Test This test will test the auth_token getter and setter property methods. Default value tested during init test, test setting value to invalid value using the property setter method. Expected Result: 'auth_token' property should be set to False, ignoring the invalid value. """ # Instantiate a GithubReports object, and test for expected test values. GitHubReportObj = GithubReports() assert (isinstance(GitHubReportObj, object)) # Test auth_token setting was defaulted to None assert (GitHubReportObj._auth_token is None) assert (GitHubReportObj.auth_token is None) # Set auth_token to an invalid value using property settter and test the # value ensuring that the invalid value was ignored, and is set None. GitHubReportObj.auth_token = 42 assert (GitHubReportObj._auth_token is None) assert (GitHubReportObj.auth_token is None) # Capture stdout, stderr to test log messages out, err = capsys.readouterr() # sys.stdout.write(out) # sys.stderr.write(err) assert "ERROR CLS->GitHubReports.auth_token: \ -> auth_token property argument expected type str but received type:" in err
def test_search_open_pulls_no_namespace(capsys): """ GithubReports Class 'test_search_open_pulls' Method Test This test will test the 'test_search_open_pulls' method. The method is designed to run a search against Github for number of open PRs across a given organization or user account. This test will attempt to call the search_open_pulls() method without repo_namespace configured. auth_token will be tested by using the auth_token property setter. Expected Result: return object should be None. Log Error no repo_namespace """ # Instantiate a GithubReports object, and test for expected test values. GitHubReportObj = GithubReports(verbose=True) assert (isinstance(GitHubReportObj, object)) assert (GitHubReportObj.auth_token is None) assert (GitHubReportObj.repo_namespace is None) # Set the Auth Token GitHubReportObj.auth_token = "12345678910987654321" assert (GitHubReportObj.auth_token == "12345678910987654321") assert (GitHubReportObj.repo_namespace is None) # Call the method search_results = GitHubReportObj.search_open_pulls() assert (search_results is None) # Capture stdout, stderr to test log messages out, err = capsys.readouterr() # sys.stdout.write(out) # sys.stderr.write(err) assert "ERROR CLS->GitHubReports.search_open_pulls: \ -> Github repo_namespace required to call this method" in err
def test_auth_token_setter_enabled(): """ GithubReports Class 'auth_token' Property Setter Test This test will test the auth_token getter and setter property methods. Default value tested during init test, test setting value to provided string using the class auth_token setter method. Expected Result: 'auth_token' property should be set to provided string value. """ # Instantiate a GithubReports object, and test for expected test values. GitHubReportObj = GithubReports() assert (isinstance(GitHubReportObj, object)) # Test auth_token is set to default False assert (GitHubReportObj._auth_token is None) assert (GitHubReportObj.auth_token is None) # Call the Setter to enable auth_token and test the property value is # set to the provided string value. GitHubReportObj.auth_token = "12345678910987654321" assert (GitHubReportObj._auth_token == "12345678910987654321") assert (GitHubReportObj.auth_token == "12345678910987654321")