Example #1
0
	def test_pipeline_fxn1(self):
		context = {'var1':'hello', PIPELINE_PREFIX_VARNAME:'/foo/bar_'}
		cwd = '.'

		exval = expand_variables('touch $PLN(test1.txt)',context,cwd,None,None,-1)
		self.assertEquals(exval,'touch /foo/bar_test1.txt')

		exval = expand_variables('touch $PLN($var1.txt)',context,cwd,None,None,-1)
		self.assertEquals(exval,'touch /foo/bar_hello.txt')
Example #2
0
    def test_pipeline_fxn1(self):
        context = {'var1': 'hello', PIPELINE_PREFIX_VARNAME: '/foo/bar_'}
        cwd = '.'

        exval = expand_variables('touch $PLN(test1.txt)', context, cwd, None,
                                 None, -1)
        self.assertEquals(exval, 'touch /foo/bar_test1.txt')

        exval = expand_variables('touch $PLN($var1.txt)', context, cwd, None,
                                 None, -1)
        self.assertEquals(exval, 'touch /foo/bar_hello.txt')
Example #3
0
	def test_multvars1(self):
		context = {'var1':'hello', 'foobar':'test'}
		cwd = '.'

		exval = expand_variables('${var1}_$foobar.txt',context,cwd,None,None,-1)
		self.assertEquals(exval,'hello_test.txt')

		exval = expand_variables('${var1}_${foobar}.txt',context,cwd,None,None,-1)
		self.assertEquals(exval,'hello_test.txt')
			
		exval = expand_variables('echo $var1 $foobar',context,cwd,None,None,-1)
		self.assertEquals(exval,'echo hello test')
Example #4
0
	def test_basic1(self):
		context = {'var1':'hello'}
		cwd = '.'

		exval = expand_variables('$var1.txt',context,cwd,None,None,-1)
		self.assertEquals(exval,'hello.txt')

		exval = expand_variables('${var1}.txt',context,cwd,None,None,-1)
		self.assertEquals(exval,'hello.txt')
			
		exval = expand_variables('hello_$var1.txt',context,cwd,None,None,-1)
		self.assertEquals(exval,'hello_hello.txt')
Example #5
0
    def test_basic1(self):
        context = {'var1': 'hello'}
        cwd = '.'

        exval = expand_variables('$var1.txt', context, cwd, None, None, -1)
        self.assertEquals(exval, 'hello.txt')

        exval = expand_variables('${var1}.txt', context, cwd, None, None, -1)
        self.assertEquals(exval, 'hello.txt')

        exval = expand_variables('hello_$var1.txt', context, cwd, None, None,
                                 -1)
        self.assertEquals(exval, 'hello_hello.txt')
Example #6
0
    def test_multvars1(self):
        context = {'var1': 'hello', 'foobar': 'test'}
        cwd = '.'

        exval = expand_variables('${var1}_$foobar.txt', context, cwd, None,
                                 None, -1)
        self.assertEquals(exval, 'hello_test.txt')

        exval = expand_variables('${var1}_${foobar}.txt', context, cwd, None,
                                 None, -1)
        self.assertEquals(exval, 'hello_test.txt')

        exval = expand_variables('echo $var1 $foobar', context, cwd, None,
                                 None, -1)
        self.assertEquals(exval, 'echo hello test')
Example #7
0
    def test_shell_fxn1(self):
        context = {'var1': 'hello'}
        cwd = '.'

        exval = expand_variables('touch $(echo hi)', context, cwd, None, None,
                                 -1)
        self.assertEquals(exval, 'touch hi')
Example #8
0
    def test_invalid_escape1(self):
        context = {'var1': 'hello'}
        cwd = '.'

        try:
            exval = expand_variables(r'\n', context, cwd, None, None, -1)
            self.fail('\\n should raise a ParseException')
        except ParseException as e:
            pass
        except:
            self.fail('\\n should raise a ParseException')
Example #9
0
	def test_shell_fxn_newline_error1(self):
		context = {'var1':'hello'}
		cwd = '.'

		raised_exc = False
		try:
			exval = expand_variables('touch $(ls None,-1)',context,cwd,None,-1)
		except:
			raised_exc = True

		self.assertTrue(raised_exc,'inline shell functions should fail on output containing newlines')
Example #10
0
	def test_invalid_escape1(self):
		context = {'var1':'hello'}
		cwd = '.'

		try:
			exval = expand_variables(r'\n',context,cwd,None,None,-1)
			self.fail('\\n should raise a ParseException')
		except ParseException as e:
			pass
		except:
			self.fail('\\n should raise a ParseException')
Example #11
0
    def test_shell_fxn_newline_error1(self):
        context = {'var1': 'hello'}
        cwd = '.'

        raised_exc = False
        try:
            exval = expand_variables('touch $(ls None,-1)', context, cwd, None,
                                     -1)
        except:
            raised_exc = True

        self.assertTrue(
            raised_exc,
            'inline shell functions should fail on output containing newlines')
Example #12
0
    def test_grep_error(self):
        cmd = """grep -o '/article/[^"]+' $PLN(lists_html/\$TAG.*) > $PLN(article_lists/\$TAG.txt)"""
        cwd = '.'
        context = {PIPELINE_PREFIX_VARNAME: '/foo/bar_'}

        exval = expand_variables(cmd, context, cwd, None, None, -1)
Example #13
0
	def test_shell_fxn1(self):
		context = {'var1':'hello'}
		cwd = '.'

		exval = expand_variables('touch $(echo hi)',context,cwd,None,None,-1)
		self.assertEquals(exval,'touch hi')
Example #14
0
	def test_grep_error(self):
		cmd = """grep -o '/article/[^"]+' $PLN(lists_html/\$TAG.*) > $PLN(article_lists/\$TAG.txt)"""
		cwd = '.'
		context = {PIPELINE_PREFIX_VARNAME:'/foo/bar_'}

		exval = expand_variables(cmd,context,cwd,None,None,-1)