def test_protected_access_inside_child_class(enable_accessify):
    """
    Case: access to the parent protected member, which do not follow naming convention, inside child class.
    Expect: protected member is accessible.
    """
    lamborghini = Lamborghini()

    assert ENGINE_HAS_BEEN_STARTED_RESPONSE.format(type_='electric', model='S', company='Tesla') == lamborghini.run()
def test_protected_access_inside_class(enable_accessify):
    """
    Case: access to the protected member, which do not follow naming convention, inside member's class.
    Expect: protected member is accessible.
    """
    car = CarWithProtectedEngine()

    assert ENGINE_HAS_BEEN_STARTED_RESPONSE.format(type_='electric', model='S', company='Tesla') == car.run()
Esempio n. 3
0
def test_private_access_inside_class(enable_accessify):
    """
    Case: access to the private member inside member's class.
    Expect: private member is accessible.
    """
    car = CarWithPrivateEngine()

    assert ENGINE_HAS_BEEN_STARTED_RESPONSE.format(
        type_='electric', model='S', company='Tesla') == car.run()
def test_protected_access_with_decorators(class_, enable_accessify):
    """
    Case: access to the protected member of the class that is wrapped to an yet one decorator.
    Expect: inaccessible due to its protection level error message.
    """
    car = class_()

    assert ENGINE_HAS_BEEN_STARTED_RESPONSE.format(
        type_='electric', model='S', company='Tesla') == car.run()

    with pytest.raises(InaccessibleDueToItsProtectionLevelException) as error:
        car.start_engine('electric', 'S', company='Tesla')

    assert '{class_with_method}.start_engine() is inaccessible due ' \
           'to its protection level'.format(class_with_method=class_.__name__) == \
           error.value.message
Esempio n. 5
0
def test_private_access_with_decorators(class_, enable_accessify):
    """
    Case: access to the private member of the class that is wrapped to an yet one decorator.
    Expect: inaccessible due to its protection level error message.
    """
    car = class_()

    assert ENGINE_HAS_BEEN_STARTED_RESPONSE.format(
        type_='electric', model='S', company='Tesla') == car.run()

    expected_error_message = INACCESSIBLE_DUE_TO_ITS_PROTECTION_LEVEL_EXCEPTION_MESSAGE.format(
        class_name=class_.__name__,
        class_method_name='start_engine',
    )

    with pytest.raises(InaccessibleDueToItsProtectionLevelException) as error:
        car.start_engine('electric', 'S', company='Tesla')

    assert expected_error_message == error.value.message
 def start_engine(this, type_, model, company='Tesla'):
     return ENGINE_HAS_BEEN_STARTED_RESPONSE.format(type_=type_, model=model, company=company)