<s> from nose . tools import * <EOL> from tests . base import OsfTestCase <EOL> from tests . factories import InstitutionFactory <EOL> from website . models import Institution , Node <EOL> class TestInstitution ( OsfTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestInstitution , self ) . setUp ( ) <EOL> self . institution = InstitutionFactory ( ) <EOL> def tearDown ( self ) : <EOL> super ( TestInstitution , self ) . tearDown ( ) <EOL> Node . remove ( ) <EOL> def test_institution_save_only_changes_mapped_fields_on_node ( self ) : <EOL> node = self . institution . node <EOL> old = { <EOL> '<STR_LIT:title>' : node . title , <EOL> '<STR_LIT>' : node . institution_logo_name , <EOL> '<STR_LIT>' : node . system_tags , <EOL> '<STR_LIT>' : node . piwik_site_id <EOL> } <EOL> new = { <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> self . institution . name = new [ '<STR_LIT:title>' ] <EOL> self . institution . logo_name = new [ '<STR_LIT>' ] <EOL> self . institution . system_tags = new [ '<STR_LIT>' ] <EOL> self . institution . piwik_site_id = new [ '<STR_LIT>' ] <EOL> self . institution . save ( ) <EOL> node . reload ( ) <EOL> assert_equal ( node . title , new [ '<STR_LIT:title>' ] ) <EOL> assert_equal ( node . institution_logo_name , new [ '<STR_LIT>' ] ) <EOL> assert_equal ( node . system_tags , old [ '<STR_LIT>' ] ) <EOL> assert_not_equal ( node . system_tags , new [ '<STR_LIT>' ] ) <EOL> assert_equal ( node . piwik_site_id , old [ '<STR_LIT>' ] ) <EOL> assert_not_equal ( node . piwik_site_id , new [ '<STR_LIT>' ] ) <EOL> def test_institution_mappings ( self ) : <EOL> for key , val in self . institution . attribute_map . iteritems ( ) : <EOL> assert_equal ( getattr ( self . institution , key ) , getattr ( self . institution . node , val ) ) <EOL> def test_institution_banner_path_none ( self ) : <EOL> inst = InstitutionFactory ( ) <EOL> inst . banner_name = None <EOL> assert_is_none ( inst . banner_path , None ) <EOL> def test_institution_logo_path_none ( self ) : <EOL> inst = InstitutionFactory ( ) <EOL> inst . logo_name = None <EOL> assert_is_none ( inst . logo_path , None ) <EOL> def test_institution_find ( self ) : <EOL> insts = list ( Institution . find ( ) ) <EOL> assert_equal ( len ( insts ) , <NUM_LIT:1> ) <EOL> assert_equal ( insts [ <NUM_LIT:0> ] , self . institution ) <EOL> def test_institution_find_doesnt_find_deleted ( self ) : <EOL> self . institution . node . is_deleted = True <EOL> self . institution . node . save ( ) <EOL> insts = list ( Institution . find ( ) ) <EOL> assert_equal ( len ( insts ) , <NUM_LIT:0> ) <EOL> def test_find_deleted ( self ) : <EOL> self . institution . node . is_deleted = True <EOL> self . institution . node . save ( ) <EOL> insts = list ( Institution . find ( deleted = True ) ) <EOL> assert_equal ( len ( insts ) , <NUM_LIT:1> ) <EOL> assert_equal ( insts [ <NUM_LIT:0> ] , self . institution ) </s>
