From d2a0ea31dba84609ad27d2b7ef623d71db7d7179 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Tue, 26 Jul 2016 15:54:44 +0200 Subject: [PATCH] Add tests from DomainParser.complete_reference issue5731 review30361002 --- tryton/common/domain_parser.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tryton/common/domain_parser.py b/tryton/common/domain_parser.py index c31699dbfc..339d298a27 100644 --- a/tryton/common/domain_parser.py +++ b/tryton/common/domain_parser.py @@ -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: