def run_with_arguments_should_work_properly() -> None: _additional_value = 'No' _additional_key_word_value = 'What' normal_val = 'one' normal_key_val = 'two' def _function(normal_arg: str, value_one: str, normal_key_arg: str = None, key_value: str = None) -> Any: CommonAssertionUtils.are_equal(value_one, _additional_value) CommonAssertionUtils.are_equal(key_value, _additional_key_word_value) CommonAssertionUtils.are_equal(normal_arg, normal_val) CommonAssertionUtils.are_equal(normal_key_arg, normal_key_val) if normal_arg == normal_val and normal_key_arg == normal_key_val and value_one == _additional_value and key_value == _additional_key_word_value: return True result = CommonFunctionUtils.run_with_arguments( _function, _additional_value, key_value=_additional_key_word_value)( normal_val, normal_key_arg=normal_key_val) CommonAssertionUtils.is_true( result, message='Failed to send proper arguments: {}'.format(result))
def _should_spawn_and_despawn_human_sim_properly() -> None: sim_info = CommonSimSpawnUtils.create_human_sim_info( first_name='Tester', last_name='McTest', source='testing') CommonAssertionUtils.is_true(sim_info is not None) CommonAssertionUtils.is_true( CommonSimSpawnUtils.despawn_sim(sim_info, cause='Was just a test.'))
def _should_override_property() -> None: @CommonInjectionUtils.inject_safely_into(ModInfo.get_identity(), FakeClassToBeOverridden, 'the_property') def _overridden_property(*_: Any, **__: Any) -> bool: return True CommonAssertionUtils.is_true(FakeClassToBeOverridden().the_property)
def _should_override_instance_method() -> None: @CommonInjectionUtils.inject_safely_into( ModInfo.get_identity(), FakeClassToBeOverridden, FakeClassToBeOverridden.the_instance_method.__name__) def _overridden_instance_method(*_: Any, **__: Any) -> bool: return True CommonAssertionUtils.is_true( FakeClassToBeOverridden().the_instance_method())
def _enum_call_should_throw_when_value_not_found(value: Any): exception = CommonAssertionUtils.throws(lambda: TestEnum(value), value) CommonAssertionUtils.is_true( isinstance(exception, KeyError), message='Exception was not of type KeyError, it was type \'{}\''. format(type(exception))) CommonAssertionUtils.has_length(exception.args, 1) exception_message = exception.args[0] CommonAssertionUtils.are_equal( exception_message, 'Value: \'{}\' not found within class \'TestEnum\''.format(value))
def _enum_should_have_value() -> None: CommonAssertionUtils.is_true( hasattr(TestEnum.TEST_VALUE_ONE, 'value'), message='Enum did not have attribute \'value\'') CommonAssertionUtils.are_equal( getattr(TestEnum.TEST_VALUE_ONE, 'value'), 1)
def enum_should_have_name(): CommonAssertionUtils.is_true( hasattr(TestEnum.TEST_VALUE_ONE, 'name'), message='Enum did not have attribute \'name\'') CommonAssertionUtils.are_equal( getattr(TestEnum.TEST_VALUE_ONE, 'name'), 'TEST_VALUE_ONE')
def should_intersect_true(list_one, *list_items): result = CommonCollectionUtils.intersects(list_one, *list_items) CommonAssertionUtils.is_true(result)
def _services_should_not_be_reinitialized_when_retrieved_via_new() -> None: thing_added = 'A thing' _TestService().a_collection_of_things.append(thing_added) CommonAssertionUtils.is_true( thing_added in _TestService().a_collection_of_things)
def _get_and_new_should_be_same_instance() -> None: CommonAssertionUtils.is_true(_TestService() is _TestService.get())