コード例 #1
0
ファイル: filters_test.py プロジェクト: comtihon/catcher
 def test_random_functions(self):
     Faker.seed(4321)
     self.populate_file(
         'main.yaml', '''---
     steps:
         - echo: {from: '{{ random("ipv4_private") }}', to: one.output}
     ''')
     runner = Runner(self.test_dir, join(self.test_dir, 'main.yaml'), None)
     self.assertTrue(runner.run_tests())
     ipaddress.ip_address(read_file(join(self.test_dir, 'one.output')))
コード例 #2
0
ファイル: sh_test.py プロジェクト: kbelova/catcher
 def test_list_directory(self):
     self.populate_file(
         'main.yaml', '''---
     steps:
         - sh:
             command: 'ls -la'
             path: '{{ CURRENT_DIR }}'
             register: {content: '{{ OUTPUT }}'}
         - echo: {from: '{{ content }}', to: 'debug.output'}
     ''')
     runner = Runner(self.test_dir, join(self.test_dir, 'main.yaml'), None)
     self.assertTrue(runner.run_tests())
     file = read_file(join(self.test_dir, 'debug.output'))
     self.assertTrue('resources' in file)
コード例 #3
0
ファイル: filters_test.py プロジェクト: comtihon/catcher
 def test_builtin_functions_available(self):
     self.populate_file(
         'main.yaml', '''---
             variables:
                 my_list: ['one', 'two', 'three']
             steps:
                 - echo: {from: '{{ random("ipv4_private") }}', to: one.output}
                 - echo: {from: '{{ random_int(1, 10) }}', to: two.output}
                 - echo: {from: '{{ random_choice(my_list) }}', to: three.output}
             ''')
     runner = Runner(self.test_dir, join(self.test_dir, 'main.yaml'), None)
     Faker.seed(4321)
     random.seed(123)
     self.assertTrue(runner.run_tests())
     ipaddress.ip_address(read_file(join(self.test_dir, 'one.output')))
     self.assertTrue(check_file(join(self.test_dir, 'two.output'), '1'))
     self.assertTrue(
         check_file(join(self.test_dir, 'three.output'), 'three'))
コード例 #4
0
 def test_env_vars_complex(self):
     os.environ['USER'] = '******'
     os.environ['PASSWORD'] = '******'
     self.populate_file('inventory.yml', '''---
     database_conf:
         username: '******'
         password: '******'
     ''')
     self.populate_file('main.yaml', '''---
     steps:
        - echo: {from: '{{ database_conf }}', to: database_conf.output}
        - check: {equals: {the: '{{ database_conf.username }}', is: 'user'}}
     ''')
     runner = Runner(self.test_dir,
                     join(self.test_dir, 'main.yaml'),
                     join(self.test_dir, 'inventory.yml'),
                     system_environment=dict(os.environ))
     self.assertTrue(runner.run_tests())
     content = ast.literal_eval(read_file(join(self.test_dir, 'database_conf.output')))
     self.assertEquals(content, {'username': '******', 'password': '******'})