<s> from django . test import SimpleTestCase <EOL> from corehq . apps . locations . models import SQLLocation , LocationType <EOL> from corehq . apps . locations . fixtures import LocationSet <EOL> class LocationSetTest ( SimpleTestCase ) : <EOL> def test_duplicate_locations ( self ) : <EOL> parent = LocationType ( <EOL> domain = "<STR_LIT>" , <EOL> name = "<STR_LIT>" , <EOL> code = "<STR_LIT>" , <EOL> ) <EOL> child = LocationType ( <EOL> domain = "<STR_LIT>" , <EOL> name = "<STR_LIT>" , <EOL> code = "<STR_LIT>" , <EOL> parent_type = parent <EOL> ) <EOL> location1 = SQLLocation ( <EOL> id = "<STR_LIT>" , <EOL> location_id = "<STR_LIT:1>" , <EOL> name = "<STR_LIT>" , <EOL> location_type = parent <EOL> ) <EOL> location2 = SQLLocation ( <EOL> id = "<STR_LIT>" , <EOL> location_id = "<STR_LIT:2>" , <EOL> name = "<STR_LIT>" , <EOL> location_type = child , <EOL> parent = location1 <EOL> ) <EOL> set_locations = LocationSet ( [ location1 , location2 ] ) <EOL> self . assertEqual ( len ( set_locations . by_parent [ '<STR_LIT:1>' ] ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( set_locations . by_parent [ '<STR_LIT:2>' ] ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( set_locations . by_id ) , <NUM_LIT:2> ) <EOL> set_locations . add_location ( location1 ) <EOL> set_locations . add_location ( location2 ) <EOL> self . assertEqual ( len ( set_locations . by_id ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( len ( set_locations . by_parent [ '<STR_LIT:1>' ] ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( set_locations . by_parent [ '<STR_LIT:2>' ] ) , <NUM_LIT:0> ) </s>
