Best Python code snippet using tempest_python
Regions.py
Source:Regions.py
1from BaseClasses import Region, Location, Entrance2def create_regions(world):3 world.regions = [4 create_region('Light World', ['Mushroom', 'Bottle Vendor', 'Haunted Grove', 'Piece of Heart (Dam)', 'Purple Chest'],5 ["Thiefs Hut", "Hyrule Castle Secret Entrance Drop", "Hyrule Castle Secret Entrance Stairs", 'Zoras River', 'Kings Grave', 'Dam',6 'Links House', 'Tavern North', 'Chicken House', 'Aginahs Cave', 'Sahasrahlas Hut', 'Kakariko Well Drop', 'Kakariko Well Cave',7 'Blacksmiths Hut', 'Bat Cave Drop Ledge', 'Bat Cave Cave', 'Sick Kids House', 'Hobo Bridge', 'Thieves Forest Hideout Drop', 'Thieves Forest Hideout Stump',8 'Lumberjack Tree Tree', 'Lumberjack Tree Cave', 'Mini Moldorm Cave', 'Ice Cave', 'Lake Hylia Central Island Pier',9 'Bonk Rock Cave', 'Library', 'Witch Hut', 'Two Brothers House (East)', 'Desert Palace Stairs', 'Eastern Palace', 'Master Sword Meadow', 'Hyrule Castle Entrance (South)',10 'Sanctuary', 'Sanctuary Grave', 'Old Man Cave (West)', 'Flute Spot 1', 'Dark Desert Teleporter', 'East Hyrule Teleporter', 'South Hyrule Teleporter', 'Kakariko Teleporter',11 'Elder House (East)', 'Elder House (West)', 'North Fairy Cave', 'North Fairy Cave Drop', 'Lost Woods Gamble', 'Snitch Lady (East)', 'Snitch Lady (West)', 'Tavern (Front)',12 'Bush Covered House', 'Light World Bomb Hut', 'Kakariko Shop', 'Long Fairy Cave', 'Good Bee Cave', '20 Rupee Cave', 'Cave Shop (Lake Hylia)', 'Waterfall of Wishing',13 'Bonk Fairy (Light)', '50 Rupee Cave', 'Fortune Teller (Light)', 'Lake Hylia Fairy', 'Swamp Fairy', 'Desert Fairy', 'Lumberjack House', 'Lake Hylia Fortune Teller', 'Kakariko Gamble Game', 'Top of Pyramid']),14 create_region('Lake Hylia Central Island', None, ['Capacity Upgrade', 'Lake Hylia Central Island Teleporter']),15 create_region('Thiefs Hut', ["[cave-022-B1] Thiefs hut [top chest]",16 "[cave-022-B1] Thiefs hut [top left chest]",17 "[cave-022-B1] Thiefs hut [top right chest]",18 "[cave-022-B1] Thiefs hut [bottom left chest]",19 "[cave-022-B1] Thiefs hut [bottom right chest]"]),20 create_region('Hyrule Castle Secret Entrance', ['Uncle', '[cave-034] Hyrule Castle Secret Entrance'], ['Hyrule Castle Secret Entrance Exit']),21 create_region('Zoras River', ['King Zora', 'Piece of Heart (Zoras River)']),22 create_region('Waterfall of Wishing', ['Waterfall Fairy - Left', 'Waterfall Fairy - Right']),23 create_region('Kings Grave', ['[cave-018] Graveyard - top right grave']),24 create_region('North Fairy Cave', None, ['North Fairy Cave Exit']),25 create_region('Dam', ['[cave-047] Dam']),26 create_region('Links House', ['[cave-040] Links House'], ['Links House Exit']),27 create_region('Tavern', ['[cave-031] Tavern']),28 create_region('Elder House', None, ['Elder House Exit (East)', 'Elder House Exit (West)']),29 create_region('Snitch Lady (East)'),30 create_region('Snitch Lady (West)'),31 create_region('Bush Covered House'),32 create_region('Tavern (Front)'),33 create_region('Light World Bomb Hut'),34 create_region('Kakariko Shop'),35 create_region('Fortune Teller (Light)'),36 create_region('Lumberjack House'),37 create_region('Bonk Fairy'), # near links house both worlds38 create_region('Healer Fairy'), # 8 entrances?39 create_region('Chicken House', ['[cave-026] Chicken House']),40 create_region('Aginahs Cave', ['[cave-044] Aginahs Cave']),41 create_region('Sahasrahlas Hut', ['[cave-035] Sahasrahlas Hut [left chest]', '[cave-035] Sahasrahlas Hut [center chest]', '[cave-035] Sahasrahlas Hut [right chest]', 'Sahasrahla']),42 create_region('Kakariko Well (top)', ['[cave-021] Kakariko Well [top chest]', '[cave-021] Kakariko Well [left chest row of 3]', '[cave-021] Kakariko Well [center chest row of 3]',43 '[cave-021] Kakariko Well [right chest row of 3]', '[cave-021] Kakariko Well [bottom chest]'], ['Kakariko Well (top to bottom)']),44 create_region('Kakariko Well (bottom)', None, ['Kakariko Well Exit']),45 create_region('Blacksmiths Hut', ['Blacksmiths']),46 create_region('Bat Cave Drop Ledge', None, ['Bat Cave Drop']),47 create_region('Bat Cave (right)', ['Magic Bat'], ['Bat Cave Door']),48 create_region('Bat Cave (left)', None, ['Bat Cave Exit']),49 create_region('Sick Kids House', ['Sick Kid']),50 create_region('Hobo Bridge', ['Hobo']),51 create_region('Thieves Forest Hideout (top)', ['Piece of Heart (Thieves Forest Hideout)'], ['Thieves Forest Hideout (top to bottom)']),52 create_region('Thieves Forest Hideout (bottom)', None, ['Thieves Forest Hideout Exit']),53 create_region('Lumberjack Tree (top)', ['Piece of Heart (Lumberjack Tree)'], ['Lumberjack Tree (top to bottom)']),54 create_region('Lumberjack Tree (bottom)', None, ['Lumberjack Tree Exit']),55 create_region('Cave South of Haunted Grove', ['Piece of Heart (Cave South of Haunted Grove)']),56 create_region('Graveyard Cave', ['Piece of Heart (Graveyard Cave)']),57 create_region('Checkerboard Cave', ['Piece of Heart (Checkerboard Cave)']),58 create_region('Long Fairy Cave'),59 create_region('Mini Moldorm Cave', ['[cave-050] Mini Moldorm Cave [bottom left chest]', '[cave-050] Mini Moldorm Cave [top left chest]', '[cave-050] Mini Moldorm Cave [top right chest]',60 '[cave-050] Mini Moldorm Cave [bottom right chest]', '[cave-050] Mini Moldorm Cave [generous guy]']),61 create_region('Ice Cave', ['[cave-051] Ice Cave']),62 create_region('Good Bee Cave'),63 create_region('20 Rupee Cave'),64 create_region('Cave Shop'), # two connectors in vanilla65 create_region('Bonk Rock Cave', ['[cave-016] Bonk Rock Cave']),66 create_region('Library', ['Library']),67 create_region('Kakariko Gamble Game'),68 create_region('Witch Hut', ['Witch']),69 create_region('Lake Hylia Island', ['Piece of Heart (Lake Hylia)']),70 create_region('Capacity Upgrade'),71 create_region('Two Brothers House', None, ['Two Brothers House Exit (East)', 'Two Brothers House Exit (West)']),72 create_region('Maze Race Ledge', ['Piece of Heart (Maze Race)'], ['Two Brothers House (West)']),73 create_region('50 Rupee Cave'),74 create_region('Desert Ledge', ['Piece of Heart (Desert - west side)'], ['Desert Palace Entrance (North) Rocks', 'Desert Palace Entrance (West)']),75 create_region('Desert Ledge (West)', None, ['Checkerboard Cave']),76 create_region('Desert Palace Stairs', None, ['Desert Palace Entrance (South)']),77 create_region('Desert Palace Lone Stairs', None, ['Desert Palace Stairs Drop', 'Desert Palace Entrance (East)']),78 create_region('Desert Palace Entrance (North) Spot', None, ['Desert Palace Entrance (North)', 'Desert Ledge Return Rocks']),79 create_region('Desert Palace Main', ['[dungeon-L2-B1] Desert Palace - Big Chest', '[dungeon-L2-B1] Desert Palace - Torch', '[dungeon-L2-B1] Desert Palace - Map Room'],80 ['Desert Palace Exit (South)', 'Desert Palace Exit (West)', 'Desert Palace Exit (East)', 'Desert Palace East Wing']),81 create_region('Desert Palace East', ['[dungeon-L2-B1] Desert Palace - Compass Room', '[dungeon-L2-B1] Desert Palace - Big Key Room']),82 create_region('Desert Palace North', ['Lanmolas - Heart Container', 'Lanmolas - Pendant'], ['Desert Palace Exit (North)']),83 create_region('Eastern Palace', ['[dungeon-L1-1F] Eastern Palace - Compass Room', '[dungeon-L1-1F] Eastern Palace - Big Chest', '[dungeon-L1-1F] Eastern Palace - Big Ball Room',84 '[dungeon-L1-1F] Eastern Palace - Big Key Room', '[dungeon-L1-1F] Eastern Palace - Map Room', 'Armos - Heart Container', 'Armos - Pendant'], ['Eastern Palace Exit']),85 create_region('Master Sword Meadow', ['Altar']),86 create_region('Lost Woods Gamble'),87 create_region('Hyrule Castle Ledge', None, ['Hyrule Castle Entrance (East)', 'Hyrule Castle Entrance (West)', 'Agahnims Tower']),88 create_region('Hyrule Castle', ['[dungeon-C-B1] Hyrule Castle - Boomerang Room', '[dungeon-C-B1] Hyrule Castle - Map Room', '[dungeon-C-B1] Hyrule Castle - Next To Zelda'],89 ['Hyrule Castle Exit (East)', 'Hyrule Castle Exit (West)', 'Hyrule Castle Exit (South)', 'Throne Room']),90 create_region('Sewer Drop', None, ['Sewer Drop']), # This exists only to be referenced for access checks91 create_region('Sewers (Dark)', ['[dungeon-C-B1] Escape - First B1 Room'], ['Sewers Door']),92 create_region('Sewers', ['[dungeon-C-B1] Escape - Final Basement Room [left chest]', '[dungeon-C-B1] Escape - Final Basement Room [middle chest]',93 '[dungeon-C-B1] Escape - Final Basement Room [right chest]'], ['Sanctuary Push Door', 'Sewers Back Door']),94 create_region('Sanctuary', ['[dungeon-C-1F] Sanctuary'], ['Sanctuary Exit']),95 create_region('Agahnims Tower', ['[dungeon-A1-2F] Hyrule Castle Tower - 2 Knife Guys Room', '[dungeon-A1-3F] Hyrule Castle Tower - Maze Room'], ['Agahnim 1', 'Agahnims Tower Exit']),96 create_region('Agahnim 1', ['Agahnim 1'], None),97 create_region('Old Man Cave', ['Old Mountain Man'], ['Old Man Cave Exit (East)', 'Old Man Cave Exit (West)']),98 create_region('Old Man House', None, ['Old Man House Exit (Bottom)', 'Old Man House Front to Back']),99 create_region('Old Man House Back', None, ['Old Man House Exit (Top)', 'Old Man House Back to Front']),100 create_region('Death Mountain', None, ['Old Man Cave (East)', 'Old Man House (Bottom)', 'Old Man House (Top)', 'Death Mountain Return Cave (East)', 'Spectacle Rock Cave', 'Spectacle Rock Cave Peak', 'Spectacle Rock Cave (Bottom)', 'Broken Bridge (West)', 'Death Mountain Teleporter']),101 create_region('Death Mountain Return Cave', None, ['Death Mountain Return Cave Exit (West)', 'Death Mountain Return Cave Exit (East)']),102 create_region('Death Mountain Return Ledge', None, ['Death Mountain Return Ledge Drop', 'Death Mountain Return Cave (West)']),103 create_region('Spectacle Rock Cave (Top)', ['Piece of Heart (Spectacle Rock Cave)'], ['Spectacle Rock Cave Drop', 'Spectacle Rock Cave Exit (Top)']),104 create_region('Spectacle Rock Cave (Bottom)', None, ['Spectacle Rock Cave Exit']),105 create_region('Spectacle Rock Cave (Peak)', None, ['Spectacle Rock Cave Peak Drop', 'Spectacle Rock Cave Exit (Peak)']),106 create_region('East Death Mountain (Bottom)', None, ['Broken Bridge (East)', '7 Chest Cave (Bottom)', '7 Chest Cave (Middle)', 'East Death Mountain Teleporter', 'Hookshot Fairy', 'Fairy Ascension Rocks', 'Spiral Cave (Bottom)']),107 create_region('Hookshot Fairy'),108 create_region('7 Chest Cave Front', None, ['7 Chest Cave Push Block Reverse', '7 Chest Cave Exit (Bottom)']),109 create_region('7 Chest Cave Chest Area', ['[cave-009-1F] Death Mountain - right cave [top left chest]',110 '[cave-009-1F] Death Mountain - right cave [top left middle chest]',111 '[cave-009-1F] Death Mountain - right cave [top right middle chest]',112 '[cave-009-1F] Death Mountain - right cave [top right chest]',113 '[cave-009-1F] Death Mountain - right cave [bottom chest]',114 '[cave-009-B1] Death Mountain - right cave [left chest]',115 '[cave-009-B1] Death Mountain - right cave [right chest]'],116 ['7 Chest Cave Push Block', '7 Chest Cave Bomb Jump']),117 create_region('7 Chest Cave', None, ['7 Chest Cave Exit (Middle)', '7 Chest Cave Exit (Top)', '7 Chest Cave Drop']),118 create_region('East Death Mountain (Top)', None, ['7 Chest Cave (Top)', 'Death Mountain (Top)', 'Spiral Cave Ledge Access', 'East Death Mountain Drop', 'Turtle Rock Teleporter', 'Fairy Ascension Ledge']),119 create_region('Spiral Cave Ledge', None, ['Spiral Cave', 'Spiral Cave Ledge Drop']),120 create_region('Spiral Cave (Top)', ['[cave-012-1F] Death Mountain - left cave]'], ['Spiral Cave (top to bottom)', 'Spiral Cave Exit (Top)']),121 create_region('Spiral Cave (Bottom)', None, ['Spiral Cave Exit']),122 create_region('Fairy Ascension Plateau', None, ['Fairy Ascension Drop', 'Fairy Ascension Cave (Bottom)']),123 create_region('Fairy Ascension Cave', None, ['Fairy Ascension Cave Exit (Top)', 'Fairy Ascension Cave Exit (Bottom)']),124 create_region('Fairy Ascension Ledge', None, ['Fairy Ascension Ledge Drop', 'Fairy Ascension Cave (Top)']),125 create_region('Death Mountain (Top)', ['Ether Tablet'], ['East Death Mountain (Top)', 'Tower of Hera', 'Death Mountain Drop']),126 create_region('Spectacle Rock', ['Piece of Heart (Spectacle Rock)'], ['Spectacle Rock Drop']),127 create_region('Tower of Hera (Bottom)', ['[dungeon-L3-1F] Tower of Hera - Freestanding Key', '[dungeon-L3-1F] Tower of Hera - Entrance'], ['Tower of Hera Small Key Door', 'Tower of Hera Big Key Door', 'Tower of Hera Exit']),128 create_region('Tower of Hera (Basement)', ['[dungeon-L3-1F] Tower of Hera - Basement']),129 create_region('Tower of Hera (Top)', ['[dungeon-L3-1F] Tower of Hera - 4F [small chest]', '[dungeon-L3-1F] Tower of Hera - Big Chest', 'Moldorm - Heart Container', 'Moldorm - Pendant']),130 create_region('East Dark World', ['Piece of Heart (Pyramid)', 'Catfish'], ['Pyramid Fairy', 'South Dark World Bridge', 'West Dark World Gap', 'Palace of Darkness', 'Dark Lake Hylia Drop (East)', 'Dark Lake Hylia Teleporter',131 'Hyrule Castle Ledge Mirror Spot', 'Dark Lake Hylia Fairy', 'Palace of Darkness Hint', 'East Dark World Hint', 'Dark World Potion Shop', 'Pyramid Hole']),132 create_region('Palace of Darkness Hint'),133 create_region('East Dark World Hint'),134 create_region('South Dark World', ['Flute Boy', 'Piece of Heart (Digging Game)', 'Bombos Tablet'], ['Dark Lake Hylia Drop (South)', 'Dark Swamp Cave', 'Swamp Palace', 'Village of Outcasts Heavy Rock',135 'Maze Race Mirror Spot', 'Cave South of Haunted Grove', 'East Dark World Bridge', 'Big Bomb Shop', 'Archery Game', 'Bonk Fairy (Dark)', 'Dark Lake Hylia Shop']),136 create_region('Big Bomb Shop'),137 create_region('Archery Game'),138 create_region('Dark Lake Hylia', None, ['Lake Hylia Island Mirror Spot', 'East Dark World Pier', 'Dark Lake Hylia Ledge']),139 create_region('Dark Lake Hylia Central Island', None, ['Ice Palace', 'Lake Hylia Central Island Mirror Spot']),140 create_region('Dark Lake Hylia Ledge', None, ['Dark Lake Hylia Ledge Drop', 'Dark Lake Hylia Ledge Fairy', 'Dark Lake Hylia Ledge Hint', 'Dark Lake Hylia Ledge Spike Cave']),141 create_region('Dark Lake Hylia Ledge Hint'),142 create_region('Dark Lake Hylia Ledge Spike Cave'),143 create_region('Dark Swamp Cave', ['[cave-073] Cave Northeast of Swamp Palace [top chest]', '[cave-073] Cave Northeast of Swamp Palace [top middle chest]', '[cave-073] Cave Northeast of Swamp Palace [bottom middle chest]',144 '[cave-073] Cave Northeast of Swamp Palace [bottom chest]', '[cave-073] Cave Northeast of Swamp Palace [generous guy]']),145 create_region('West Dark World', None, ['Village of Outcasts Drop', 'East Dark World River Pier', 'Doorless Hut', 'C-Shaped House', 'Chest Game', 'Thieves Town', 'Graveyard Cave', 'Bumper Cave (Bottom)', 'Skull Woods Forest',146 'Bat Cave Drop Ledge Mirror Spot', 'Dark World Hammer Peg Cave', 'Red Shield Shop', 'Dark Sanctuary Hint', 'Fortune Teller (Dark)', 'Dark World Shop', 'Dark World Lumberjack Shop']),147 create_region('Fortune Teller (Dark)'),148 create_region('Dark World Shop'),149 create_region('Dark World Hammer Peg Cave', ['Piece of Heart (Dark World Blacksmith Pegs)']),150 create_region('Pyramid Fairy', ['Pyramid Fairy [left chest]', 'Pyramid Fairy [right chest]']),151 create_region('Doorless Hut', ['[cave-063] Doorless Hut']),152 create_region('C-Shaped House', ['[cave-062] C-Shaped House']),153 create_region('Chest Game', ['Piece of Heart (Treasure Chest Game)']),154 create_region('Red Shield Shop'),155 create_region('Dark Sanctuary Hint'),156 create_region('Bumper Cave', None, ['Bumper Cave Exit (Bottom)', 'Bumper Cave Exit (Top)']),157 create_region('Bumper Cave Ledge', ['Piece of Heart (Bumper Cave)'], ['Bumper Cave Ledge Drop', 'Bumper Cave (Top)', 'Bumper Cave Ledge Mirror Spot']),158 create_region('Skull Woods Forest', None, ['Skull Woods First Section Hole (East)', 'Skull Woods First Section Hole (West)', 'Skull Woods First Section Hole (North)', 'Skull Woods First Section Door',159 'Skull Woods Second Section Door (East)']),160 create_region('Skull Woods Forest (West)', None, ['Skull Woods Second Section Hole', 'Skull Woods Second Section Door (West)', 'Skull Woods Final Section']),161 create_region('Dark Desert', None, ['Misery Mire', 'Dark Desert Cave', 'Desert Ledge (West) Mirror Spot', 'Desert Ledge Mirror Spot', 'Desert Palace Stairs Mirror Spot', 'Desert Palace Entrance (North) Mirror Spot',162 'Dark Desert Hint', 'Dark Desert Fairy']),163 create_region('Dark Desert Cave', ['[cave-071] Misery Mire West Area [left chest]', '[cave-071] Misery Mire West Area [right chest]']),164 create_region('Dark Desert Hint'),165 create_region('Dark Death Mountain (West Bottom)', None, ['Spike Cave', 'Spectacle Rock Mirror Spot', 'Dark Death Mountain Fairy']),166 create_region('Dark Death Mountain (Top)', None, ['Dark Death Mountain Drop (East)', 'Dark Death Mountain Drop (West)', 'Ganons Tower', 'Dark Death Mountain Ascend (Top)', 'Hookshot Cave',167 'East Death Mountain (Top) Mirror Spot', 'Turtle Rock']),168 create_region('Dark Death Mountain Ledge', None, ['Dark Death Mountain Ledge (East)', 'Dark Death Mountain Ledge (West)', 'Mimic Cave Mirror Spot', 'Spiral Cave Mirror Spot']),169 create_region('Dark Death Mountain Isolated Ledge', None, ['Isolated Ledge Mirror Spot', 'Turtle Rock Isolated Ledge Entrance']),170 create_region('Dark Death Mountain (East Bottom)', None, ['Dark Death Mountain Ascend (Bottom)', 'Cave Shop (Dark Death Mountain)', 'Fairy Ascension Mirror Spot']),171 create_region('Dark Death Mountain Ascend', ['[cave-057-1F] Dark World Death Mountain Climb [top chest]', '[cave-057-1F] Dark World Death Mountain Climb [bottom chest]'],172 ['Dark Death Mountain Ascend Exit (Top)', 'Dark Death Mountain Ascend Exit (Bottom)']),173 create_region('Spike Cave', ['[cave-055] Spike Cave']),174 create_region('Hookshot Cave', ['[cave-056] Hookshot Cave [top right chest]', '[cave-056] Hookshot Cave [top left chest]', '[cave-056] Hookshot Cave [bottom right chest]', '[cave-056] Hookshot Cave [bottom left chest]'],175 ['Hookshot Cave Exit (South)', 'Hookshot Cave Exit (North)']),176 create_region('Death Mountain Floating Island', ['Piece of Heart (Death Mountain - Floating Island)'], ['Floating Island Drop', 'Hookshot Cave Back Entrance']),177 create_region('Turtle Rock (Top)', None, ['Turtle Rock Drop']),178 create_region('Mimic Cave', ['[cave-013] Mimic Cave']),179 create_region('Swamp Palace (Entrance)', None, ['Swamp Palace Moat', 'Swamp Palace Exit']),180 create_region('Swamp Palace (First Room)', ['[dungeon-D2-1F] Swamp Palace - First Room'], ['Swamp Palace Small Key Door']),181 create_region('Swamp Palace (Starting Area)', ['[dungeon-D2-1F] Swamp Palace - Map Room'], ['Swamp Palace (Center)']),182 create_region('Swamp Palace (Center)', ['[dungeon-D2-B1] Swamp Palace - Big Chest', '[dungeon-D2-B1] Swamp Palace - South of Hookshot Room',183 '[dungeon-D2-B1] Swamp Palace - Big Key Chest', '[dungeon-D2-B1] Swamp Palace - Compass Chest'], ['Swamp Palace (North)']),184 create_region('Swamp Palace (North)', ['[dungeon-D2-B2] Swamp Palace - Flooded Room [left chest]', '[dungeon-D2-B2] Swamp Palace - Flooded Room [right chest]',185 '[dungeon-D2-B2] Swamp Palace - Waterfall Room', 'Arrghus - Heart Container', 'Arrghus - Crystal']),186 create_region('Thieves Town (Entrance)', ['[dungeon-D4-B1] Thieves Town - Bottom Left of Huge Room [bottom right chest]',187 '[dungeon-D4-B1] Thieves Town - Bottom Left of Huge Room [top left chest]',188 '[dungeon-D4-B1] Thieves Town - Bottom Right of Huge Room',189 '[dungeon-D4-B1] Thieves Town - Top Left of Huge Room'], ['Thieves Town Big Key Door', 'Thieves Town Exit']),190 create_region('Thieves Town (Deep)', ['[dungeon-D4-1F] Thieves Town - Room above Boss',191 '[dungeon-D4-B2] Thieves Town - Big Chest',192 '[dungeon-D4-B2] Thieves Town - Chest next to Blind'], ['Blind Fight']),193 create_region('Blind Fight', ['Blind - Heart Container', 'Blind - Crystal']),194 create_region('Skull Woods First Section', ['[dungeon-D3-B1] Skull Woods - Compass Room', '[dungeon-D3-B1] Skull Woods - East of Big Chest',195 '[dungeon-D3-B1] Skull Woods - Big Chest', '[dungeon-D3-B1] Skull Woods - Push Statue Room',196 '[dungeon-D3-B1] Skull Woods - South of Big Chest'], ['Skull Woods First Section Exit']),197 create_region('Skull Woods First Section (Right)', None, ['Skull Woods First Section (Right)']), # drop through regions for unique hole targets198 create_region('Skull Woods First Section (Left)', None, ['Skull Woods First Section (Left)']),199 create_region('Skull Woods First Section (Top)', None, ['Skull Woods First Section (Top)']),200 create_region('Skull Woods Second Section', ['[dungeon-D3-B1] Skull Woods - Big Key Room'], ['Skull Woods Second Section Exit (East)', 'Skull Woods Second Section Exit (West)']),201 create_region('Skull Woods Final Section (Entrance)', ['[dungeon-D3-B1] Skull Woods - Final Section Entrance'], ['Skull Woods Torch Room', 'Skull Woods Final Section Exit']),202 create_region('Skull Woods Final Section (Mothula)', ['Mothula - Heart Container', 'Mothula - Crystal']),203 create_region('Ice Palace (Entrance)', None, ['Ice Palace Entrance Room', 'Ice Palace Exit']),204 create_region('Ice Palace (Main)', ['[dungeon-D5-B1] Ice Palace - Compass Room', '[dungeon-D5-B4] Ice Palace - Above Big Chest',205 '[dungeon-D5-B5] Ice Palace - Big Chest', '[dungeon-D5-B5] Ice Palace - Jellyfish Room'], ['Ice Palace (East)', 'Ice Palace (Kholdstare)']),206 create_region('Ice Palace (East)', ['[dungeon-D5-B3] Ice Palace - Spike Room'], ['Ice Palace (East Top)']),207 create_region('Ice Palace (East Top)', ['[dungeon-D5-B1] Ice Palace - Big Key Room', '[dungeon-D5-B2] Ice Palace - Map Room']),208 create_region('Ice Palace (Kholdstare)', ['Kholdstare - Heart Container', 'Kholdstare - Crystal']),209 create_region('Misery Mire (Entrance)', None, ['Misery Mire Entrance Gap', 'Misery Mire Exit']),210 create_region('Misery Mire (Main)', ['[dungeon-D6-B1] Misery Mire - Big Chest', '[dungeon-D6-B1] Misery Mire - Map Room', '[dungeon-D6-B1] Misery Mire - Hub Room',211 '[dungeon-D6-B1] Misery Mire - End of Bridge', '[dungeon-D6-B1] Misery Mire - Spike Room'], ['Misery Mire (West)', 'Misery Mire Big Key Door']),212 create_region('Misery Mire (West)', ['[dungeon-D6-B1] Misery Mire - Compass Room', '[dungeon-D6-B1] Misery Mire - Big Key Room']),213 create_region('Misery Mire (Final Area)', None, ['Misery Mire (Vitreous)']),214 create_region('Misery Mire (Vitreous)', ['Vitreous - Heart Container', 'Vitreous - Crystal']),215 create_region('Turtle Rock (Entrance)', None, ['Turtle Rock Entrance Gap', 'Turtle Rock Exit (Front)']),216 create_region('Turtle Rock (First Section)', ['[dungeon-D7-1F] Turtle Rock - Compass Room', '[dungeon-D7-1F] Turtle Rock - Map Room [left chest]',217 '[dungeon-D7-1F] Turtle Rock - Map Room [right chest]'], ['Turtle Rock Pokey Room', 'Turtle Rock Entrance Gap Reverse']),218 create_region('Turtle Rock (Chain Chomp Room)', ['[dungeon-D7-1F] Turtle Rock - Chain Chomp Room'], ['Turtle Rock (Chain Chomp Room) (North)', 'Turtle Rock (Chain Chomp Room) (South)']),219 create_region('Turtle Rock (Second Section)', ['[dungeon-D7-B1] Turtle Rock - Big Key Room'], ['Turtle Rock Ledge Exit (West)', 'Turtle Rock Chain Chomp Staircase', 'Turtle Rock Big Key Door']),220 create_region('Turtle Rock (Big Chest)', ['[dungeon-D7-B1] Turtle Rock - Big Chest'], ['Turtle Rock (Big Chest) (North)', 'Turtle Rock Ledge Exit (East)']),221 create_region('Turtle Rock (Roller Switch Room)', ['[dungeon-D7-B1] Turtle Rock - Roller Switch Room'], ['Turtle Rock Dark Room Staircase', 'Turtle Rock Big Key Door Reverse']),222 create_region('Turtle Rock (Dark Room)', None, ['Turtle Rock (Dark Room) (North)', 'Turtle Rock (Dark Room) (South)']),223 create_region('Turtle Rock (Eye Bridge)', ['[dungeon-D7-B2] Turtle Rock - Eye Bridge Room [bottom left chest]', '[dungeon-D7-B2] Turtle Rock - Eye Bridge Room [bottom right chest]',224 '[dungeon-D7-B2] Turtle Rock - Eye Bridge Room [top left chest]', '[dungeon-D7-B2] Turtle Rock - Eye Bridge Room [top right chest]'],225 ['Turtle Rock Dark Room (South)', 'Turtle Rock (Trinexx)', 'Turtle Rock Isolated Ledge Exit']),226 create_region('Turtle Rock (Trinexx)', ['Trinexx - Heart Container', 'Trinexx - Crystal']),227 create_region('Dark Palace (Entrance)', ['[dungeon-D1-B1] Dark Palace - Shooter Room'], ['Dark Palace Bridge Room', 'Dark Palace Bonk Wall', 'Dark Palace Exit']),228 create_region('Dark Palace (Center)', ['[dungeon-D1-1F] Dark Palace - Jump Room [left chest]', '[dungeon-D1-B1] Dark Palace - Turtle Stalfos Room'],229 ['Dark Palace Big Key Chest Staircase', 'Dark Palace (North)', 'Dark Palace Big Key Door']),230 create_region('Dark Palace (Big Key Chest)', ['[dungeon-D1-1F] Dark Palace - Big Key Room']),231 create_region('Dark Palace (Bonk Section)', ['[dungeon-D1-1F] Dark Palace - Jump Room [right chest]', '[dungeon-D1-1F] Dark Palace - Statue Push Room'], ['Dark Palace Hammer Peg Drop']),232 create_region('Dark Palace (North)', ['[dungeon-D1-1F] Dark Palace - Compass Room', '[dungeon-D1-B1] Dark Palace - Dark Room [left chest]', '[dungeon-D1-B1] Dark Palace - Dark Room [right chest]'],233 ['Dark Palace Spike Statue Room Door', 'Dark Palace Maze Door']),234 create_region('Dark Palace (Maze)', ['[dungeon-D1-1F] Dark Palace - Maze Room [top chest]', '[dungeon-D1-1F] Dark Palace - Maze Room [bottom chest]', '[dungeon-D1-1F] Dark Palace - Big Chest']),235 create_region('Dark Palace (Spike Statue Room)', ['[dungeon-D1-1F] Dark Palace - Spike Statue Room']),236 create_region('Dark Palace (Final Section)', ['Helmasaur - Heart Container', 'Helmasaur - Crystal']),237 create_region('Ganons Tower (Entrance)', ['[dungeon-A2-1F] Ganons Tower - Torch', '[dungeon-A2-1F] Ganons Tower - Right Staircase [left chest]', '[dungeon-A2-1F] Ganons Tower - Right Staircase [right chest]'],238 ['Ganons Tower (Tile Room)', 'Ganons Tower (Hookshot Room)', 'Ganons Tower Big Key Door', 'Ganons Tower Exit']),239 create_region('Ganons Tower (Tile Room)', ['[dungeon-A2-1F] Ganons Tower - Tile Room'], ['Ganons Tower (Tile Room) Key Door']),240 create_region('Ganons Tower (Compass Room)', ['[dungeon-A2-1F] Ganons Tower - Compass Room [top left chest]', '[dungeon-A2-1F] Ganons Tower - Compass Room [top right chest]',241 '[dungeon-A2-1F] Ganons Tower - Compass Room [bottom left chest]', '[dungeon-A2-1F] Ganons Tower - Compass Room [bottom right chest]'],242 ['Ganons Tower (Bottom) (East)']),243 create_region('Ganons Tower (Hookshot Room)', ['[dungeon-A2-1F] Ganons Tower - North of Hookshot Room [top left chest]', '[dungeon-A2-1F] Ganons Tower - North of Hookshot Room [top right chest]',244 '[dungeon-A2-1F] Ganons Tower - North of Hookshot Room [bottom left chest]', '[dungeon-A2-1F] Ganons Tower - North of Hookshot Room [bottom right chest]'],245 ['Ganons Tower (Map Room)', 'Ganons Tower (Double Switch Room)']),246 create_region('Ganons Tower (Map Room)', ['[dungeon-A2-1F] Ganons Tower - Map Room']),247 create_region('Ganons Tower (Firesnake Room)', ['[dungeon-A2-1F] Ganons Tower - Firesnake Room'], ['Ganons Tower (Firesnake Room)']),248 create_region('Ganons Tower (Teleport Room)', ['[dungeon-A2-1F] Ganons Tower - Teleport Room [top left chest]', '[dungeon-A2-1F] Ganons Tower - Teleport Room [top right chest]',249 '[dungeon-A2-1F] Ganons Tower - Teleport Room [bottom left chest]', '[dungeon-A2-1F] Ganons Tower - Teleport Room [bottom right chest]'],250 ['Ganons Tower (Bottom) (West)']),251 create_region('Ganons Tower (Bottom)', ['[dungeon-A2-1F] Ganons Tower - above Armos', '[dungeon-A2-1F] Ganons Tower - Big Chest', '[dungeon-A2-B1] Ganons Tower - Armos Room [left chest]',252 '[dungeon-A2-B1] Ganons Tower - Armos Room [right chest]', '[dungeon-A2-B1] Ganons Tower - Armos Room [bottom chest]']),253 create_region('Ganons Tower (Top)', None, ['Ganons Tower Torch Rooms']),254 create_region('Ganons Tower (Before Moldorm)', ['[dungeon-A2-6F] Ganons Tower - Mini Helmasaur Room [left chest]', '[dungeon-A2-6F] Ganons Tower - Mini Helmasaur Room [right chest]',255 '[dungeon-A2-6F] Ganons Tower - Room before Moldorm'], ['Ganons Tower Moldorm Door']),256 create_region('Ganons Tower (Moldorm)', None, ['Ganons Tower Moldorm Gap']),257 create_region('Agahnim 2', ['[dungeon-A2-6F] Ganons Tower - Moldorm Room', 'Agahnim 2'], None),258 create_region('Pyramid', ['Ganon'], ['Ganon Drop']),259 create_region('Bottom of Pyramid', None, ['Pyramid Exit']),260 create_region('Pyramid Ledge', None, ['Pyramid Entrance', 'Pyramid Drop'])261 ]262def create_region(name, locations=None, exits=None):263 ret = Region(name)264 if locations is None:265 locations = []266 if exits is None:267 exits = []268 for exit in exits:269 ret.exits.append(Entrance(exit, ret))270 for location in locations:271 address, crystal, hint_text = location_table[location]272 ret.locations.append(Location(location, address, crystal, hint_text, ret))273 return ret274location_table = {'Mushroom': (0x180013, False, 'in the woods'),275 'Bottle Vendor': (0x2EB18, False, 'with a merchant'),276 'Haunted Grove': (0x18014A, False, 'underground'),...
test_editor_api.py
Source:test_editor_api.py
...42 Generate the convex hull of the regions. # noqa: E50143 """44 r1 = Region()45 r1.region_string = 'Rect J2000 0 0 10 10'46 self.api.create_region("test1", RegionRequest(r1))47 r2 = self.api.get_region("test1").region48 49 req = RegionRequest()50 req.selection = ["test1",]51 self.api.c_hull_regions("test2", req)52 r3 = self.api.get_region("test2").region5354 req.selection = ["test2",]55 self.api.c_hull_regions("test3", req)56 r4 = self.api.get_region("test3").region5758 self.assertGreaterEqual(r3.area,r2.area)59 self.assertGreaterEqual(r4.area,r3.area)6061 def test_copy_region(self):62 """Test case for copy_region6364 Copy a region. # noqa: E50165 """66 r1 = Region()67 r1.region_string = 'Rect J2000 0 0 10 10'68 self.api.create_region("test1", RegionRequest(r1))69 70 req = RegionRequest()71 req.selection = ["test1",]72 self.api.copy_region("test2", req)7374 r2 = self.api.get_region("test1").region75 r3 = self.api.get_region("test2").region76 self.assertEqual(r2.area,r3.area)7778 def test_create_region(self):79 """Test case for create_region8081 Create a new region. # noqa: E50182 """83 r1 = Region()84 r1.region_string = 'CIRCLE J2000 10 10 10'85 self.api.create_region("test", RegionRequest(r1))86 r2 = self.api.get_region("test").region87 self.assertEqual(0.087266401064508378, r2.area)8889 r3 = self.api.create_region("test2", { "region": { "regionString": "CIRCLE J2000 20 20 10"}})90 self.assertEqual(0.08726640106450838, r3.region.area)919293 def test_delete_footprint(self):94 """Test case for delete_footprint9596 Delete footprint and reset the editor. # noqa: E50197 """98 r1 = Region()99 r1.region_string = 'CIRCLE J2000 10 10 10'100 r2 = Region()101 r2.region_string = 'CIRCLE J2000 10 10 10'102 r3 = Region()103 r3.region_string = 'CIRCLE J2000 10 10 10'104 self.api.create_region("test1", RegionRequest(r1))105 self.api.create_region("test2", RegionRequest(r2))106 self.api.create_region("test3", RegionRequest(r3))107 req = FootprintRequest()108 req.footprint = Footprint()109 req.footprint.combination_method = CombinationMethod.UNION110 res1 = self.api.list_regions()111 self.api.modify_footprint(req)112 self.api.delete_footprint()113 self.api.list_regions()114 res2 = self.api.list_regions()115 self.assertEqual(len(res2.regions), 0)116117 def test_delete_region(self):118 """Test case for delete_region119120 Delete a region. # noqa: E501121 """122 r1 = Region()123 r1.region_string = 'CIRCLE J2000 10 10 10'124 self.api.create_region("test1", RegionRequest(r1))125 self.api.delete_region("test1")126 res = self.api.list_regions()127 self.assertEqual(len(res.regions), 0)128 129 r2 = Region()130 r2.region_string = 'CIRCLE J2000 10 10 10'131 self.api.create_region("test2", RegionRequest(r2))132 self.api.create_region("test1", RegionRequest(r1))133 self.api.delete_region("test1")134 res = self.api.list_regions()135 self.assertEqual(len(res.regions), 1)136137 def test_download_footprint(self):138 """Test case for download_footprint139140 Returns the footprint in raw format text or binary. # noqa: E501141 """142 r1 = Region()143 r1.region_string = 'CIRCLE J2000 10 10 10'144 self.api.create_region("test1", RegionRequest(r1))145 r2 = Region()146 r2.region_string = 'CIRCLE J2000 1 1 10'147 self.api.create_region("test2", RegionRequest(r2))148 req = FootprintRequest()149 req.footprint = Footprint()150 req.footprint.combination_method = CombinationMethod.UNION151 self.api.modify_footprint(req)152 outline = self.api.download_footprint(accept="text/plain", _preload_content=False)153 self.assertEqual(outline.data, b'REGION\r\n CONVEX\r\n 0.9698463103929541 0.17101007166283433 0.17364817766693033 0.99999576920548627\r\n\r\n CONVEX\r\n 0.99969541350954794 0.017449748351250485 0.017452406437283512 0.99999576920548627\r\n\r\n')154 155156 def test_download_footprint_outline(self):157 """Test case for download_footprint_outline158159 Returns the outline of the footprint. # noqa: E501160 """161 r1 = Region()162 r1.region_string = 'CIRCLE J2000 10 10 10'163 self.api.create_region("test1", RegionRequest(r1))164 r2 = Region()165 r2.region_string = 'CIRCLE J2000 20 20 10'166 self.api.create_region("test2", RegionRequest(r2))167168 req = FootprintRequest()169 req.footprint = Footprint()170 req.footprint.combination_method = CombinationMethod.UNION171 self.api.modify_footprint(req)172 self.api.download_footprint_outline(accept="text/plain", _preload_content=False)173174 self.assertEqual(self.ssclient.last_response.data,b'OUTLINE\r\n LOOP\r\n ARC 0.9698463103929541 0.17101007166283433 0.17364817766693033 0.99999576920548627 0.97034732853354255 0.16814466256280783 0.17364744299717294 0.97034732853354255 0.16814466256280783 0.17364744299717294\r\n\r\n LOOP\r\n ARC 0.88302222155948906 0.32139380484326968 0.34202014332566871 0.99999576920548627 0.88401338053904255 0.318658993915464 0.34201869630872272 0.88401338053904255 0.318658993915464 0.34201869630872272\r\n\r\n')175176 def test_download_region(self):177 """Test case for download_region178179 Returns the shape description of the footprint region. # noqa: E501180 """181 r1 = Region()182 r1.region_string = 'CIRCLE J2000 10 10 10'183 self.api.create_region("test_download_region", RegionRequest(r1))184 self.api.download_region("test_download_region", accept="text/plain", _preload_content=False)185 self.assertEqual(self.ssclient.last_response.data,b'REGION\r\n CONVEX\r\n 0.9698463103929541 0.17101007166283433 0.17364817766693033 0.99999576920548627\r\n\r\n')186187 def test_download_region_outline(self):188 """Test case for download_region_outline189190 Returns the outline of the footprint. # noqa: E501191 """192 r1 = Region()193 r1.region_string = 'CIRCLE J2000 10 10 10'194 self.api.create_region("test_download_region_outline", RegionRequest(r1))195 self.api.download_region_outline("test_download_region_outline", accept="text/plain", _preload_content=False)196 self.assertEqual(self.ssclient.last_response.data, b'OUTLINE\r\n LOOP\r\n ARC 0.9698463103929541 0.17101007166283433 0.17364817766693033 0.99999576920548627 0.97034732853354255 0.16814466256280783 0.17364744299717294 0.97034732853354255 0.16814466256280783 0.17364744299717294\r\n\r\n')197198 def test_get_footprint(self):199 """Test case for get_footprint200201 Returns the header information of the edited footprint # noqa: E501202 """203 r1 = Region()204 r1.region_string = 'CIRCLE J2000 10 10 10'205 self.api.create_region("test", RegionRequest(r1))206 req = FootprintRequest()207 req.footprint = Footprint()208 req.footprint.combination_method = CombinationMethod.UNION209 self.api.modify_footprint(req)210 211 res = self.api.get_footprint()212 self.assertEqual(res.footprint.name, 'new_footprint')213214 def test_get_footprint_outline_points(self):215 """Test case for get_footprint_outline_points216217 Returns the points of the outline of the footprint. # noqa: E501218 """219 r1 = Region()220 r1.region_string = 'CIRCLE J2000 10 10 0.1'221 self.api.create_region("test1", RegionRequest(r1))222 r2 = Region()223 r2.region_string = 'CIRCLE J2000 0 0 0.1'224 self.api.create_region("test2", RegionRequest(r2))225 req = FootprintRequest()226 req.footprint = Footprint()227 req.footprint.combination_method = CombinationMethod.UNION228 self.api.modify_footprint(req)229 points = self.api.get_footprint_outline_points()230 self.assertEqual(self.ssclient.last_response.data, "[{\"lon\":9.9983076222260951,\"lat\":9.9999999957257124},{\"lon\":9.9991538148716028,\"lat\":9.9985566231837328},{\"lon\":10.000846185128445,\"lat\":9.9985566231837328},{\"lon\":10.00169237777399,\"lat\":9.9999999957257124},{\"lon\":10.000846192645945,\"lat\":10.001443374679123},{\"lon\":9.9983076222260951,\"lat\":9.9999999957257124},{\"lon\":359.99833333324716,\"lat\":0.0},{\"lon\":359.99916666662358,\"lat\":-0.0014433757476998812},{\"lon\":0.00083333337639550733,\"lat\":-0.0014433757476998814},{\"lon\":0.0016666667528350855,\"lat\":-2.041010695154396E-19},{\"lon\":0.00083333337639550733,\"lat\":0.001443375747699881},{\"lon\":359.99833333324716,\"lat\":0.0}]")231232 def test_get_region(self):233 """Test case for get_region234235 Returns the header information of a region. # noqa: E501236 """237 r1 = Region()238 r1.region_string = 'CIRCLE J2000 10 10 10'239 self.api.create_region("test1", RegionRequest(r1))240 r2 = Region()241 r2.region_string = 'CIRCLE J2000 10 10 11'242 self.api.create_region("test2", RegionRequest(r2))243 self.api.get_region("test1",_preload_content=False)244 self.assertEqual(self.ssclient.last_response.data, b"{\"region\":{\"footprintName\":\"new_footprint\",\"name\":\"test1\",\"fillFactor\":1.0,\"isSimplified\":true,\"area\":0.087266401064508378}}")245246 def test_get_region_outline_points(self):247 """Test case for get_region_outline_points248249 Returns the points of the outline of the region. # noqa: E501250 """251 r1 = Region()252 r1.region_string = 'CIRCLE J2000 10 10 0.1'253 self.api.create_region("test", RegionRequest(r1))254 self.api.get_region_outline_points("test")255 self.assertEqual(self.ssclient.last_response.data,"[{\"lon\":9.9983076222260951,\"lat\":9.9999999957257124},{\"lon\":9.9991538148716028,\"lat\":9.9985566231837328},{\"lon\":10.000846185128445,\"lat\":9.9985566231837328},{\"lon\":10.00169237777399,\"lat\":9.9999999957257124},{\"lon\":10.000846192645945,\"lat\":10.001443374679123},{\"lon\":9.9983076222260951,\"lat\":9.9999999957257124}]")256257 def test_grow_region(self):258 """Test case for grow_region259260 Grow region. # noqa: E501261 """262 r1 = Region()263 r1.region_string = 'CIRCLE J2000 10 10 10'264 self.api.create_region("test1", RegionRequest(r1))265266 req = RegionRequest()267 req.selection = ["test1",]268 req.keep_original = True269 self.api.grow_region("test2", req, radius=1)270 271 r1 = self.api.get_region("test1").region272 r2 = self.api.get_region("test2").region 273 274 self.assertLess(r1.area, r2.area)275276 def test_intersect_regions(self):277 """Test case for intersect_regions278279 Compute the intersection of regions. # noqa: E501280 """281 r1 = Region()282 r1.region_string = 'CIRCLE J2000 10 10 200'283 self.api.create_region("test1", RegionRequest(r1))284 r2 = Region()285 r3 = Region()286 r2.region_string = 'CIRCLE J2000 11 11 200'287 self.api.create_region("test2", RegionRequest(r2))288 289 req = RegionRequest()290 req.selection = ["test1", "test2"]291 req.keep_original = True292 self.api.intersect_regions("test3",req)293294 r1 = self.api.get_region("test1")295 r2 = self.api.get_region("test2")296 r3 = self.api.get_region("test3")297298 self.assertLessEqual(r3.region.area, r1.region.area)299 self.assertLessEqual(r3.region.area, r2.region.area)300301 def test_list_regions(self):302 """Test case for list_regions303304 List regions. # noqa: E501305 """306 r1 = Region()307 r1.region_string = 'CIRCLE J2000 10 10 10'308 self.api.create_region("testlist1", RegionRequest(r1))309 self.api.list_regions()310 self.assertEqual(self.ssclient.last_response.data, "{\"regions\":[{\"footprintName\":\"new_footprint\",\"name\":\"testlist1\",\"fillFactor\":1.0,\"isSimplified\":true,\"area\":0.087266401064508378}]}")311312 r2 = Region()313 r2.region_string = 'CIRCLE J2000 11 10 10'314 self.api.create_region("testlist2", RegionRequest(r2))315 self.api.list_regions()316 self.assertEqual(self.ssclient.last_response.data, "{\"regions\":[{\"footprintName\":\"new_footprint\",\"name\":\"testlist1\",\"fillFactor\":1.0,\"isSimplified\":true,\"area\":0.087266401064508378},{\"footprintName\":\"new_footprint\",\"name\":\"testlist2\",\"fillFactor\":1.0,\"isSimplified\":true,\"area\":0.087266401064508378}]}")317318319 def test_modify_footprint(self):320 """Test case for modify_footprint321322 Modified the properties of the footprint in the editor. # noqa: E501323 """324 r1 = Region()325 r1.region_string = 'CIRCLE J2000 10 10 10'326 self.api.create_region("tes1", RegionRequest(r1))327 r2 = Region()328 r2.region_string = 'CIRCLE J2000 11 10 10'329 self.api.create_region("test2", RegionRequest(r2))330331 req = FootprintRequest()332 req.footprint = Footprint()333 req.footprint.combination_method = CombinationMethod.UNION334335 self.api.modify_footprint(req)336 337 r3 = self.api.get_footprint();338 self.assertEqual(r3.footprint.combination_method, 'union')339340 req.footprint.combination_method = CombinationMethod.INTERSECT341342 self.api.modify_footprint(req)343 344 r3 = self.api.get_footprint();345 self.assertEqual(r3.footprint.combination_method, 'intersect')346347 def test_modify_region(self):348 """Test case for modify_region349350 Modify a region. # noqa: E501351 """352 r1 = Region()353 r1.region_string = 'CIRCLE J2000 10 10 10'354 self.api.create_region("test_mregion1", RegionRequest(r1))355 r2 = Region()356 r2.region_string = 'CIRCLE J2000 20 20 20'357 self.api.modify_region("test_mregion1", RegionRequest(r2))358 self.assertEqual(self.ssclient.last_response.data, "{\"region\":{\"footprintName\":\"new_footprint\",\"name\":\"test_mregion1\",\"fillFactor\":1.0,\"isSimplified\":true,\"area\":0.34906486584773644}}")359 360 def test_rename_region(self):361 """Test case for move_region362363 Move a region. # noqa: E501364 """365 r1 = Region()366 r1.region_string = 'CIRCLE J2000 10 10 10'367 self.api.create_region("test", RegionRequest(r1))368 req = RegionRequest()369 req.selection = ["test",]370 self.api.rename_region("test_rename", req)371 self.api.list_regions()372 self.assertEqual(self.ssclient.last_response.data, "{\"regions\":[{\"footprintName\":\"new_footprint\",\"name\":\"test_rename\",\"fillFactor\":1.0,\"isSimplified\":true,\"area\":0.087266401064508378}]}")373374 def test_plot_footprint(self):375 """Test case for plot_footprint376377 Plots the footprint # noqa: E501378 """379 r1 = Region()380 r1.region_string = 'CIRCLE J2000 10 10 100'381 r2 = Region()382 r2.region_string = 'CIRCLE J2000 1 11 110'383 r3 = Region()384 r3.region_string = 'CIRCLE J2000 40 40 400'385 self.api.create_region("test1", RegionRequest(r1))386 self.api.create_region("test2", RegionRequest(r2))387 self.api.create_region("test3", RegionRequest(r3))388389 req = FootprintRequest()390 req.footprint = Footprint()391 req.footprint.combination_method = CombinationMethod.UNION392 self.api.modify_footprint(req)393394 self.api.plot_region("test1", "image/png", _preload_content=False)395 self.assertEqual("tested","tested")396397 self.api.plot_footprint("image/png", _preload_content=False)398399 def test_plot_footprint_advanced(self):400 """Test case for plot_footprint_advanced401402 Plots the footprint, with advanced parameters # noqa: E501403 """404# self.fail()405 r1 = Region()406 r1.region_string = 'CIRCLE J2000 10 10 100'407 r2 = Region()408 r2.region_string = 'CIRCLE J2000 1 11 110'409 r3 = Region()410 r3.region_string = 'CIRCLE J2000 40 40 400'411 self.api.create_region("test1", RegionRequest(r1))412 self.api.create_region("test2", RegionRequest(r2))413 self.api.create_region("test3", RegionRequest(r3))414415 req = FootprintRequest()416 req.footprint = Footprint()417 req.footprint.combination_method = CombinationMethod.UNION418 self.api.modify_footprint(req)419420 self.api.plot_region("test1", "image/png", _preload_content=False)421 preq = PlotRequest()422 preq.plot = Plot()423 self.api.plot_footprint_advanced(preq, "image/png", _preload_content=False)424425426 def test_plot_region(self):427 """Test case for plot_region428429 Plots the region # noqa: E501430 """431 r1 = Region()432 r1.region_string = 'CIRCLE J2000 10 10 100'433 r1.region_string = 'RECT J2000 0 0 10 20'434 self.api.create_region("test", RegionRequest(r1))435 436 res = self.api.plot_region("test", accept="image/png", _preload_content=False)437 self.api.plot_region("test", accept='image/jpeg', _preload_content=False)438 self.api.plot_region("test", accept='image/gif', _preload_content=False)439 self.api.plot_region("test", accept='image/bmp', _preload_content=False)440 #self.api.plot_region("test", accept='application/pdf',441 #_preload_content=False)442 #self.api.plot_region("test", accept='application/postscript',443 #_preload_content=False)444 #self.api.plot_region("test", accept='windows/metafile',445 #_preload_content=False)446 self.api.plot_region("test", accept="image/png",projection="GALJ2000", color_theme="green" , _preload_content=False)447 self.assertEqual("tested","tested")448449450 def test_plot_region_advanced(self):451 """Test case for plot_region_advanced452453 Plots the region, with advanced parameters # noqa: E501454 """455 r1 = Region()456 r1.region_string = 'CIRCLE J2000 10 10 100'457 self.api.create_region("test", RegionRequest(r1))458 preq = PlotRequest()459 preq.plot = Plot()460 self.api.plot_region_advanced("test", preq, "image/png", _preload_content=False)461462 def test_subtract_regions(self):463 """Test case for subtract_regions464465 Compute the difference of regions. # noqa: E501466 """467 r1 = Region()468 r1.region_string = 'CIRCLE J2000 10 10 100'469 self.api.create_region("test1", RegionRequest(r1))470 r2 = Region()471 r2.region_string = 'CIRCLE J2000 10.01 10.01 100'472 self.api.create_region("test2", RegionRequest(r2))473 474 req = RegionRequest()475 req.selection = ["test1", "test2"]476 req.keep_original = True477 self.api.subtract_regions("testsubtract",req)478479 r1 = self.api.get_region("test1")480 r2 = self.api.get_region("test2")481 r3 = self.api.get_region("testsubtract")482483 self.assertLessEqual(r3.region.area, r1.region.area)484 self.assertLessEqual(r3.region.area, r2.region.area)485486487 def test_union_regions(self):488 """Test case for union_regions489490 Compute the union of regions. # noqa: E501491 """492 r1 = Region()493 r1.region_string = 'CIRCLE J2000 10 10 100'494 self.api.create_region("test1", RegionRequest(r1))495 r2 = Region()496 r2.region_string = 'CIRCLE J2000 20 20 100'497 self.api.create_region("test2", RegionRequest(r2))498 499 req = RegionRequest()500 req.selection = ["test1", "test2"]501 req.keep_original = True502 self.api.union_regions("testunion", req)503 504 r1 = self.api.get_region("test1")505 r2 = self.api.get_region("test2")506 r3 = self.api.get_region("testunion")507508 self.assertGreaterEqual(r3.region.area, r1.region.area)509 self.assertGreaterEqual(r3.region.area, r2.region.area)510511512 def test_upload_region(self):513 """Test case for upload_region514515 Upload a region binary or other representation # noqa: E501516 """517 self.api.upload_region("test", "text/plain", "CIRCLE J2000 10 10 10")518 r = self.api.get_region("test")519 self.assertEqual(0.08726640106450838, r.region.area)520521 def test_new_galeq(self):522 r1 = Region()523 r1.region_string = 'POLY J2000 0 0 0 10 20 0'524 self.api.create_region("eqtest", RegionRequest(r1))525526 r2 = Region()527 r2.region_string = 'POLY J2000 0 0 0 10 20 0'528 self.api.create_region("eqtest2", RegionRequest(r2))529530 req = RegionRequest(r1)531 req.sys = CoordinateSystem.GALJ2000532 self.api.modify_region("eqtest",req)533534 reqf = FootprintRequest()535 reqf.footprint = Footprint()536 reqf.footprint.combination_method = CombinationMethod.UNION537 self.api.modify_footprint(reqf)538539# self.api.plot_footprint("image/png", _preload_content=False)540541 preq = PlotRequest()542 preq.plot = Plot()543# self.api.plot_region("eqtest", "image/png", projection = "GalJ2000", auto_zoom = False, color_theme = "blue", _preload_content=False)544 self.api.plot_region("eqtest", "image/png", sys = "GALJ2000", auto_zoom = False, color_theme = "blue", _preload_content=False)545546 def test_new_galeq2(self):547 r1 = Region()548 r1.region_string = 'CONVEX 0.9698463103929541 0.17101007166283433 0.17364817766693033 0.9995769500822006'549 req = RegionRequest(r1)550 req.sys = CoordinateSystem.GALJ2000551 self.api.create_region("eqtest1", req)552553 r2 = Region()554 r2.region_string = 'CIRCLE J2000 10 10 100'555 self.api.create_region("eqtest2", RegionRequest(r2))556557 reqf = FootprintRequest()558 reqf.footprint = Footprint()559 reqf.footprint.combination_method = CombinationMethod.UNION560 self.api.modify_footprint(reqf)561562 self.api.plot_footprint("image/png", _preload_content=False)563 self.api.download_region("eqtest1", accept="text/plain", _preload_content=False)564 self.api.get_region("eqtest1",_preload_content=False)565566 def test_new_rotation(self):567 r1 = Region()568 r1.region_string = 'POLY J2000 0 0 0 10 20 0'569 req = RegionRequest(r1)570 alp = Rotation()571 alp.alpha = 20572 alp.beta = 0573 alp.gamma = 0574 req.rotation = alp575 self.api.create_region("eqtest", req)576 self.api.plot_region("eqtest", "image/png", _preload_content=False)577578 def test_modify_rot(self):579 r1 = Region()580 r1.region_string = 'POLY J2000 0 0 0 10 20 0'581 req = RegionRequest(r1)582 alp = Rotation()583 alp.alpha = 20584 alp.beta = 0585 alp.gamma = 0586 req.rotation = alp587 self.api.create_region("modrottest", RegionRequest(r1))588 self.api.create_region("modrottestinit", RegionRequest(r1))589 self.api.modify_region("modrottest", req)590 self.api.plot_region("modrottest", "image/png", _preload_content=False)591 self.api.plot_region("modrottestinit", "image/png", _preload_content=False)592593 def test_modify_rot2(self):594 r1 = Region()595 r1.region_string = 'POLY J2000 0 0 0 10 20 0'596 req = RegionRequest(r1)597 alp = Rotation()598 alp.alpha = 20599 alp.beta = 0600 alp.gamma = 0601 req.rotation = alp602 self.api.create_region("test1", req)603 self.api.get_region("test1",_preload_content=False)604 respget1 = self.ssclient.last_response.data605 self.api.download_region("test1", accept="text/plain", _preload_content=False)606 respdow1 = self.ssclient.last_response.data607608 self.api.delete_region("test1")609610 r2 = Region()611 r2.region_string = 'POLY J2000 0 0 0 10 20 0'612 req = RegionRequest(r2)613 alp = Rotation()614 alp.alpha = 20615 alp.beta = 0616 alp.gamma = 0617 req.rotation = alp618 self.api.create_region("test1", RegionRequest(r2))619 self.api.modify_region("test1", req)620 self.api.get_region("test1",_preload_content=False)621 respget2 = self.ssclient.last_response.data622 self.api.download_region("test1", accept="text/plain", _preload_content=False)623 respdow2 = self.ssclient.last_response.data624625 self.assertEqual(respget1,respget2)626 self.assertEqual(respdow1,respdow2)627628 def test_new_astropy_two_image(self):629 filename1 = "C:/Users/tomshark/Downloads/hspireplw1342246580_20pmp_1463459088096.fits"630 filename2 = "C:/Users/tomshark/Downloads/hspireplw1342237553_20pmp_1463454955470.fits"631 w1 = WCS(filename1)632 w2 = WCS(filename2)633 image1 = fits.open(filename1)634 image2 = fits.open(filename2)635636 #store header637 header1 = image1[1].header638 header2 = image2[1].header639 n1 = header1["NAXIS1"]640 m1 = header1["NAXIS2"]641642 lon1, lat1 = w1.all_pix2world(0, 0, 0)643 lon2, lat2 = w1.all_pix2world(n1, 0, 0)644 lon3, lat3 = w1.all_pix2world(n1, m1, 0)645 lon4, lat4 = w1.all_pix2world(0, m1, 0)646 r1 = Region()647 r1.region_string = 'POLY J2000 ' + str(lon1) + ' ' + str(lat1) + ' ' + str(lon2) + ' ' + str(lat2) + ' ' + str(lon3) + ' ' + str(lat3) + ' ' + str(lon4) + ' ' + str(lat4) 648 #r1.region_string = 'POLY J2000 ' + str(lon1, lat1) + ' ' + str(lon2, lat2) + ' ' + str(lon3, lat3) + ' ' + str(lon4, lat4) 649650 header2 = image2[1].header651 n1 = header2["NAXIS1"]652 m1 = header2["NAXIS2"]653 lon1, lat1 = w2.all_pix2world(0, 0, 0)654 lon2, lat2 = w2.all_pix2world(n1, 0, 0)655 lon3, lat3 = w2.all_pix2world(n1, m1, 0)656 lon4, lat4 = w2.all_pix2world(0, m1, 0)657 r2 = Region()658 r2.region_string = 'POLY J2000 ' + str(lon1) + ' ' + str(lat1) + ' ' + str(lon2) + ' ' + str(lat2) + ' ' + str(lon3) + ' ' + str(lat3) + ' ' + str(lon4) + ' ' + str(lat4) 659660 self.api.create_region("test1", RegionRequest(r1))661 self.api.create_region("test2", RegionRequest(r2))662663 res = self.api.plot_region("test1", accept="image/png", _preload_content=False)664 req = FootprintRequest()665 req.footprint = Footprint()666 req.footprint.combination_method = CombinationMethod.UNION667 self.api.modify_footprint(req)668669 self.api.plot_footprint("image/png", _preload_content=False)670671 rreq = RegionRequest()672 rreq.selection = ["test1", "test2"]673 rreq.keep_original = True674 self.api.union_regions("testunion", rreq)675 676 r1 = self.api.get_region("test1")677 r2 = self.api.get_region("test2")678 r3 = self.api.get_region("testunion")679680 self.assertGreaterEqual(r3.region.area, r1.region.area)681 self.assertGreaterEqual(r3.region.area, r2.region.area)682683 def test_new_two_image(self):684 #read fits685 filename1 = "C:/Users/tomshark/Downloads/hspireplw1342246580_20pmp_1463459088096.fits"686 filename2 = "C:/Users/tomshark/Downloads/hspireplw1342237553_20pmp_1463454955470.fits"687 688 image1 = fits.open(filename1)689 image2 = fits.open(filename2)690691 #store header692 header1 = image1[1].header693 #read different parameters from header694 n1 = header1["NAXIS1"]695 m1 = header1["NAXIS2"]696 centerx1 = header1["CRPIX1"]697 centery1 = header1["CRPIX2"]698 center_ra1 = header1["CRVAL1"]699 center_dec1 = header1["CRVAL2"]700 pix_to_degree1x = header1["CDELT2"]701 pix_to_degree1y = header1["CDELT2"]702 rot1 = header1["CROTA2"]703704 if centerx1 - round(centerx1) == 0:705 buttomleftcrx = center_ra1 - (centerx1) * pix_to_degree1x706 buttomleftcry = center_dec1 - (centery1) * pix_to_degree1y707 else:708 buttomleftcrx = center_ra1 - (centerx1 - 0.5) * pix_to_degree1x709 buttomleftcry = center_dec1 - (centery1 - 0.5) * pix_to_degree1y710711 a1 = pix_to_degree1x * n1 + buttomleftcrx712 b1 = pix_to_degree1y * m1 + buttomleftcry713714 r1 = Region()715 r1.region_string = 'POLY J2000 ' + str(buttomleftcrx) + ' ' +str(buttomleftcry) + ' ' +str(buttomleftcrx+a1) + ' ' + str(buttomleftcry) + ' ' + str(buttomleftcrx+a1) + ' ' + str(buttomleftcry+b1) + ' ' + str(buttomleftcrx) + ' ' + str(buttomleftcry+b1)716 #r1.region_string = 'POLY J2000 0 0 10 10 0 10'717 #r1.region_string = 'RECT J2000 5 0 10 10'718 self.api.create_region("test1", RegionRequest(r1))719720 #store header721 header2 = image2[1].header722 #read different parameters from header723 n2 = header2["NAXIS1"]724 m2 = header2["NAXIS2"]725 centerx2 = header2["CRPIX1"]726 centery2 = header2["CRPIX2"]727 center_ra2 = header2["CRVAL1"]728 center_dec2 = header2["CRVAL2"]729 pix_to_degree2x = header2["CDELT2"]730 pix_to_degree2y = header2["CDELT2"]731 rot2 = header2["CROTA2"]732733 if centerx2 - round(centerx2) == 0:734 buttomleftcrx = center_ra2 - (centerx2) * pix_to_degree2x735 buttomleftcry = center_dec2 - (centery2) * pix_to_degree2y736 else:737 buttomleftcrx = center_ra2 - (centerx1 - 0.5) * pix_to_degree2x738 buttomleftcry = center_dec2 - (centery1 - 0.5) * pix_to_degree2y739740 a2 = pix_to_degree2x * n2 + buttomleftcrx741 b2 = pix_to_degree2y * m2 + buttomleftcry742743 r2 = Region()744 r2.region_string = 'POLY J2000 ' + str(buttomleftcrx) + ' ' +str(buttomleftcry) + ' ' +str(buttomleftcrx+a2) + ' ' + str(buttomleftcry) + ' ' + str(buttomleftcrx+a2) + ' ' + str(buttomleftcry+b2) + ' ' + str(buttomleftcrx) + ' ' + str(buttomleftcry+b2)745746 self.api.create_region("test2", RegionRequest(r2))747 748 #res = self.api.plot_region("test", accept="image/png", _preload_content=False)749 750 req = FootprintRequest()751 req.footprint = Footprint()752 req.footprint.combination_method = CombinationMethod.UNION753 self.api.modify_footprint(req)754755 self.api.plot_footprint("image/png", _preload_content=False)756757if __name__ == '__main__':
...
test_template.py
Source:test_template.py
1from nose.tools import * 2import template3import numpy as np4from matplotlib import pylab5def create_region(x, y):6 a = np.arange(x*y)7 a.shape = (y, x)8 return a9 10def test_overlap():11 ae = assert_equal12 # template / tgt same size13 ae(template.overlap(5, 5, 0), (0, 5))14 ae(template.overlap(5, 5, 1), (1, 5))15 ae(template.overlap(5, 5, 4), (4, 5))16 ae(template.overlap(5, 5, 5), (0, 0))17 ae(template.overlap(5, 5, -3), (0, 2))18 # check for smaller template19 ae(template.overlap(10, 5, 0), (0, 5))20 ae(template.overlap(10, 5, 1), (1, 6))21 ae(template.overlap(10, 5, 5), (5, 10))22 ae(template.overlap(10, 5, 10), (0, 0))23 24 # check for larger template25 ae(template.overlap(5, 10, 0), (0, 5))26 ae(template.overlap(5, 10, 1), (1, 5))27 ae(template.overlap(5, 10, 5), (0, 0))28 ae(template.overlap(5, 10, -5), (0, 5))29 30def test_template_select():31 # simple initial checks32 ae = assert_equal33 r1 = create_region(10, 5)34 t1 = create_region(3, 3)35 r1_a, t1_a = template.template_select(r1, t1, 0, 0)36 ae(r1_a.shape, (3, 3))37 ae(t1_a.shape, (3, 3))38 ae(r1_a[0, 0], 0)39 ae(r1_a[2, 2], 22)40 ae(t1_a[0, 0], 0)41 ae(t1_a[2, 2], 8)42 # simple offset43 r1 = create_region(10, 5)44 t1 = create_region(3, 3)45 r1_a, t1_a = template.template_select(r1, t1, 1, 2)46 ae(r1_a.shape, (3, 3))47 ae(t1_a.shape, (3, 3))48 ae(r1_a[0, 0], 21)49 ae(r1_a[2, 2], 43)50 ae(t1_a[0, 0], 0)51 ae(t1_a[2, 2], 8)52 # lower-right corner, almost53 r1 = create_region(10, 5)54 t1 = create_region(3, 3)55 r1_a, t1_a = template.template_select(r1, t1, 9, 3)56 ae(r1_a.shape, (2, 1))57 ae(t1_a.shape, (2, 1))58 ae(r1_a[0, 0], 39)59 ae(r1_a[1, 0], 49)60 ae(t1_a[0, 0], 0)61 ae(t1_a[1, 0], 3)62 # negative x-y spots63 r1 = create_region(10, 5)64 t1 = create_region(3, 4)65 r1_a, t1_a = template.template_select(r1, t1, -2, -1)66 ae(r1_a.shape, (3, 1))67 ae(t1_a.shape, (3, 1))68 ae(r1_a[0, 0], 0)69 ae(r1_a[2, 0], 20)70 ae(t1_a[0, 0], 5)71 ae(t1_a[2, 0], 11)72 # crazy values73 r1 = create_region(320, 240)74 t1 = create_region(34, 34)75 r1_a, t1_a = template.template_select(r1, t1, -17., -17.)76def test_template_render():77 tr = template.TemplateRenderGaussian()78 tr.set_params(14, 7, 4)79 i1 = tr.render(np.pi/2, np.pi/2)80 print type(i1), i1.shape81 82 pylab.subplot(1, 2, 1)83 pylab.imshow(i1, interpolation='nearest')84 pylab.colorbar()85 pylab.subplot(1, 2, 2)86 pylab.imshow(i1.mask.astype(float), interpolation='nearest')87 pylab.colorbar()88 #pylab.show()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!