<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> import os <EOL> import subprocess <EOL> import pytest <EOL> from flexmock import flexmock <EOL> from atomic_reactor . constants import EXPORTED_SQUASHED_IMAGE_NAME <EOL> from atomic_reactor . util import ImageName <EOL> from atomic_reactor . inner import DockerBuildWorkflow <EOL> from atomic_reactor . plugin import PostBuildPluginsRunner <EOL> from atomic_reactor . plugins . post_cp_built_image_to_nfs import CopyBuiltImageToNFSPlugin <EOL> from tests . constants import INPUT_IMAGE <EOL> from tests . fixtures import docker_tasker <EOL> class Y ( object ) : <EOL> pass <EOL> class X ( object ) : <EOL> image_id = INPUT_IMAGE <EOL> source = Y ( ) <EOL> source . dockerfile_path = None <EOL> source . path = None <EOL> base_image = ImageName ( repo = "<STR_LIT>" , tag = "<STR_LIT>" ) <EOL> NFS_SERVER_PATH = "<STR_LIT>" <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , [ None , "<STR_LIT>" ] ) <EOL> def test_cp_built_image_to_nfs ( tmpdir , docker_tasker , dest_dir ) : <EOL> mountpoint = tmpdir . join ( "<STR_LIT>" ) <EOL> def fake_check_call ( cmd ) : <EOL> assert cmd == [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> NFS_SERVER_PATH , <EOL> mountpoint , <EOL> ] <EOL> flexmock ( subprocess , check_call = fake_check_call ) <EOL> workflow = DockerBuildWorkflow ( { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } , "<STR_LIT>" ) <EOL> workflow . builder = X ( ) <EOL> workflow . exported_image_sequence . append ( { "<STR_LIT:path>" : os . path . join ( str ( tmpdir ) , <EOL> EXPORTED_SQUASHED_IMAGE_NAME ) } ) <EOL> open ( workflow . exported_image_sequence [ - <NUM_LIT:1> ] . get ( "<STR_LIT:path>" ) , '<STR_LIT:a>' ) . close ( ) <EOL> runner = PostBuildPluginsRunner ( <EOL> docker_tasker , <EOL> workflow , <EOL> [ { <EOL> '<STR_LIT:name>' : CopyBuiltImageToNFSPlugin . key , <EOL> '<STR_LIT:args>' : { <EOL> "<STR_LIT>" : NFS_SERVER_PATH , <EOL> "<STR_LIT>" : dest_dir , <EOL> "<STR_LIT>" : str ( mountpoint ) , <EOL> } <EOL> } ] <EOL> ) <EOL> runner . run ( ) <EOL> if dest_dir is None : <EOL> assert os . path . isfile ( os . path . join ( str ( mountpoint ) , EXPORTED_SQUASHED_IMAGE_NAME ) ) <EOL> else : <EOL> assert os . path . isfile ( os . path . join ( str ( mountpoint ) , dest_dir , EXPORTED_SQUASHED_IMAGE_NAME ) ) </s>
