def test_skill_setattr_ok(simple_translator: Translator): skill = simple_translator.encode_setattr(SkillCode('x'), 'key', 123).replace(' ', '') assert skill == 'x->key=123' skill = simple_translator.encode_setattr(SkillCode('x->y'), 'key', 123).replace(' ', '') assert skill == 'x->y->key=123'
def test_named_parameters_are_optionally_converted( simple_translator: Translator): code = simple_translator.encode_call('func', 1, 2, 3, x=10, long_name=20, longName=30) assert code.replace(' ', '') == 'func(123?x10?longName20?longName30)'
def test_skill_help_to_list(simple_translator: Translator): expected = ['abc', 'def', 'camel_case', 'snake_case'] assert simple_translator.decode_dir( '["abc","def","camelCase","snake_case"]') == expected
def test_skill_help_adds_question_mark(simple_translator: Translator): assert 'x->?' in simple_translator.encode_dir(SkillCode('x')) assert 'x->y->?' in simple_translator.encode_dir(SkillCode('x->y'))
def test_set_attribute(simple_translator: Translator, obj, name, value): got = simple_translator.encode_setattr(obj, name, value).replace(' ', '') left = '->'.join([obj, name]) expected = f'{left}={value}' assert got == expected
def test_get_attribute(simple_translator: Translator, obj, name): assert simple_translator.encode_getattr(obj, name).replace( ' ', '') == '->'.join([obj, name])