<s> import mock <EOL> from solum . api . controllers . camp . v1_1 . datamodel import attribute_definitions <EOL> from solum . api . controllers . camp . v1_1 . datamodel import type_definitions as model <EOL> from solum . api . controllers . camp . v1_1 import type_definitions <EOL> from solum import objects <EOL> from solum . tests import base <EOL> from solum . tests import fakes <EOL> TEST_ATTR_DEFINITION = ( <EOL> attribute_definitions . AttributeDefinition ( type = '<STR_LIT>' , <EOL> name = '<STR_LIT>' ) <EOL> ) <EOL> TEST_ATTR_DEF_LINK = ( <EOL> model . AttributeLink ( href = '<STR_LIT>' , <EOL> target_name = '<STR_LIT>' ) ) <EOL> TEST_TYPE_DEFINITION = ( <EOL> model . TypeDefinition ( type = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> description = '<STR_LIT>' , <EOL> attribute_definition_links = [ TEST_ATTR_DEF_LINK ] ) <EOL> ) <EOL> @ mock . patch ( '<STR_LIT>' , new_callable = fakes . FakePecanRequest ) <EOL> @ mock . patch ( '<STR_LIT>' , new_callable = fakes . FakePecanResponse ) <EOL> @ mock . patch ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> class TestTypeDefinitions ( base . BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestTypeDefinitions , self ) . setUp ( ) <EOL> objects . load ( ) <EOL> def test_type_definitions_get ( self , <EOL> AttributeDefinitionHandler , <EOL> TypeDefinitionHandler , <EOL> resp_mock , <EOL> request_mock ) : <EOL> thand_get_all = TypeDefinitionHandler . return_value . get_all <EOL> thand_get_all . return_value = [ TEST_TYPE_DEFINITION ] <EOL> cont = type_definitions . TypeDefinitionsController ( ) <EOL> resp = cont . get ( ) <EOL> self . assertIsNotNone ( resp ) <EOL> self . assertEqual ( <NUM_LIT:200> , resp_mock . status ) <EOL> self . assertIsNotNone ( resp [ '<STR_LIT:result>' ] . type_definition_links ) <EOL> td_links = resp [ '<STR_LIT:result>' ] . type_definition_links <EOL> self . assertEqual ( <NUM_LIT:1> , len ( td_links ) ) <EOL> self . assertEqual ( TEST_TYPE_DEFINITION . name , td_links [ <NUM_LIT:0> ] . target_name ) <EOL> def test_type_definitions_get_one ( self , <EOL> AttributeDefinitionHandler , <EOL> TypeDefinitionHandler , <EOL> resp_mock , <EOL> request_mock ) : <EOL> ahand_get = AttributeDefinitionHandler . return_value . get <EOL> ahand_get . return_value = TEST_ATTR_DEFINITION <EOL> thand_get = TypeDefinitionHandler . return_value . get <EOL> thand_get . return_value = TEST_TYPE_DEFINITION <EOL> cont = type_definitions . TypeDefinitionsController ( ) <EOL> resp = cont . get_one ( '<STR_LIT>' ) <EOL> self . assertIsNotNone ( resp ) <EOL> self . assertEqual ( <NUM_LIT:200> , resp_mock . status ) <EOL> self . assertEqual ( TEST_TYPE_DEFINITION . type , resp [ '<STR_LIT:result>' ] . type ) <EOL> self . assertEqual ( TEST_TYPE_DEFINITION . name , resp [ '<STR_LIT:result>' ] . name ) <EOL> ad_links = resp [ '<STR_LIT:result>' ] . attribute_definition_links <EOL> self . assertEqual ( <NUM_LIT:1> , len ( ad_links ) ) <EOL> self . assertEqual ( TEST_ATTR_DEFINITION . name , <EOL> ad_links [ <NUM_LIT:0> ] . target_name ) <EOL> def test_type_definition_get_not_found ( self , <EOL> AttributeDefinitionHandler , <EOL> TypeDefinitionHandler , <EOL> resp_mock , <EOL> request_mock ) : <EOL> thand_get = TypeDefinitionHandler . return_value . get <EOL> thand_get . return_value = None <EOL> cont = type_definitions . TypeDefinitionsController ( ) <EOL> resp = cont . get_one ( '<STR_LIT>' ) <EOL> self . assertIsNotNone ( resp ) <EOL> self . assertEqual ( <NUM_LIT> , resp_mock . status ) </s>
