Esempio n. 1
0
def test_open_pr_threshold_setter_invalid(capsys):
    """ GithubReports 'open_pr_threshold' Property Setter Invalid Val Test

    This test will test the 'open_pr_threshold' getter and setter property
    methods. Default value tested during init test, test setting value to
    invalid value using the property setter method.

    Expected Result:
      'open_pr_threshold' property should be set to 5 (default value),
      ignoring the invalid value.
    """

    # Instantiate a GithubReports object, and test for expected test values.
    GitHubReportObj = GithubReports()
    assert (isinstance(GitHubReportObj, object))

    # Test open_pr_threshold setting was defaulted to 5
    assert (GitHubReportObj._open_pr_threshold == 5)
    assert (GitHubReportObj.open_pr_threshold == 5)

    # Set open_pr_threshold to an invalid value using property settter
    # and test the value ensuring that the invalid value was ignored,
    # and is set to default value of 5.
    GitHubReportObj.open_pr_threshold = True
    assert (GitHubReportObj._open_pr_threshold == 5)
    assert (GitHubReportObj.open_pr_threshold == 5)

    # Capture stdout, stderr to test log messages
    out, err = capsys.readouterr()
    # sys.stdout.write(out)
    # sys.stderr.write(err)
    assert "ERROR   CLS->GitHubReports.open_pr_threshold: \
-> open_pr_threshold property argument expected type int but received " in err
Esempio n. 2
0
def test_open_pr_threshold_setter_enabled():
    """ GithubReports Class 'open_pr_threshold' Property Setter Test

    This test will test the 'open_pr_threshold' getter and setter property
    methods. Default value tested during init test, test setting value to
    valid int value using the class 'open_pr_threshold' setter method.

    Expected Result:
      'open_pr_threshold' property should be set to provided int value.
    """

    # Instantiate a GithubReports object, and test for expected test values.
    GitHubReportObj = GithubReports()
    assert (isinstance(GitHubReportObj, object))

    # Test open_pr_threshold is set to default 5
    assert (GitHubReportObj._open_pr_threshold == 5)
    assert (GitHubReportObj.open_pr_threshold == 5)

    # Call the Setter to enable open_pr_threshold and test the property
    # value is set to provided int value value.
    GitHubReportObj.open_pr_threshold = 3
    assert (GitHubReportObj._open_pr_threshold == 3)
    assert (GitHubReportObj.open_pr_threshold == 3)