How to use export_target method in autotest

Best Python code snippet using autotest_python

export_tests.py

Source:export_tests.py Github

copy

Full Screen

1#!/usr/bin/env python2#3# export_tests.py: testing export cases.4#5# Subversion is a tool for revision control. 6# See http://subversion.tigris.org for more information.7# 8# ====================================================================9# Copyright (c) 2000-2004 CollabNet. All rights reserved.10#11# This software is licensed as described in the file COPYING, which12# you should have received as part of this distribution. The terms13# are also available at http://subversion.tigris.org/license-1.html.14# If newer versions of this license are posted there, you may use a15# newer version instead, at your option.16#17######################################################################18# General modules19import shutil, string, sys, re, os20# Our testing module21import svntest22# (abbreviation)23Skip = svntest.testcase.Skip24XFail = svntest.testcase.XFail25Item = svntest.wc.StateItem26 27######################################################################28# Tests29#30# Each test must return on success or raise on failure.31#----------------------------------------------------------------------32def export_empty_directory(sbox):33 "export an empty directory"34 sbox.build(create_wc = False)35 36 svntest.main.safe_rmtree(sbox.wc_dir)37 export_target = sbox.wc_dir38 empty_dir_url = svntest.main.current_repo_url + '/A/C'39 svntest.main.run_svn(None, 'export', empty_dir_url, export_target)40 if not os.path.exists(export_target):41 raise svntest.Failure42def export_greek_tree(sbox):43 "export the greek tree"44 sbox.build(create_wc = False)45 svntest.main.safe_rmtree(sbox.wc_dir)46 export_target = sbox.wc_dir47 expected_output = svntest.main.greek_state.copy()48 expected_output.wc_dir = sbox.wc_dir49 expected_output.desc[''] = Item()50 expected_output.tweak(contents=None, status='A ')51 svntest.actions.run_and_verify_export(svntest.main.current_repo_url,52 export_target,53 expected_output,54 svntest.main.greek_state.copy())55def export_nonexistent_url(sbox):56 "attempt to export a nonexistent URL"57 sbox.build(create_wc = False)58 svntest.main.safe_rmtree(sbox.wc_dir)59 export_target = os.path.join(sbox.wc_dir, 'nonexistent')60 nonexistent_url = sbox.repo_url + "/nonexistent"61 svntest.actions.run_and_verify_svn("Error about nonexistent URL expected",62 None, svntest.SVNAnyOutput,63 'export', nonexistent_url, export_target)64def export_working_copy(sbox):65 "export working copy"66 sbox.build()67 export_target = sbox.add_wc_path('export')68 svntest.actions.run_and_verify_export(sbox.wc_dir,69 export_target,70 svntest.wc.State(sbox.wc_dir, {}),71 svntest.main.greek_state.copy())72def export_working_copy_with_mods(sbox):73 "export working copy with mods"74 sbox.build()75 wc_dir = sbox.wc_dir76 # Make a couple of local mods to files77 mu_path = os.path.join(wc_dir, 'A', 'mu')78 rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')79 kappa_path = os.path.join(wc_dir, 'kappa')80 gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')81 E_path = os.path.join(wc_dir, 'A', 'B', 'E')82 svntest.main.file_append(mu_path, 'appended mu text')83 svntest.main.file_append(rho_path, 'new appended text for rho')84 svntest.main.file_append(kappa_path, "This is the file 'kappa'.")85 svntest.main.run_svn(None, 'add', kappa_path)86 svntest.main.run_svn(None, 'rm', E_path, gamma_path)87 expected_disk = svntest.main.greek_state.copy()88 expected_disk.tweak('A/mu',89 contents=expected_disk.desc['A/mu'].contents90 + 'appended mu text')91 expected_disk.tweak('A/D/G/rho',92 contents=expected_disk.desc['A/D/G/rho'].contents93 + 'new appended text for rho')94 expected_disk.add({'kappa' : Item("This is the file 'kappa'.")})95 expected_disk.remove('A/B/E/alpha', 'A/B/E/beta', 'A/B/E', 'A/D/gamma')96 export_target = sbox.add_wc_path('export')97 svntest.actions.run_and_verify_export(sbox.wc_dir,98 export_target,99 svntest.wc.State(sbox.wc_dir, {}),100 expected_disk)101def export_over_existing_dir(sbox):102 "export over existing dir"103 sbox.build()104 export_target = sbox.add_wc_path('export')105 # Create the target directory which should cause106 # the export operation to fail.107 os.mkdir(export_target)108 svntest.actions.run_and_verify_svn("No error where one is expected",109 None, svntest.SVNAnyOutput,110 'export', sbox.wc_dir, export_target)111 # As an extra precaution, make sure export_target doesn't have112 # anything in it.113 if len(os.listdir(export_target)):114 raise svntest.Failure("Unexpected files/directories in " + export_target)115def export_keyword_translation(sbox):116 "export with keyword translation"117 sbox.build()118 wc_dir = sbox.wc_dir119 # Add a keyword to A/mu and set the svn:keywords property120 # appropriately to make sure it's translated during121 # the export operation122 mu_path = os.path.join(wc_dir, 'A', 'mu')123 svntest.main.file_append(mu_path, '$LastChangedRevision$')124 svntest.main.run_svn(None, 'ps', 'svn:keywords', 125 'LastChangedRevision', mu_path)126 svntest.main.run_svn(None, 'ci',127 '--username', svntest.main.wc_author,128 '--password', svntest.main.wc_passwd,129 '-m', 'Added keyword to mu', mu_path)130 expected_disk = svntest.main.greek_state.copy()131 expected_disk.tweak('A/mu',132 contents=expected_disk.desc['A/mu'].contents + 133 '$LastChangedRevision: 2 $')134 export_target = sbox.add_wc_path('export')135 expected_output = svntest.main.greek_state.copy()136 expected_output.wc_dir = export_target137 expected_output.desc[''] = Item()138 expected_output.tweak(contents=None, status='A ')139 svntest.actions.run_and_verify_export(sbox.repo_url,140 export_target,141 expected_output,142 expected_disk)143def export_eol_translation(sbox):144 "export with eol translation"145 sbox.build()146 wc_dir = sbox.wc_dir147 # Set svn:eol-style to 'CR' to see if it's applied correctly in the148 # export operation149 mu_path = os.path.join(wc_dir, 'A', 'mu')150 svntest.main.run_svn(None, 'ps', 'svn:eol-style', 151 'CR', mu_path)152 svntest.main.run_svn(None, 'ci',153 '--username', svntest.main.wc_author,154 '--password', svntest.main.wc_passwd,155 '-m', 'Added eol-style prop to mu', mu_path)156 expected_disk = svntest.main.greek_state.copy()157 new_contents = expected_disk.desc['A/mu'].contents.replace("\n", "\r")158 expected_disk.tweak('A/mu', contents=new_contents)159 export_target = sbox.add_wc_path('export')160 expected_output = svntest.main.greek_state.copy()161 expected_output.wc_dir = export_target162 expected_output.desc[''] = Item()163 expected_output.tweak(contents=None, status='A ')164 svntest.actions.run_and_verify_export(sbox.repo_url,165 export_target,166 expected_output,167 expected_disk)168def export_working_copy_with_keyword_translation(sbox):169 "export working copy with keyword translation"170 sbox.build()171 wc_dir = sbox.wc_dir172 # Add a keyword to A/mu and set the svn:keywords property173 # appropriately to make sure it's translated during174 # the export operation175 mu_path = os.path.join(wc_dir, 'A', 'mu')176 svntest.main.file_append(mu_path, '$LastChangedRevision$')177 svntest.main.run_svn(None, 'ps', 'svn:keywords', 178 'LastChangedRevision', mu_path)179 expected_disk = svntest.main.greek_state.copy()180 expected_disk.tweak('A/mu',181 contents=expected_disk.desc['A/mu'].contents + 182 '$LastChangedRevision: 1M $')183 export_target = sbox.add_wc_path('export')184 svntest.actions.run_and_verify_export(wc_dir,185 export_target,186 svntest.wc.State(sbox.wc_dir, {}),187 expected_disk)188def export_working_copy_with_property_mods(sbox):189 "export working copy with property mods"190 sbox.build()191 wc_dir = sbox.wc_dir192 # Make a local property mod to A/mu193 mu_path = os.path.join(wc_dir, 'A', 'mu')194 svntest.main.run_svn(None, 'ps', 'svn:eol-style',195 'CR', mu_path)196 expected_disk = svntest.main.greek_state.copy()197 new_contents = expected_disk.desc['A/mu'].contents.replace("\n", "\r")198 expected_disk.tweak('A/mu', contents=new_contents)199 export_target = sbox.add_wc_path('export')200 svntest.actions.run_and_verify_export(wc_dir,201 export_target,202 svntest.wc.State(sbox.wc_dir, {}),203 expected_disk)204def export_working_copy_at_base_revision(sbox):205 "export working copy at base revision"206 sbox.build()207 wc_dir = sbox.wc_dir208 mu_path = os.path.join(wc_dir, 'A', 'mu')209 kappa_path = os.path.join(wc_dir, 'kappa')210 gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')211 E_path = os.path.join(wc_dir, 'A', 'B', 'E')212 # Appends some text to A/mu, and add a new file213 # called kappa. These modifications should *not*214 # get exported at the base revision.215 svntest.main.file_append(mu_path, 'Appended text')216 svntest.main.file_append(kappa_path, "This is the file 'kappa'.")217 svntest.main.run_svn(None, 'add', kappa_path)218 svntest.main.run_svn(None, 'rm', E_path, gamma_path)219 # Note that we don't tweak the expected disk tree at all,220 # since the appended text and kappa should not be present.221 expected_disk = svntest.main.greek_state.copy()222 export_target = sbox.add_wc_path('export')223 svntest.actions.run_and_verify_export(wc_dir,224 export_target,225 svntest.wc.State(sbox.wc_dir, {}),226 expected_disk,227 None, None, None, None,228 '-rBASE')229def export_native_eol_option(sbox):230 "export with --native-eol"231 sbox.build()232 wc_dir = sbox.wc_dir233 # Append a '\n' to A/mu and set svn:eol-style to 'native'234 # to see if it's applied correctly in the export operation235 mu_path = os.path.join(wc_dir, 'A', 'mu')236 svntest.main.run_svn(None, 'ps', 'svn:eol-style', 237 'native', mu_path)238 svntest.main.run_svn(None, 'ci',239 '--username', svntest.main.wc_author,240 '--password', svntest.main.wc_passwd,241 '-m', 'Added eol-style prop to mu', mu_path)242 expected_disk = svntest.main.greek_state.copy()243 new_contents = expected_disk.desc['A/mu'].contents.replace("\n", "\r")244 expected_disk.tweak('A/mu', contents=new_contents)245 export_target = sbox.add_wc_path('export')246 expected_output = svntest.main.greek_state.copy()247 expected_output.wc_dir = export_target248 expected_output.desc[''] = Item()249 expected_output.tweak(contents=None, status='A ')250 svntest.actions.run_and_verify_export(sbox.repo_url,251 export_target,252 expected_output,253 expected_disk,254 None, None, None, None,255 '--native-eol','CR')256def export_nonexistent_file(sbox):257 "export nonexistent file"258 sbox.build()259 wc_dir = sbox.wc_dir260 kappa_path = os.path.join(wc_dir, 'kappa')261 export_target = sbox.add_wc_path('export')262 svntest.actions.run_and_verify_svn("No error where one is expected",263 None, svntest.SVNAnyOutput,264 'export', kappa_path, export_target)265def export_unversioned_file(sbox):266 "export unversioned file"267 sbox.build()268 wc_dir = sbox.wc_dir269 kappa_path = os.path.join(wc_dir, 'kappa')270 svntest.main.file_append(kappa_path, "This is the file 'kappa'.")271 export_target = sbox.add_wc_path('export')272 svntest.actions.run_and_verify_svn("No error where one is expected",273 None, svntest.SVNAnyOutput,274 'export', kappa_path, export_target)275def export_with_state_deleted(sbox):276 "export with state deleted=true"277 sbox.build()278 wc_dir = sbox.wc_dir279 # state deleted=true caused export to crash280 alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')281 svntest.actions.run_and_verify_svn(None, None, [], 'rm', alpha_path)282 expected_output = svntest.wc.State(wc_dir, {283 'A/B/E/alpha' : Item(verb='Deleting'),284 })285 expected_status = svntest.actions.get_virginal_state(wc_dir, 2)286 expected_status.tweak(wc_rev=1)287 expected_status.remove('A/B/E/alpha')288 svntest.actions.run_and_verify_commit(wc_dir,289 expected_output, expected_status,290 None, None, None, None, None,291 wc_dir)292 export_target = sbox.add_wc_path('export')293 expected_output = svntest.wc.State(sbox.wc_dir, {})294 expected_disk = svntest.main.greek_state.copy()295 expected_disk.remove('A/B/E/alpha')296 svntest.actions.run_and_verify_export(sbox.wc_dir,297 export_target,298 expected_output,299 expected_disk)300def export_creates_intermediate_folders(sbox):301 "export and create some intermediate folders"302 sbox.build(create_wc = False)303 svntest.main.safe_rmtree(sbox.wc_dir)304 export_target = os.path.join(sbox.wc_dir, 'a', 'b', 'c')305 expected_output = svntest.main.greek_state.copy()306 expected_output.wc_dir = export_target307 expected_output.desc[''] = Item()308 expected_output.tweak(contents=None, status='A ')309 svntest.actions.run_and_verify_export(svntest.main.current_repo_url,310 export_target,311 expected_output,312 svntest.main.greek_state.copy())313########################################################################314# Run the tests315# list all tests here, starting with None:316test_list = [ None,317 export_empty_directory,318 export_greek_tree,319 export_nonexistent_url,320 export_working_copy,321 export_working_copy_with_mods,322 export_over_existing_dir,323 export_keyword_translation,324 export_eol_translation,325 export_working_copy_with_keyword_translation,326 export_working_copy_with_property_mods,327 export_working_copy_at_base_revision,328 export_native_eol_option,329 export_nonexistent_file,330 export_unversioned_file,331 export_with_state_deleted,332 export_creates_intermediate_folders,333 ]334if __name__ == '__main__':335 svntest.main.run_tests(test_list)336 # NOTREACHED...

Full Screen

Full Screen

b1-export-channel

Source:b1-export-channel Github

copy

Full Screen

1#!/usr/bin/env python2## purpose: Hardlink all packages from a channel to a target dir. 3## copyright: B1 Systems GmbH <info@b1-systems.de>, 2014.4## license: GPLv3+, http://www.gnu.org/licenses/gpl-3.0.html5## author: Mattias Giese <giese@b1-systems.de>, 2014.6## version: 0.1: first prototype with minimal functionality7import argparse8import os9import sys10import xmlrpclib11import b1_spacewalk_lib12import subprocess13sw = b1_spacewalk_lib.swauth()14client = sw.client15key = sw.key16# just testing ;)17#channel='rhel-x86_64-server-6'18noop=False19if len(sys.argv) < 2:20 print """Usage: %s channel [ noop ]21channel: The channel label i should export22noop: Dry-Run23""" % sys.argv[0]24 sys.exit(1)25channel=sys.argv[1]26if len(sys.argv) > 2 and sys.argv[2] == 'noop':27 noop = True28export_target='/var/www/html/pub/repos/' + channel29basedir='/var/satellite'30print 'Satellite base:',basedir31print 'Export target:', export_target32if not os.path.exists(export_target):33 print 'Export target',export_target,'does not exists. Creating it now'34 if not noop:35 try:36 os.makedirs(export_target)37 except OSError, e:38 print 'Error creating directory, exiting.',e39 sys.exit(1)40for package in client.channel.software.listLatestPackages(key,channel):41 pkg_path=client.packages.getDetails(key,package['id'])['path']42 target=basedir + '/' + pkg_path 43 pkg=os.path.basename(target)44 target_link=export_target + '/' + pkg45 if noop:46 print 'ln', target, target_link47 else:48 try:49 if not os.path.exists(target_link):50 subprocess.call(['/bin/ln','-s',target,target_link]) 51 print 'Processed package',pkg 52 else:53 print 'Skipping',pkg,'because it already exists in',export_target54 55 except CalledProcessError, e:56 print 'Linking',target_link,'to',target,'failed! Exception:',e...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful