def test_get_activity_from_protocl(self): """Verify the activity is extracted from the protocol name.""" protocol = self.parser.activities.keys()[0] activity = self.parser.activities[protocol][0] self.content = self.content.replace('Traveling', protocol) self.response = response_for_content(self.content, 'utf-8', url=self.url) self.parser = HTMLParser(self.response) self.assertEqual(activity, self.parser.get_activity())
def setUp(self): """Initialize the test.""" data = { 'location': { 'name': 'Location A', } } self.response = response_for_content(u""" <table cellspacing="0" class="PopupTable"> <tr> <td colspan="2"><label>Location name</label></td> <td>Location A</td> </tr> <tr> <td colspan="2"><label>Region</label></td> <td>Country</td> </tr> <tr> <td colspan="2"><label>Central co-ordinates</label></td> <td>45.0000, -45.0000</td> </tr> <tr> <td colspan="2"><label>Area</label></td> <td>0ha</td></tr> <tr> <td colspan="2"><label>Altitude</label></td> <td>0m - 0m</td> </tr> <tr> <td colspan="2"><label>Notes</label></td> <td></td> </tr> <tr> <td colspan="2"><br><a target="_parent" href="locationreport.php?id=1&so=3">Run Location Report</a></td> </tr> <tr> <td width="5%"><br> <a onclick="doGoogleLocation(1)" href="#"> <img src="images/theme_blue/map.gif"> </a> </td> <td><br><a onclick="doGoogleLocation(1)" href="#">Google</a></td> <td> </td> </tr> </table> """, 'utf-8', metadata={ 'checklist': data, 'identifiers': (1, 2, 3), 'country': 'pt' }) self.parser = LocationParser(self.response) self.checklist = self.parser.get_checklist() self.location = self.checklist['location']
def setUp(self): """Initialize the test.""" data = { 'location': { 'name': 'Location A', } } self.response = response_for_content(u""" <table cellspacing="0" class="PopupTable"> <tr> <td colspan="2"><label>Location name</label></td> <td>Location A</td> </tr> <tr> <td colspan="2"><label>Region</label></td> <td>Country</td> </tr> <tr> <td colspan="2"><label>Central co-ordinates</label></td> <td>45.0000, -45.0000</td> </tr> <tr> <td colspan="2"><label>Area</label></td> <td>0ha</td></tr> <tr> <td colspan="2"><label>Altitude</label></td> <td>0m - 0m</td> </tr> <tr> <td colspan="2"><label>Notes</label></td> <td></td> </tr> <tr> <td colspan="2"><br><a target="_parent" href="locationreport.php?id=1&so=3">Run Location Report</a></td> </tr> <tr> <td width="5%"><br> <a onclick="doGoogleLocation(1)" href="#"> <img src="images/theme_blue/map.gif"> </a> </td> <td><br><a onclick="doGoogleLocation(1)" href="#">Google</a></td> <td> </td> </tr> </table> """, 'utf-8', metadata={'checklist': data, 'identifiers': (1, 2, 3), 'country': 'pt'}) self.parser = LocationParser(self.response) self.checklist = self.parser.get_checklist() self.location = self.checklist['location']
def setUp(self): """Initialize the test.""" self.response = response_for_content(""" <table width="100%" border="0" cellspacing="0" class="StandardTable"> <th align="left"> </th> <th align="left">Location</th> <th align="left">Region</th> <th align="left">Date</th> <th align="left">Observer</th> <th align="center">Info</th> <tr id="HighlightRow"> <td>1.</td> <td align="left"> <a onclick="doLocation(1);" href="javascript:void(0);">Location A</a> </td> <td align="left">Region</td> <td align="left">23/05/2013</td> <td align="left"> <a onclick="doObserver(2);" href="javascript:void(0);">username_a</a> </td> <td align="center"> <a onclick="doHighlights(1, 3, 0, 0);" href="javascript:void(0);"> <img src="images/theme_blue/more.gif"> </a> </td> </tr> <tr> <td>2.</td> <td align="left"> <a onclick="doLocation(5);" href="javascript:void(0);">Location B</a> </td> <td align="left">Region</td> <td align="left">22/05/2013</td> <td align="left"> <a onclick="doObserver(6);" href="javascript:void(0);">username_b</a> </td> <td align="center"> <a onclick="doHighlights(1, 4, 0, 0);" href="javascript:void(0);"> <img src="images/theme_blue/more.gif"> </a> </td> </tr> </table> """, 'utf-8') self.parser = VisitParser(self.response)
def setUp(self): """Initialize the test.""" self.response = response_for_content(u""" <table class="PopupTable" cellspacing="0"> <tr> <td><label>User name</label></td> <td>username</td> </tr> <tr> <td><label>Full name</label></td> <td>Full Name</td> </tr> <tr> <td><label>Email</label></td> <td> <a href="mailto:[email protected]">[email protected]</a> </td> </tr> </table> """, 'utf-8', metadata={'checklist': {}}) self.parser = ObserverParser(self.response) self.checklist = self.parser.get_checklist()
def setUp(self): """Initialize the test.""" self.response = response_for_content(""" <div id="popupwrapper" style="width: 600px; height: 370px; top: 160px; left: 533.5px;"> <div id="popupheader" style="width: 600px;"> <a href="javascript:doShowInfo(false,%200,%200,%200);"> <div id="ico_close"></div> </a> </div> <div id="popupscroll" style="width: 600px; height: 350px;"> <div id="popupbody" style="width: 560px;"><p></p> <div id="popupcontent"><br> <table cellspacing="0" class="PopupTable"> <tr> <td width="60%"><label>Location</label></td> <td width="40%">Location A</td></tr> <tr> <td><label>Region</label></td> <td>Region A</td> </tr> <tr> <td><label>Start date</label></td> <td>23-05-2013</td> </tr> <tr> <td><label>Time</label></td> <td>11:00 - 12:05</td> </tr> <tr> <td><label>Time spent birding</label></td> <td>1 Hrs 5 Mins</td> </tr> <tr> <td><label>Observers</label></td> <td>1</td> </tr> <tr> <td><label>Were all birds seen recorded?</label></td> <td><img src="images/theme_blue/tick.gif"></td> </tr> <tr> <td><label>Were no birds seen?</label></td> <td><img src="images/theme_blue/cross.gif"></td> </tr> <tr> <td><label>Did weather, visibility, disturbance etc affect your counts?</label></td> <td><img src="images/theme_blue/cross.gif"></td> </tr> <tr> <td><label>Purpose</label></td> <td>Birdwatching, with no specific purpose</td><td></td> </tr> <tr valign="top"> <td><label>Other notes for the visit</label></td> <td></td> <td></td> </tr> <tr valign="top"> <td><label>Observers</label></td> <td>Observer A, Observer B</td><td></td> </tr> <tr> <td><label>Total species observed during visit</label></td> <td>3 <a ;="" onclick="doHighlights(1, 00001, 0, 0)" href="javascript:void(0);">Hide list</a></td> </tr> </table> <br><br> <b>Confidential entries are hidden from the list displayed below.</b><br><br> <table cellspacing="0" class="TableThin"> <tr> <th width="30%" align="left">Species</th> <th width="10%">Count</th> <th width="20%">Activity</th> <th width="35%" align="left">Notes</th> <th width="5%">Status</th> </tr> <tr> <td>Species A</td> <td align="center">10</td> <td>activity</td> <td>notes</td> <td>status</td> </tr> <tr> <td>Species B</td> <td align="center">2</td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Species C</td> <td align="center"><img src="images/theme_blue/tick.gif"></td> <td> </td> <td> </td> <td> </td> </tr> </table><br> </div><p></p> </div> </div> </div> """, 'utf-8', metadata={ 'identifiers': (1, 2, 3), 'country': 'pt' }) self.parser = ChecklistParser(self.response)
def setUp(self): """Initialize the test.""" self.url = "http://ebird.org/ebird/view/checklist?subID=S0000001" self.content = """ <tr class="spp-entry"> <th><h5 class="se-count">23</h5></th> <td> <div class="se-hd"> <div class="inner bd"> <h5 class="se-name">Mallard</h5> <div class="rs-action"> </div> </div> </div><!-- .se-hd --> <div class="se-detail"> <div class="sd-head"> <h6>Age & Sex</h6> </div> <div class="sd-data-age-sex"> <table> <tbody> <tr> <th></th> <th>Juvenile</th> <th>Immature</th> <th>Adult</th> <th>Age Unknown</th> </tr> <tr> <td>Male</td> <td class="num"></td> <td class="num"></td> <td class="num">9</td> <td class="num"></td> </tr> <tr> <td>Female</td> <td class="num"></td> <td class="num"></td> <td class="num">6</td> <td class="num"></td> </tr> <tr> <td>Sex Unknown</td> <td class="num">8</td> <td class="num"></td> <td class="num"></td> <td class="num"></td> </tr> </tbody> </table> </div> </div> <div class="se-detail"> <div class="sd-head"> <h6>Breeding Code</h6> </div> <div class="sd-data"> FL Confirmed--Recently Fledged Young </div> </div> </td> </tr> """ self.content = response_for_content(self.content, 'utf-8', url=self.url) self.parser = HTMLParser(self.content)
def setUp(self): """Initialize the test.""" self.url = "http://ebird.org/ebird/view/checklist?subID=S0000001" self.content = """ <div class="report-section"> <div class="rs-body-spp"> <div class="mod"> <div class="inner"> <div class="bd"> <div class="rs-action"> </div> <h5 class="rep-obs-date"> <!-- date --> Sun Mar 24, 2013 3:10 PM </h5> <dl class="def-list"> <dt>Protocol:</dt> <dd>Traveling</dd> </dl> <dl class="def-list"> <dt>Party Size:</dt> <dd>1</dd> </dl> <dl class="def-list"> <dt>Duration:</dt> <dd>2 hour(s) 35 minute(s)</dd> </dl> <dl class="def-list"> <dt>Distance:</dt> <dd>2.0 kilometer(s)</dd> </dl> <dl class="def-list"> <dt>Observers:</dt> <dd> Observer One <a href="checklist?subID=S1" class="btn-minor">List</a> , Observer Two <a href="checklist?subID=S2" class="btn-minor">List</a> , <strong>Observer Three</strong> , Observer Four <a href="checklist?subID=S4" class="btn-minor">List</a> , Observer Five <a href="checklist?subID=S5" class="btn-minor">List</a> </dd> </dl> <dl class="def-list"> <dt>Comments:</dt> <dd> A comment. </dd> </dl> </div> </div> </div> </div> </div> """ self.response = response_for_content(self.content, 'utf-8', url=self.url) self.parser = HTMLParser(self.response)
def setUp(self): """Initialize the test.""" self.response = response_for_content(""" <div id="popupwrapper" style="width: 600px; height: 370px; top: 160px; left: 533.5px;"> <div id="popupheader" style="width: 600px;"> <a href="javascript:doShowInfo(false,%200,%200,%200);"> <div id="ico_close"></div> </a> </div> <div id="popupscroll" style="width: 600px; height: 350px;"> <div id="popupbody" style="width: 560px;"><p></p> <div id="popupcontent"><br> <table cellspacing="0" class="PopupTable"> <tr> <td width="60%"><label>Location</label></td> <td width="40%">Location A</td></tr> <tr> <td><label>Region</label></td> <td>Region A</td> </tr> <tr> <td><label>Start date</label></td> <td>23-05-2013</td> </tr> <tr> <td><label>Time</label></td> <td>11:00 - 12:05</td> </tr> <tr> <td><label>Time spent birding</label></td> <td>1 Hrs 5 Mins</td> </tr> <tr> <td><label>Observers</label></td> <td>1</td> </tr> <tr> <td><label>Were all birds seen recorded?</label></td> <td><img src="images/theme_blue/tick.gif"></td> </tr> <tr> <td><label>Were no birds seen?</label></td> <td><img src="images/theme_blue/cross.gif"></td> </tr> <tr> <td><label>Did weather, visibility, disturbance etc affect your counts?</label></td> <td><img src="images/theme_blue/cross.gif"></td> </tr> <tr> <td><label>Purpose</label></td> <td>Birdwatching, with no specific purpose</td><td></td> </tr> <tr valign="top"> <td><label>Other notes for the visit</label></td> <td></td> <td></td> </tr> <tr valign="top"> <td><label>Observers</label></td> <td>Observer A, Observer B</td><td></td> </tr> <tr> <td><label>Total species observed during visit</label></td> <td>3 <a ;="" onclick="doHighlights(1, 00001, 0, 0)" href="javascript:void(0);">Hide list</a></td> </tr> </table> <br><br> <b>Confidential entries are hidden from the list displayed below.</b><br><br> <table cellspacing="0" class="TableThin"> <tr> <th width="30%" align="left">Species</th> <th width="10%">Count</th> <th width="20%">Activity</th> <th width="35%" align="left">Notes</th> <th width="5%">Status</th> </tr> <tr> <td>Species A</td> <td align="center">10</td> <td>activity</td> <td>notes</td> <td>status</td> </tr> <tr> <td>Species B</td> <td align="center">2</td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Species C</td> <td align="center"><img src="images/theme_blue/tick.gif"></td> <td> </td> <td> </td> <td> </td> </tr> </table><br> </div><p></p> </div> </div> </div> """, 'utf-8', metadata={'identifiers': (1, 2, 3), 'country': 'pt'}) self.parser = ChecklistParser(self.response)