def test_valid(self): data = ''' *** Variables *** ${x} value @{y}= two values &{z} = one=item ''' expected = VariableSection(header=SectionHeader( tokens=[Token(Token.VARIABLE_HEADER, '*** Variables ***', 1, 0)]), body=[ Variable([ Token(Token.VARIABLE, '${x}', 2, 0), Token(Token.ARGUMENT, 'value', 2, 10) ]), Variable([ Token(Token.VARIABLE, '@{y}=', 3, 0), Token(Token.ARGUMENT, 'two', 3, 10), Token(Token.ARGUMENT, 'values', 3, 17) ]), Variable([ Token(Token.VARIABLE, '&{z} =', 4, 0), Token(Token.ARGUMENT, 'one=item', 4, 10) ]), ]) get_and_assert_model(data, expected, depth=0)
def test_valid(self): model = get_model('''\ *** Variables *** ${x} value @{y}= two values &{z} = one=item ''', data_only=True) expected = VariableSection(header=SectionHeader( tokens=[Token(Token.VARIABLE_HEADER, '*** Variables ***', 1, 0)]), body=[ Variable([ Token(Token.VARIABLE, '${x}', 2, 0), Token(Token.ARGUMENT, 'value', 2, 10) ]), Variable([ Token(Token.VARIABLE, '@{y}=', 3, 0), Token(Token.ARGUMENT, 'two', 3, 10), Token(Token.ARGUMENT, 'values', 3, 17) ]), Variable([ Token(Token.VARIABLE, '&{z} =', 4, 0), Token(Token.ARGUMENT, 'one=item', 4, 10) ]), ]) assert_model(model.sections[0], expected)
def test_invalid(self): model = get_model('''\ *** Variables *** Ooops I did it again ${} invalid ${x}== invalid ${not closed invalid &{dict} invalid ${invalid} ''', data_only=True) expected = VariableSection( header=SectionHeader(tokens=[ Token(Token.VARIABLE_HEADER, '*** Variables ***', 1, 0) ]), body=[ Variable(tokens=[ Token(Token.VARIABLE, 'Ooops', 2, 0), Token(Token.ARGUMENT, 'I did it again', 2, 10) ], errors=("Invalid variable name 'Ooops'.", )), Variable(tokens=[ Token(Token.VARIABLE, '${}', 3, 0), Token(Token.ARGUMENT, 'invalid', 3, 10) ], errors=("Invalid variable name '${}'.", )), Variable(tokens=[ Token(Token.VARIABLE, '${x}==', 4, 0), Token(Token.ARGUMENT, 'invalid', 4, 10) ], errors=("Invalid variable name '${x}=='.", )), Variable(tokens=[ Token(Token.VARIABLE, '${not', 5, 0), Token(Token.ARGUMENT, 'closed', 5, 10) ], errors=("Invalid variable name '${not'.", )), Variable(tokens=[ Token(Token.VARIABLE, '', 6, 0), Token(Token.ARGUMENT, 'invalid', 6, 10) ], errors=("Invalid variable name ''.", )), Variable( tokens=[ Token(Token.VARIABLE, '&{dict}', 7, 0), Token(Token.ARGUMENT, 'invalid', 7, 10), Token(Token.ARGUMENT, '${invalid}', 7, 21) ], errors= ("Invalid dictionary variable item 'invalid'. " "Items must use 'name=value' syntax or be dictionary variables themselves.", "Invalid dictionary variable item '${invalid}'. " "Items must use 'name=value' syntax or be dictionary variables themselves." )), ]) assert_model(model.sections[0], expected)