Add tests from DomainParser.complete_reference

issue5731
review30361002
This commit is contained in:
Sergi Almacellas Abellana committed 2016-07-26 15:54:44 +02:00
1 parent 4866e72ef1
commit d2a0ea31db
1 file changed
+19
+19
View File
@@ -755,6 +755,25 @@ def test_complete_selection():
assert list(complete_value(field_with_empty, value)) == result
def test_complete_reference():
field = {
'type': 'reference',
'selection': [
('spam', 'Spam'),
('ham', 'Ham'),
('', ''),
],
}
for value, result in (
('s', ['%spam%']),
('test', []),
('', ['%spam%', '%ham%', '%']),
(None, ['%spam%', '%ham%', '%']),
(['spam', 'h'], [['spam', 'ham']]),
):
assert list(complete_value(field, value)) == result
def parenthesize(tokens):
"Nest tokens according to parenthesis"
for token in tokens: