<s> import unittest <EOL> try : <EOL> import unittest . mock as mock <EOL> except ImportError : <EOL> import mock <EOL> from oslo_config import cfg <EOL> from cloudbaseinit . plugins . common . userdataplugins import cloudconfig <EOL> from cloudbaseinit . tests import testutils <EOL> CONF = cfg . CONF <EOL> class CloudConfigPluginTests ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . plugin = cloudconfig . CloudConfigPlugin ( ) <EOL> def test_priority ( self ) : <EOL> orig = CONF . cloud_config_plugins <EOL> CONF . cloud_config_plugins = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> expected = [ <EOL> ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:2> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:3> ) , <EOL> ] <EOL> try : <EOL> executor = cloudconfig . CloudConfigPluginExecutor ( <EOL> dummy = <NUM_LIT:1> , <EOL> dummy1 = <NUM_LIT:2> , <EOL> invalid = <NUM_LIT:3> , <EOL> write_file = <NUM_LIT:0> ) <EOL> self . assertEqual ( expected , executor . _expected_plugins ) <EOL> finally : <EOL> CONF . cloud_config_plugins = orig <EOL> def test_executor_from_yaml ( self ) : <EOL> expected_logging = [ "<STR_LIT>" ] <EOL> for invalid in ( mock . sentinel . yaml , None , <NUM_LIT:1> , int ) : <EOL> with testutils . LogSnatcher ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) as snatcher : <EOL> with self . assertRaises ( cloudconfig . CloudConfigError ) as cm : <EOL> cloudconfig . CloudConfigPluginExecutor . from_yaml ( invalid ) <EOL> self . assertEqual ( expected_logging , snatcher . output ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> str ( cm . exception ) ) <EOL> executor = cloudconfig . CloudConfigPluginExecutor . from_yaml ( '<STR_LIT:{}>' ) <EOL> self . assertIsInstance ( executor , cloudconfig . CloudConfigPluginExecutor ) <EOL> def test_invalid_type ( self ) : <EOL> with testutils . LogSnatcher ( '<STR_LIT>' <EOL> '<STR_LIT>' ) as snatcher : <EOL> self . plugin . process_non_multipart ( { '<STR_LIT>' } ) <EOL> expected = [ "<STR_LIT>" , <EOL> "<STR_LIT>" % set ] <EOL> self . assertEqual ( expected , snatcher . output ) </s>
