def test_parseNoEval3(self): '''flaghelper: CAS-6553 parse and evaluate a string with whitespaces''' # Dividers for string first = ' ' second = '=' reference = OrderedDict([('mode', "tfcrop"), ('antenna', 'ea24')]) # cmd with whitespace in the begin and end cmd = " mode='tfcrop' antenna='ea24' " myparser = fh.Parser(first, second) res = myparser.parseNoEval(cmd) # evaluate parameters to fix single quote left dangling resdict = fh.evaluateParameters(res) self.assertDictEqual( reference, resdict, 'Failed to parserNoEval() with whitespaces at begin and end')
def test_evaluateParameters2(self): '''flaghelper: parse and evaluate a string with a single quote inside''' # Dividers for string first = ' ' second = '=' reference = OrderedDict([('mode', "manual"), ('field', "It A'int a Field")]) # cmd with single quote inside a string cmd = "mode='manual' field='It A'int a Field'" myparser = fh.Parser(first, second) res = myparser.parseNoEval(cmd) # evaluate parameters to fix single quote resdict = fh.evaluateParameters(res) self.assertDictEqual( reference, resdict, 'Failed to evaluateParameters with single quote in value')
def test_evaluateParameters1(self): '''flaghelper: parse and evaluate a string with a many extra whitespaces''' # Dividers for string first = ' ' second = '=' reference = OrderedDict([('mode', "manual"), ('antenna', 'ea24'), ('spw', '0'), ('reason', 'MY WHITESPACES')]) # cmd with single quote inside a string cmd = " mode='manual' antenna='ea24' spw='0' reason='MY WHITESPACES'" myparser = fh.Parser(first, second) res = myparser.parseNoEval(cmd) # evaluate parameters to fix single quote resdict = fh.evaluateParameters(res) self.assertDictEqual( reference, resdict, 'Failed to evaluateParameters with many whitespaces')
def test_parseNoEval2(self): '''flaghelper: CAS-6553 parse and evaluate a string with whitespaces''' # Dividers for string first = ' ' second = '=' reference = OrderedDict([('mode', "extend"), ('antenna', 'ea24'), ('flagnearfreq', True)]) # cmd with whitespace between pairs and at the end cmd = "mode='extend' antenna='ea24 ' flagnearfreq=True" myparser = fh.Parser(first, second) # test parseNoEval() res = myparser.parseNoEval(cmd) # evaluate parameters to fix single quote resdict = fh.evaluateParameters(res) self.assertDictEqual( reference, resdict, 'Failed to parserNoEval() with whitespaces in value')