<s> import uuid <EOL> from nose . plugins . attrib import attr <EOL> from manager_rest . test import base_test <EOL> from cloudify_rest_client . exceptions import FunctionsEvaluationError <EOL> @ attr ( client_min_version = <NUM_LIT:1> , client_max_version = base_test . LATEST_API_VERSION ) <EOL> class AttributesTestCase ( base_test . BaseServerTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( AttributesTestCase , self ) . setUp ( ) <EOL> self . id_ = str ( uuid . uuid4 ( ) ) <EOL> self . put_deployment ( <EOL> blueprint_file_name = '<STR_LIT>' , <EOL> blueprint_id = self . id_ , <EOL> deployment_id = self . id_ ) <EOL> instances = self . client . node_instances . list ( deployment_id = self . id_ ) <EOL> self . node1 = [ x for x in instances if x . node_id == '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . node2 = [ x for x in instances if x . node_id == '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . node3 = [ x for x in instances if x . node_id == '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . node4 = [ x for x in instances if x . node_id == '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . client . node_instances . update ( <EOL> self . node1 . id , runtime_properties = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . client . node_instances . update ( <EOL> self . node2 . id , runtime_properties = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . client . node_instances . update ( <EOL> self . node3 . id , runtime_properties = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . client . node_instances . update ( <EOL> self . node4 . id , runtime_properties = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_attributes ( self ) : <EOL> context = { <EOL> '<STR_LIT>' : self . node1 . id , <EOL> '<STR_LIT:source>' : self . node2 . id , <EOL> '<STR_LIT:target>' : self . node3 . id <EOL> } <EOL> payload = { <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } , <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } <EOL> } <EOL> expected_processed_payload = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> response = self . client . evaluate . functions ( self . id_ , <EOL> context , <EOL> payload ) <EOL> self . assertEqual ( response . deployment_id , self . id_ ) <EOL> self . assertEqual ( response . payload , expected_processed_payload ) <EOL> def test_missing_self ( self ) : <EOL> payload = { <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } , <EOL> } <EOL> try : <EOL> self . client . evaluate . functions ( self . id_ , { } , payload ) <EOL> self . fail ( ) <EOL> except FunctionsEvaluationError as e : <EOL> self . assertIn ( '<STR_LIT>' , e . message ) <EOL> def test_missing_source ( self ) : <EOL> payload = { <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } , <EOL> } <EOL> try : <EOL> self . client . evaluate . functions ( self . id_ , { } , payload ) <EOL> self . fail ( ) <EOL> except FunctionsEvaluationError as e : <EOL> self . assertIn ( '<STR_LIT>' , e . message ) <EOL> def test_missing_target ( self ) : <EOL> payload = { <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } , <EOL> } <EOL> try : <EOL> self . client . evaluate . functions ( self . id_ , { } , payload ) <EOL> self . fail ( ) <EOL> except FunctionsEvaluationError as e : <EOL> self . assertIn ( '<STR_LIT>' , e . message ) <EOL> def test_multi_instance ( self ) : <EOL> payload = { <EOL> '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } , <EOL> } <EOL> try : <EOL> self . client . evaluate . functions ( self . id_ , { } , payload ) <EOL> self . fail ( ) <EOL> except FunctionsEvaluationError as e : <EOL> self . assertIn ( '<STR_LIT>' , e . message ) </s>
