<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> import pytest <EOL> from dockerfile_parse import DockerfileParser <EOL> from atomic_reactor . inner import DockerBuildWorkflow <EOL> from atomic_reactor . plugin import PreBuildPluginsRunner , PluginFailedException <EOL> from atomic_reactor . plugins . pre_assert_labels import AssertLabelsPlugin <EOL> from atomic_reactor . util import ImageName <EOL> from tests . constants import MOCK_SOURCE <EOL> from tests . fixtures import docker_tasker <EOL> class Y ( object ) : <EOL> pass <EOL> class X ( object ) : <EOL> image_id = "<STR_LIT>" <EOL> source = Y ( ) <EOL> source . dockerfile_path = None <EOL> source . path = None <EOL> base_image = ImageName ( repo = "<STR_LIT>" , tag = "<STR_LIT>" ) <EOL> DF_CONTENT = """<STR_LIT>""" <EOL> DF_CONTENT_LABELS = DF_CONTENT + '<STR_LIT>' <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , [ <EOL> ( DF_CONTENT , None , PluginFailedException ( ) ) , <EOL> ( DF_CONTENT_LABELS , None , None ) , <EOL> ( DF_CONTENT_LABELS , [ '<STR_LIT>' ] , PluginFailedException ( ) ) <EOL> ] ) <EOL> def test_assertlabels_plugin ( tmpdir , docker_tasker , df_content , req_labels , expected ) : <EOL> df = DockerfileParser ( str ( tmpdir ) ) <EOL> df . content = df_content <EOL> workflow = DockerBuildWorkflow ( MOCK_SOURCE , '<STR_LIT>' ) <EOL> workflow . builder = X <EOL> workflow . builder . df_path = df . dockerfile_path <EOL> workflow . builder . df_dir = str ( tmpdir ) <EOL> runner = PreBuildPluginsRunner ( <EOL> docker_tasker , <EOL> workflow , <EOL> [ { <EOL> '<STR_LIT:name>' : AssertLabelsPlugin . key , <EOL> '<STR_LIT:args>' : { '<STR_LIT>' : req_labels } <EOL> } ] <EOL> ) <EOL> assert AssertLabelsPlugin . key is not None <EOL> if isinstance ( expected , PluginFailedException ) : <EOL> with pytest . raises ( PluginFailedException ) : <EOL> runner . run ( ) <EOL> else : <EOL> runner . run ( ) </s>
