def test_update_CHANGELOG(chObject_new, load_changelog_file, push_changelog_file, db_obj, conn_api, dearchive_file, del_from_db, clean_tmp): log = logging.getLogger('test_update_CHANGELOG') log.debug('Testing the \'update_CHANGELOG\' function') CONFIG.set('ctree', 'backup', os.getenv('DATADIR') + "/ctree/") CONFIG.set('ctree', 'chlog_fpath', '/ctree/MOCK_CHANGELOG') chObject_new.print_changelog(ifile=load_changelog_file.name) chObject_new.update_CHANGELOG(load_changelog_file.name, db=db_obj, api=conn_api) del_from_db.append(load_changelog_file.name) dearchive_file.append(push_changelog_file)
def test_push_ctree(db_obj, conn_api, load_staging_tree, push_prod_tree, dearchive_file, clean_tmp, del_from_db): log = logging.getLogger('test_push_ctree') log.debug('Testing \'push_ctree\' function') CONFIG.set('ctree', 'backup', os.getenv('DATADIR') + "/ctree/") ctree = CurrentTree( db=db_obj, api=conn_api, staging_tree=os.getenv('DATADIR') + "/ctree/current.staging.tree", prod_tree=os.getenv('DATADIR') + "/ctree/current.minus1.tree") fire_path = ctree.push_ctree(dry=False) del_from_db.append(load_staging_tree.name) dearchive_file.append(fire_path)
def modify_settings(request): """ Fixture to modify the settings.ini and generate a modified version that will be used in this file """ abs_dir = os.path.abspath(os.getenv('DATADIR')) CONFIG.set('ftp', 'ftp_mount', abs_dir) with open('settings_m.ini', 'w') as configfile: CONFIG.write(configfile) def fin(): print( '\n[teardown] modify_settings finalizer, deleting modified settings file' ) os.remove('settings_m.ini') request.addfinalizer(fin) return 'settings_m.ini'
def test_run_new(db_obj, conn_api, load_changelog_file, push_changelog_file, push_prod_tree, del_from_db, dearchive_file, clean_tmp): log = logging.getLogger('test_run_new') log.debug('Testing \'run\' function when there is an additional path in ' 'CurrentTree.staging_tree with respect to CurrentTree.prod_tree') ctree = CurrentTree( db=db_obj, api=conn_api, staging_tree=os.getenv('DATADIR') + "/ctree/current.staging.tree", prod_tree=os.getenv('DATADIR') + "/ctree/current.minus1.tree") CONFIG.set('ctree', 'backup', os.getenv('DATADIR') + "/ctree/") CONFIG.set('ctree', 'chlog_fpath', '/ctree/MOCK_CHANGELOG') CONFIG.set('ctree', 'chlog_details_dir', '/ftp/changelog_details_test') pushed_dict = ctree.run(chlog_f=load_changelog_file.name, limit=10, dry=False) for k in pushed_dict.keys(): if k == "chlog_details": for p in pushed_dict[k]: dearchive_file.append(p) else: dearchive_file.append(pushed_dict[k]) for p in pushed_dict['chlog_details']: del_from_db.append(f"{CONFIG.get('ftp', 'ftp_mount')}/{p}") del_from_db.append(load_changelog_file.name)