def test_iterate_path_tags_user_tags(self): tags = ['test_tag'] self.single_file_config['paths'][0]['tags'] = tags v = {'version': '3.1.0-m3'} rpx.iterate(self.single_file_config, v, verbose=True, tags=tags) with open(self.single_file_output_file) as f: self.assertIn('3.1.0-m3', f.read())
def test_iterate(self): output_file = MOCK_TEST_FILE + '.test' v = {'version': '3.1.0-m3'} iterate(MOCK_CONFIG_FILE, v) with open(output_file) as f: self.assertIn('3.1.0-m3', f.read()) os.remove(output_file)
def test_iterate_multiple_files(self): fd, tmp = tempfile.mkstemp() os.close(fd) with open(tmp, 'w') as f: f.write('version: \'3.1.0-m3\'') # iterate once params = { '-c': MOCK_MULTIPLE_FILES, '--vars-file=': tmp, '--var=': '\'preversion\'=\'3.1.0-m2\'', } try: _invoke_click('iter', params) finally: os.remove(tmp) # verify that all files were modified for version_file in self.version_files_without_excluded: with open(version_file) as f: self.assertIn('3.1.0-m3', f.read()) # # all other than the excluded ones for version_file in self.excluded_files: with open(version_file) as f: self.assertIn('3.1.0-m2', f.read()) v = {'preversion': '3.1.0-m3', 'version': '3.1.0-m2'} rpx.iterate(MOCK_MULTIPLE_FILES, v) # verify that all files were modified for version_file in self.version_files_without_excluded: with open(version_file) as f: self.assertIn('3.1.0-m2', f.read()) # # all other than the excluded ones for version_file in self.excluded_files: with open(version_file) as f: self.assertIn('3.1.0-m2', f.read())
def test_iterate_path_tags_user_tags(self): tags = ['test_tag'] self.single_file_config['paths'][0]['tags'] = tags v = {'version': '3.1.0-m3'} rpx.iterate( self.single_file_config, v, verbose=True, tags=tags) with open(self.single_file_output_file) as f: self.assertIn('3.1.0-m3', f.read())
def test_env_var_based_replacement(self): v = {'version': '3.1.0-m3'} os.environ['REPEX_VAR_VERSION'] = '3.1.0-m9' try: rpx.iterate(MOCK_SINGLE_FILE, v) with open(self.single_file_output_file) as f: self.assertIn('3.1.0-m9', f.read()) finally: os.environ.pop('REPEX_VAR_VERSION')
def test_iterate_multiple_files(self): v = { 'preversion': '3.1.0-m2', 'version': '3.1.0-m3' } iterate(MOCK_CONFIG_MULTIPLE_FILES, v) files = get_all_files( 'mock_VERSION', TEST_RESOURCES_DIR_PATTERN, TEST_RESOURCES_DIR) for fl in files: with open(fl) as f: self.assertIn('3.1.0-m3', f.read()) v['preversion'] = '3.1.0-m3' v['version'] = '3.1.0-m2' iterate(MOCK_CONFIG_MULTIPLE_FILES, v) for fl in files: with open(fl) as f: self.assertIn('3.1.0-m2', f.read())
def test_iterate_multiple_files(self): fd, tmp = tempfile.mkstemp() os.close(fd) with open(tmp, 'w') as f: f.write('version: \'3.1.0-m3\'') # iterate once params = { '-c': MOCK_MULTIPLE_FILES, '--vars-file=': tmp, '--var=': '\'preversion\'=\'3.1.0-m2\'', } try: _invoke_click('iter', params) finally: os.remove(tmp) # verify that all files were modified for version_file in self.version_files_without_excluded: with open(version_file) as f: self.assertIn('3.1.0-m3', f.read()) # # all other than the excluded ones for version_file in self.excluded_files: with open(version_file) as f: self.assertIn('3.1.0-m2', f.read()) v = { 'preversion': '3.1.0-m3', 'version': '3.1.0-m2' } rpx.iterate(MOCK_MULTIPLE_FILES, v) # verify that all files were modified for version_file in self.version_files_without_excluded: with open(version_file) as f: self.assertIn('3.1.0-m2', f.read()) # # all other than the excluded ones for version_file in self.excluded_files: with open(version_file) as f: self.assertIn('3.1.0-m2', f.read())
# import os import repex.repex as rpx CONFIG_YAML_FILE = "check_validity/tester.yaml" VERSION = '3.1.0-m3' variables = {'version': VERSION, 'base_dir': 'check_validity'} rpx.iterate(CONFIG_YAML_FILE, variables, verbose=True) # You can also run this from the command line instead: # rpx execute -c check_validity/tester.yaml -t mytag -v --vars-file check_validity/vars.yaml --var base_dir=check_validity --var version=3.3.x # NOQA
def test_iterate_with_vars_in_config(self): rpx.iterate(MOCK_SINGLE_FILE) with open(self.single_file_output_file) as f: self.assertIn('3.1.0-m4', f.read())
def test_iterate_with_vars(self): v = {'version': '3.1.0-m3'} rpx.iterate(MOCK_SINGLE_FILE, v) with open(self.single_file_output_file) as f: self.assertIn('3.1.0-m3', f.read())
def test_iterate_user_tags_no_path_tags(self): tags = ['test_tag'] v = {'version': '3.1.0-m3'} rpx.iterate(MOCK_SINGLE_FILE, v, verbose=True, tags=tags) self.assertFalse(os.path.isfile(self.single_file_output_file))
def test_iterate_path_tags_no_user_tags(self): tags = ['test_tag'] self.single_file_config['paths'][0]['tags'] = tags v = {'version': '3.1.0-m3'} rpx.iterate(self.single_file_config, v, verbose=True) self.assertFalse(os.path.isfile(self.single_file_output_file))
def test_iterate_no_files(self): try: iterate(EMPTY_CONFIG_FILE) except RepexError as ex: self.assertEqual(str(ex), 'no paths configured')
def test_iterate_no_config_supplied(self): try: iterate() except TypeError as ex: self.assertIn('takes at least 1 argument', str(ex))
# import os import repex.repex as rpx CONFIG_YAML_FILE = "check_validity/tester.yaml" VERSION = '3.1.0-m3' variables = { 'version': VERSION, 'base_dir': 'check_validity' } rpx.iterate(CONFIG_YAML_FILE, variables, verbose=True) # You can also run this from the command line instead: # rpx execute -c check_validity/tester.yaml -t mytag -v --vars-file check_validity/vars.yaml --var base_dir=check_validity --var version=3.3.x # NOQA
def test_iterate_variables_not_dict(self): try: iterate(MOCK_CONFIG_FILE, variables='x') except RuntimeError as ex: self.assertEqual(str(ex), 'variables must be of type dict')