def test_ranking_page(self): MockDateTime.change_datetime(2015, 7, 1, 17, 0, 0) self.insert_extra_test_body() self.insert_one_more_extra_test_body() self.insert_another_extra_test_body() # Sarah goes to the ranking page and expects to see the ranked list of NEOs with the FOM. ranking_page_url = self.live_server_url + '/ranking/' self.browser.get(ranking_page_url) self.assertNotIn('Home | LCO NEOx', self.browser.title) self.assertIn('Ranking Page | LCO NEOx', self.browser.title) self.check_for_header_in_table( 'id_ranked_targets', 'Rank FOM Target Name NEOCP Score Discovery Date R.A. Dec. South Polar Distance V Mag. Updated? Num. Obs. Arc H Mag. Not Seen (days) Observed? Reported?' ) # Position below computed for 2015-07-01 17:00:00 testlines = [ u'1 1.8e+76 V38821zi 100 May 10, 2015, noon 23 43 14.40 +19 59 08.2 110.0 20.7 2 0.07 21.0 12.29 Not yet Not yet', u'2 2.5e-01 N999r0q 90 May 10, 2015, noon 23 43 14.40 +19 59 08.2 110.0 20.7 17 3.12 21.0 0.42 1/2 1/2', u'3 1.5e-01 q382918r 85 May 10, 2015, noon 23 43 14.40 +19 59 08.2 110.0 20.7 35 42.00 21.0 2.22 Not yet Not yet', '4 bloop 100 May 10, 2015, noon 23 43 14.40 +19 59 08.2 110.0 20.7 2 0.07 21.0 None Not yet Not yet' ] self.check_for_row_in_table('id_ranked_targets', testlines[0]) self.check_for_row_in_table('id_ranked_targets', testlines[1]) self.check_for_row_in_table('id_ranked_targets', testlines[2]) self.check_for_row_in_table('id_ranked_targets', testlines[3]) # Because we can't find the Updated icon with a simple text search # we look for the data-label for 'Updated?' updated_statuses = ['No', 'Yes', 'No', 'No'] data_label = 'Updated?' self.check_icon_status_elements('id_ranked_targets', data_label, updated_statuses)
def test_results_for_no_H(self): MockDateTime.change_datetime(2015, 3, 19, 6, 00, 00) self.body.abs_mag = None self.body.save() # A new user comes along to the site self.browser.get(self.live_server_url) # She sees a link from the targets' name on the front page to a more # detailed view. link = self.browser.find_element_by_link_text('N999r0q') body_url = self.live_server_url + reverse('target', kwargs={'pk': 1}) self.assertIn(link.get_attribute('href'), body_url) # She clicks the link and is taken to a page with the targets' details. with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), body_url) # the target has no Absolute Magnitude testlines = [ u'ABSOLUTE MAGNITUDE (H) ' + 'None', ] for line in testlines: self.check_for_row_in_table('id_orbelements', line)
def test_can_view_previous_spectra(self): MockDateTime.change_datetime(2015, 3, 19, 6, 00, 00) # A new user comes along to the site self.browser.get(self.live_server_url) # She sees a link from the targets' name on the front page to a more # detailed view. link = self.browser.find_element_by_link_text('66146') # She clicks the link and is taken to a page with the targets' details. with self.wait_for_page_load(timeout=10): link.click() # She clicks a link to view external spectra for this target link = self.browser.find_element_by_link_text('(Plots)') with self.wait_for_page_load(timeout=10): link.click() spec_plot = self.browser.find_element_by_xpath( "/html/body[@class='page']/div[@id='page-wrapper']/div[@id='page']/div[@id='main']/div[@name='spec_plot']/div[@class='bk']/div[@class='bk'][1]/div[@class='bk']/div[@class='bk']/div[@class='bk bk-canvas-events']" ) try: target_list = self.browser.find_element_by_xpath( "/html/body[@class='page']/div[@id='page-wrapper']/div[@id='page']/div[@id='main']/div[@name='spec_plot']/div[@class='bk']/div[@class='bk'][1]/div[@class='bk'][1]/div[@class='bk bk-input-group']/select[@class='bk bk-input']" ) analog_list = self.browser.find_element_by_xpath( "/html/body[@class='page']/div[@id='page-wrapper']/div[@id='page']/div[@id='main']/div[@name='spec_plot']/div[@class='bk']/div[@class='bk'][1]/div[@class='bk'][2]/div[@class='bk bk-input-group']/select[@class='bk bk-input']" ) raise Exception( "Target list, or Analog list is present when it shouldn't be.") except NoSuchElementException: pass
def test_bad_date(self): MockDateTime.change_datetime(2016, 3, 1, 22, 0, 0) date_string = '(Feb. 30.00 UT)' expected_dt = datetime(2016, 3, 1, 00, 00, 00) dt = parse_neocp_date(date_string) self.assertEqual(expected_dt, dt)
def test_add_lookproject_target(self): MockDateTime.change_datetime(2020, 11, 14, 17, 0, 0) self.insert_extra_test_bodies() # self.insert_another_extra_test_body() # self.insert_another_other_extra_test_body() # Michaela goes to the the LOOK Project page as she has heard about a new outburst lookproject_page_url = self.live_server_url + '/lookproject/' self.browser.get(lookproject_page_url) self.assertNotIn('Home | LCO NEOx', self.browser.title) self.assertIn('LOOK Project Page | LCO NEOx', self.browser.title) # She looks through the list of targets but does not see her desired target table = self.browser.find_element_by_id('active_targets') table_body = table.find_element_by_tag_name('tbody') rows = table_body.find_elements_by_tag_name('tr') self.assertNotIn('191P', [row.text.replace('\n', ' ') for row in rows]) # She logs in and sees that a new field and 'Add LOOK target' button has appeared self.browser.get('%s%s' % (self.live_server_url, '/accounts/login/')) username_input = self.browser.find_element_by_id("username") username_input.send_keys(self.lisa_username) password_input = self.browser.find_element_by_id("password") password_input.send_keys(self.lisa_password) with self.wait_for_page_load(timeout=10): self.browser.find_element_by_id('login-btn').click() # Wait until response is received self.wait_for_element_with_id('page') # Back to LOOK Project page self.browser.get(lookproject_page_url) self.wait_for_element_with_id('page') newtarget_input = self.browser.find_element_by_id('id_target_name') newtarget_button = self.browser.find_element_by_id( 'add_new_target-btn') # She fills in the field with the new object name and clicks it newtarget_input.send_keys("191P") newtarget_button.click() # The page refreshes and the new target appears as an active target testlines = [ u'191P Comet Jupiter Family 21 24 28.42 -23 49 36.4 18.6 0.78 2.4 Nothing scheduled [-----]', ] self.check_for_row_in_table('active_targets', testlines[0]) # She retries adding the same object newtarget_input = self.browser.find_element_by_id('id_target_name') newtarget_button = self.browser.find_element_by_id( 'add_new_target-btn') newtarget_input.send_keys("191P") newtarget_button.click() # The message box says that the target is already in the system msg_box = self.browser.find_element_by_id('show-messages') self.assertIn('191P is already in the system', msg_box.text)
def test_extra_spaces3(self): MockDateTime.change_datetime(2016, 4, 8, 0, 30, 0) date_string = u'(Mar. 19.97 UT)' expected_dt = datetime(2016, 3, 19, 23, 16, 48) dt = parse_neocp_date(date_string) self.assertEqual(expected_dt, dt)
def test_can_view_spectral_details(self): MockDateTime.change_datetime(2015, 3, 19, 6, 00, 00) # A new user comes along to the site self.browser.get(self.live_server_url) # She sees a link from the targets' name on the front page to a more # detailed view. self.body.origin = 'N' # This target is from NASA self.body.source_type = 'N' self.body.save() link = self.browser.find_element_by_link_text('N999r0q') body_url = self.live_server_url + reverse('target', kwargs={'pk': 1}) self.assertIn(link.get_attribute('href'), body_url) # She clicks the link and is taken to a page with the targets' details. with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), body_url) # She notices the page title has the name of the site and the header # mentions the current target self.assertIn(self.body.current_name() + ' details | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn(self.body.full_name(), header_text) title_text = self.browser.find_element_by_class_name('container').text self.assertIn('Characterization Target', title_text) # She notices there is a section describing the object's spectral info testlines = [ 'BUS-DEMEO' + u' TAXONOMIC TYPE ' + str(self.test_taxonomy.taxonomic_class), 'HOWELL' + u' TAXONOMIC TYPE ' + str(self.test_taxonomy2.taxonomic_class), 'THOLEN' + u' TAXONOMIC TYPE ' + str(self.test_taxonomy3.taxonomic_class), 'SMASS SPECTRA Vis+NIR' ] for line in testlines: self.check_for_row_in_table('id_spectralinfo', line) expected_tooltips = self.browser.find_elements_by_class_name( "tooltiptext") expected_tt_text = '' for tip in expected_tooltips: expected_tt_text += tip.get_attribute('innerHTML') tooltips = [ 'March 19, 2015', 'Neese, Asteroid Taxonomy V6.0, (2010).', 'Visible: Xu (1994), Xu et al. (1995). NIR: DeMeo et al. (2009).', '7 color indices were used.', 'Used medium-resolution spectrum by Chapman and Gaffey (1979).' ] for tool in tooltips: self.assertIn(tool, expected_tt_text)
def test_no_supplied_date(self): MockDateTime.change_datetime(2015, 11, 18, 12, 0, 0) dt = None expected_start = datetime(2015, 11, 17, 16, 0, 0) expected_end = datetime(2015, 11, 19, 20, 0, 0) start, end = determine_archive_start_end(dt) self.assertEqual(expected_start, start) self.assertEqual(expected_end, end)
def test_can_compute_ephemeris(self): MockDateTime.change_datetime(2015, 7, 1, 17, 0, 0) # Eduardo has heard about a new website for NEOs. He goes to the # homepage self.browser.get(self.live_server_url) # He notices the page title has the name of the site and the header # mentions current targets self.assertIn('Home | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_id('site-name').text self.assertIn('Minor planet follow-up portal', header_text) # He notices there are several targets that could be followed up self.check_for_header_in_table('id_neo_targets', 'Rank Target Name Type R.A. Dec. Mag. Num.Obs. Arc Not Seen (days) NEOCP Score Updated?') # Position below computed for 2015-07-01 17:00:00 testlines = [u'1 N999r0q Candidate 23 43 14.40 +19 59 08.2 20.7 None None None None', ] self.check_for_row_in_table('id_neo_targets', testlines[0]) # he goes to the page from N999r0q and computes the ephemeris link = self.browser.find_element_by_link_text('N999r0q') with self.wait_for_page_load(timeout=10): link.click() # He decides to use the ephemeris form inputbox = self.get_item_input_box() datebox = self.get_item_input_box_and_clear('id_utc_date') datebox.send_keys('2015-04-21') site_choices = Select(self.get_item_input_box('id_site_code')) self.assertIn('TFN 1.0m - Z31,Z24; (Tenerife, Spain)', [option.text for option in site_choices.options]) site_choices.select_by_visible_text('TFN 1.0m - Z31,Z24; (Tenerife, Spain)') # When he hits Enter, he is taken to a new page and now the page shows an ephemeris # for the target with a column header and a series of rows for the position # as a function of time. with self.wait_for_page_load(timeout=10): self.browser.find_element_by_id("id_submit").click() eduardo_ephem_url = self.browser.current_url self.assertRegexpMatches(eduardo_ephem_url, '/ephemeris/.+') menu = self.browser.find_element_by_id('extramenu').text self.assertIn('Ephemeris for N999r0q at Z24', menu) self.check_for_header_in_table('id_ephemeris_table', 'Date/Time (UTC) RA Dec Mag "/min P.A. Alt Moon Phase Moon Dist. Moon Alt. Score H.A.' ) self.check_for_row_in_table('id_ephemeris_table', '2015 04 21 03:00 20 08 59.51 +29 57 16.0 20.4 2.43 89.0 +34 0.07 105 -45 +049 -04:20' )
def test_can_view_calibsource_spectra(self): settings.MEDIA_ROOT = os.path.abspath('data') self.add_new_calib_sources() MockDateTime.change_datetime(2018, 5, 22, 5, 0, 0) # A new user, Daniel, goes to a hidden calibration page on the site target_url = "{0}{1}".format(self.live_server_url, reverse('calibsource-view')) self.browser.get(target_url) actual_url = self.browser.current_url self.assertEqual(actual_url, target_url) # He notices the page title has the name of the site and the header # mentions calibrations self.assertIn('Calibration Sources | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn('Calibration Sources', header_text) # He decides he would like to schedule a hot spectrophotometric standard test_line = 'HR9087 00:01:49.42 -03:01:39.0 5.12 B7III Spectrophotometric standard' self.check_for_row_in_table('id_calibsources', test_line) # He picks HR9087 as being a suitably hot star link = self.browser.find_element_by_link_text('HR9087') target = StaticSource.objects.get(name='HR9087') target_url = "{0}{1}".format( self.live_server_url, reverse('calibsource', kwargs={'pk': target.pk})) actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to check the detail page to see if the spectrum # is suitable with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(new_url, actual_url) # He sees the detail page for his standard table_text = self.browser.find_element_by_id( 'id_staticsource_detail').text self.assertIn('00:01:49.42', table_text) self.assertIn('-03:01:39.0', table_text) self.assertIn('B7III', table_text) self.assertIn( 'Spectrophotometric standard', self.browser.find_element_by_class_name("section-title").text) spec_plot = self.browser.find_element_by_name("spec_plot") self.assertNotIn("Target Frames", spec_plot.text) self.assertNotIn("Analog", spec_plot.text)
def test_can_view_best_calibsources(self): self.add_new_calib_sources() MockDateTime.change_datetime(2019, 10, 5, 22, 0, 0) # A new user, Curtis, goes to a calibration page on the site target_url = "{0}{1}".format(self.live_server_url, reverse('calibsource-view')) self.browser.get(target_url) actual_url = self.browser.current_url self.assertEqual(actual_url, target_url) # He notices the page title has the name of the site and the header # mentions calibrations self.assertIn('Calibration Sources | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn('Calibration Sources', header_text) anti_solar_element = self.browser.find_element_by_id( "anti_solar_point") anti_solar_point = "Current Anti-Solar Point: RA = 00:45:30.55 / Dec = +04:53:15.7" self.assertEqual(anti_solar_point, anti_solar_element.text) # He decides he would like to find a calibration standard to schedule # which will be up all night. # He sees a Show Best Standards button link = self.browser.find_element_by_id('show-best-standards') target_url = "{0}{1}".format(self.live_server_url, reverse('beststandards-view')) actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) with self.wait_for_page_load(timeout=10): link.click() # He notices the page title has best suggested calibraions and the header # mentions calibrations for the current date self.assertIn('Best Calibration Sources | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_id('night_banner').text self.assertIn('Best Calibration Sources for Oct. 5, 2019', header_text) # He checks there are some suitable targets for FTS test_lines = [ 'HR9087 00:01:49.42 -03:01:39.0 5.12 B7III', 'CD-34d241 00:41:46.92 -33:39:08.5 11.23 F' ] for test_line in test_lines: self.check_for_row_in_table('id_fts_calibsources', test_line)
def test_homepage_rounds_arc_notseen(self): MockDateTime.change_datetime(2017, 2, 1, 17, 0, 0) self.insert_local_test_body() self.insert_extra_test_body() # Matt has heard about a new website that provides a ranked list of NEOs for follow-up. # He goes to the homepage for the website and expects to see this ranked list of NEOs. self.browser.get(self.live_server_url) self.assertIn('Home | LCO NEOx', self.browser.title) self.check_for_header_in_table( 'id_neo_targets', 'Rank Target Name Type R.A. Dec. Mag. Num.Obs. Arc Not Seen (days) NEOCP Score Updated?' ) # Position below computed for 2017-02-01 17:00:00 testlines = [ u'1 LSCTLGm Candidate 09 27 31.01 +03 05 27.6 21.6 16 1.07 0.919 2', ] self.check_for_row_in_table('id_neo_targets', testlines[0]) # Because we can't find the Updated icon with a simple text search # we look for the data-label for 'Updated?' updated_statuses = [ 'Yes', ] data_label = 'Updated?' self.check_icon_status_elements('id_neo_targets', data_label, updated_statuses) # He clicks on the top ranked NEO and is taken to a page that has more information on the object. link = self.browser.find_element_by_link_text('LSCTLGm') body_url = self.live_server_url + reverse('target', kwargs={'pk': self.body3.pk}) self.assertIn(link.get_attribute('href'), body_url) # He clicks the link and is taken to a page with the targets' details. link.click() self.browser.implicitly_wait(3) new_url = self.browser.current_url self.assertEqual(str(new_url), body_url) # He notices the page title has the name of the site and the header # mentions the current target self.assertIn(self.body3.current_name() + ' details | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn(self.body3.full_name(), header_text)
def test_homepage_has_ranking(self): MockDateTime.change_datetime(2015, 7, 1, 17, 0, 0) self.insert_extra_test_body() # Matt has heard about a new website that provides a ranked list of NEOs for follow-up. # He goes to the homepage for the website and expects to see this ranked list of NEOs. self.browser.get(self.live_server_url) self.assertIn('Home | LCO NEOx', self.browser.title) self.check_for_header_in_table( 'id_neo_targets', 'Rank Target Name Type R.A. Dec. Mag. Num.Obs. Arc Not Seen (days) NEOCP Score Updated?' ) # Position below computed for 2015-07-01 17:00:00 testlines = [ u'1 N999r0q Candidate 23 43 14.40 +19 59 08.2 20.7 17 3.12 0.423 90', u'2 1995 YR1 NEO 23 43 14.40 +19 59 08.2 20.7 35 42.00 2.220 None' ] self.check_for_row_in_table('id_neo_targets', testlines[0]) self.check_for_row_in_table('id_neo_targets', testlines[1]) # Because we can't find the Updated icon with a simple text search # we look for the data-label for 'Updated?' updated_statuses = ['Yes', 'No'] data_label = 'Updated?' self.check_icon_status_elements('id_neo_targets', data_label, updated_statuses) # He clicks on the top ranked NEO and is taken to a page that has more information on the object. link = self.browser.find_element_by_link_text('N999r0q') body_url = self.live_server_url + reverse('target', kwargs={'pk': 1}) self.assertIn(link.get_attribute('href'), body_url) # He clicks the link and is taken to a page with the targets' details. link.click() self.browser.implicitly_wait(3) new_url = self.browser.current_url self.assertEqual(str(new_url), body_url) # He notices the page title has the name of the site and the header # mentions the current target self.assertIn(self.body.current_name() + ' details | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn(self.body.full_name(), header_text)
def test_can_view_comet_details(self): MockDateTime.change_datetime(2019, 4, 3, 0, 00, 00) self.insert_test_comet() # A new user comes along to the site who likes comets self.browser.get(self.live_server_url) # She sees a link from the targets' name on the results page to a more # detailed view. link = self.browser.find_element_by_link_text('C/2006 F4') body_url = self.live_server_url + reverse('target', kwargs={'pk': 2}) self.assertIn(link.get_attribute('href'), body_url) # She clicks the link and is taken to a page with the targets' details. with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), body_url) # She notices there is a table which lists a lot more details about # the comet with just the right amount of precision. testlines = [ 'EPOCH OF PERIHELION (MJD) ' + str(round(self.comet.epochofperih_mjd(), 5)), 'PERIHELION DISTANCE (AU) ' + str(round(self.comet.perihdist, 7)), 'TOTAL MAGNITUDE (M1) ' + str(self.comet.abs_mag), 'SLOPE PARAMETER (K1) ' + str(self.comet.slope * 2.5) ] for line in testlines: self.check_for_row_in_table('id_orbelements', line) # She notices there are no details about the albedo or diameter, which # are hard to measure for comets. testlines = [ 'ALBEDO (AVERAGE) 0.17', 'ALBEDO (RANGE) 0.01 - 0.60', 'DIAMETER IN METERS (AVERAGE) ', 'DIAMETER IN METERS (RANGE) ' ] for line in testlines: table = self.browser.find_element_by_id('id_orbelements') table_body = table.find_element_by_tag_name('tbody') rows = table_body.find_elements_by_tag_name('tr') self.assertNotIn(line, [row.text.replace('\n', ' ') for row in rows])
def test_lookproject_page(self): MockDateTime.change_datetime(2017, 7, 1, 17, 0, 0) self.insert_extra_test_bodies() # self.insert_another_extra_test_body() # self.insert_another_other_extra_test_body() # Conan the Barbarian goes to the LOOK Project page and expects to see the list of bodies in need of observation. lookproject_page_url = self.live_server_url + '/lookproject/' self.browser.get(lookproject_page_url) self.assertNotIn('Home | LCO NEOx', self.browser.title) self.assertIn('LOOK Project Page | LCO NEOx', self.browser.title) testlines = [ 'Target Name', 'Target Type', 'Target Subtype', 'R.A.', 'Dec.', 'V Mag.', 'Rate ("/min)', 'Heliocentric Distance (AU)', 'Observations Scheduled', '(for next 30 days) Observation Window', '(for next 90 days)' ] testline = "\n".join(testlines) self.check_for_header_in_table('active_targets', testline) # Position below computed for 2017-07-01 17:00:00 testlines = [ u'C/2013 US10 Comet Hyperbolic, Dynamically New 03 57 50.41 +44 46 52.2 18.5 0.20 7.0 Nothing scheduled [-----]', u'C/2017 K2 Comet Long Period, Dynamically New 17 29 39.56 +64 13 24.1 17.8 0.17 11.8 Active until 07/30 [-----]' ] self.check_for_row_in_table('active_targets', testlines[0]) self.check_for_row_in_table('active_targets', testlines[1]) # He checks for fresh victims...comet targets... section_text = self.browser.find_element_by_id("new_comets").text self.assertIn("New Comet Targets", section_text) testlines = [ u'C/2013 US10 Hyperbolic, Dynamically New 03 57 50.41 +44 46 52.2 18.5 0.20 1.00055 1e+99 0.8245 5.296e-05 [-----]', ] self.check_for_row_in_table('new_comets', testlines[0])
def test_cannot_add_lookproject_target(self): MockDateTime.change_datetime(2020, 11, 14, 17, 0, 0) self.insert_extra_test_bodies() # self.insert_another_extra_test_body() # self.insert_another_other_extra_test_body() # Bart goes to the the LOOK Project page as he has heard about a new outburst lookproject_page_url = self.live_server_url + '/lookproject/' self.browser.get(lookproject_page_url) self.assertNotIn('Home | LCO NEOx', self.browser.title) self.assertIn('LOOK Project Page | LCO NEOx', self.browser.title) # He looks through the list of targets but does not see his desired target table = self.browser.find_element_by_id('active_targets') table_body = table.find_element_by_tag_name('tbody') rows = table_body.find_elements_by_tag_name('tr') self.assertNotIn('191P', [row.text.replace('\n', ' ') for row in rows]) # He logs in but is disappointed that the 'Add LOOK target' button has not appeared self.browser.get('%s%s' % (self.live_server_url, '/accounts/login/')) username_input = self.browser.find_element_by_id("username") username_input.send_keys(self.bart_username) password_input = self.browser.find_element_by_id("password") password_input.send_keys(self.bart_password) with self.wait_for_page_load(timeout=10): self.browser.find_element_by_id('login-btn').click() # Wait until response is received self.wait_for_element_with_id('page') # Back to LOOK Project page self.browser.get(lookproject_page_url) self.wait_for_element_with_id('page') newtarget_input = self.browser.find_elements_by_id('id_target_name') newtarget_button = self.browser.find_elements_by_id( 'add_new_target-btn') self.assertEqual(0, len(newtarget_input)) self.assertEqual(0, len(newtarget_button))
def test_characterization_page(self): MockDateTime.change_datetime(2015, 7, 1, 17, 0, 0) self.insert_extra_test_body() self.insert_another_extra_test_body() self.insert_another_other_extra_test_body() # Kildorn the Unstoppable goes to the characterization page and expects to see the list of bodies in need of Characterization. characterization_page_url = self.live_server_url + '/characterization/' self.browser.get(characterization_page_url) self.assertNotIn('Home | LCO NEOx', self.browser.title) self.assertIn('Characterization Page | LCO NEOx', self.browser.title) # Position below computed for 2015-07-01 17:00:00 testlines = [ u'1 V38821zi 23 43 14.40 +19 59 08.2 18.7 1.27 LC 19.0 Goldstone Vis+NIR 08/15-09/15', u'2 q382918r 23 43 14.40 +19 59 08.2 20.7 1.27 Spec/LC 21.0 NASA NIR Yes [-----]' ] self.check_for_row_in_table('characterization_targets', testlines[0]) self.check_for_row_in_table('characterization_targets', testlines[1])
def test_can_view_calibsources(self): self.add_new_calib_sources() MockDateTime.change_datetime(2018, 5, 22, 5, 0, 0) # A new user, Daniel, goes to a hidden calibration page on the site target_url = "{0}{1}".format(self.live_server_url, reverse('calibsource-view')) self.browser.get(target_url) actual_url = self.browser.current_url self.assertEqual(actual_url, target_url) # He notices the page title has the name of the site and the header # mentions calibrations self.assertIn('Calibration Sources | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn('Calibration Sources', header_text) # He notices the position of the Solar antinode is given. expected_coords = ['15:55:45.42', '-20:22:15.3'] coords_text = self.browser.find_element_by_id('anti_solar_point').text for coor in expected_coords: self.assertIn(coor, coords_text) # He notices there are several calibration sources that are listed self.check_for_header_in_table( 'id_calibsources', 'Name R.A. Dec. V Mag. Spectral Type Source Type') testlines = [ 'HR9087 00:01:49.42 -03:01:39.0 5.12 B7III Spectrophotometric standard', 'CD-34d241 00:41:46.92 -33:39:08.5 11.23 F Spectrophotometric standard', 'LTT2415 05:56:24.30 -27:51:28.8 12.21 Spectrophotometric standard', 'Landolt SA98-978 06:51:34.00 -00:11:33.0 10.50 G2V Solar spectrum standard' ] self.check_for_row_in_table('id_calibsources', testlines[0]) self.check_for_row_in_table('id_calibsources', testlines[1]) self.check_for_row_in_table('id_calibsources', testlines[2]) self.check_for_row_in_table('id_calibsources', testlines[3])
def test_schedule_page_edit_block(self): self.test_login() # Bart has heard about a new website for NEOs. He goes to the # page of the first target # (XXX semi-hardwired but the targets link should be being tested in # test_targets_validation.TargetsValidationTest) start_url = reverse('target', kwargs={'pk': 1}) self.browser.get(self.live_server_url + start_url) # He sees a Schedule Observations button link = self.browser.find_element_by_id('schedule-obs') target_url = "{0}{1}".format( self.live_server_url, reverse('schedule-body', kwargs={'pk': 1})) actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to go to the Schedule Observations page with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), target_url) # He sees a Switch to Cadence Observations button link = self.browser.find_element_by_id('single-switch') target_url = "{0}{1}{2}".format( self.live_server_url, reverse('schedule-body', kwargs={'pk': 1}), '#') actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to Switch to Cadence Observations link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), target_url) # He notices a new selection for the proposal, site code, # UTC start date, UTC end date, period, and jitter and # chooses the NEO Follow-up Network, ELP (V37), period=2 hrs, # and jitter=0.5 hrs proposal_choices = Select( self.browser.find_element_by_id('id_proposal_code_cad')) self.assertIn(self.neo_proposal.title, [option.text for option in proposal_choices.options]) # self.browser.implicitly_wait(15) proposal_choices.select_by_visible_text(self.neo_proposal.title) site_choices = Select( self.browser.find_element_by_id('id_site_code_cad')) self.assertIn('ELP 1.0m - V37,V39; (McDonald, Texas)', [option.text for option in site_choices.options]) site_choices.select_by_visible_text( 'ELP 1.0m - V37,V39; (McDonald, Texas)') MockDateTime.change_datetime(2015, 4, 20, 1, 30, 00) datebox = self.get_item_input_box('id_start_time') datebox.clear() datebox.send_keys('2015-04-21 01:30:00') MockDateTime.change_datetime(2015, 4, 20, 7, 30, 00) datebox = self.get_item_input_box('id_end_time') datebox.clear() datebox.send_keys('2015-04-21 07:30:00') jitterbox = self.get_item_input_box('id_jitter') jitterbox.clear() jitterbox.send_keys('0.5') periodbox = self.get_item_input_box('id_period') periodbox.clear() periodbox.send_keys('1.0') with self.wait_for_page_load(timeout=10): self.browser.find_element_by_xpath( '//button[@id="cadence-submit"]').click() # The page refreshes and he reaches the schedule cadence page target_url = "{0}{1}".format( self.live_server_url, reverse('schedule-body-cadence', kwargs={'pk': 1})) new_url = self.browser.current_url self.assertEqual(str(new_url), target_url) # He notices that a series of values for magnitude, speed, slot # length, number and length of exposures, period, and jitter appear magnitude = self.browser.find_element_by_id( 'id_magnitude_row').find_element_by_class_name('kv-value').text self.assertIn('20.40', magnitude) speed = self.browser.find_element_by_id( 'id_speed_row').find_element_by_class_name('kv-value').text self.assertIn('2.37 "/min', speed) slot_length = self.browser.find_element_by_id( 'id_slot_length').get_attribute('value') self.assertIn('22.5', slot_length) num_exp = self.browser.find_element_by_id( 'id_no_of_exps_row').find_element_by_class_name('kv-value').text self.assertIn('9', num_exp) exp_length = self.browser.find_element_by_id( 'id_exp_length').get_attribute('value') self.assertIn('100.0', exp_length) jitter = self.browser.find_element_by_id('id_jitter').get_attribute( 'value') self.assertIn('0.5', jitter) period = self.browser.find_element_by_id('id_period').get_attribute( 'value') self.assertIn('1.0', period) cadence_cost = self.browser.find_element_by_id( 'id_cadence_cost_row').find_element_by_class_name('kv-value').text self.assertIn('2 / 0.75', cadence_cost) # Bart wants to change the slot length and recalculate the number of exposures slot_length_box = self.browser.find_element_by_id('id_slot_length') slot_length_box.clear() slot_length_box.send_keys('25.') # He also wants to change the period to 0 because he thinks it will be funny periodbox = self.browser.find_element_by_id('id_period') periodbox.clear() periodbox.send_keys('0') # He wants the cadence to end a few days later self.browser.find_element_by_id("id_edit_window").click() datebox = self.get_item_input_box('id_end_time') datebox.clear() datebox.send_keys('2015-04-23 07:30:00') self.browser.find_element_by_id("id_edit_button").click() # The page refreshes and we get correct slot length and the Schedule button again slot_length = self.browser.find_element_by_id( 'id_slot_length').get_attribute('value') self.assertIn('25.', slot_length) jitter = self.browser.find_element_by_id('id_jitter').get_attribute( 'value') self.assertIn('0.5', jitter) period = self.browser.find_element_by_id('id_period').get_attribute( 'value') self.assertIn('0.02', period) # He sees a warning about the large number of hours now required for this cadence. As well as a message about potential overlap cadence_cost = self.browser.find_element_by_id( 'id_cadence_cost_row').find_element_by_class_name('warning').text self.assertIn('2328 / 970', cadence_cost) period_warning = self.browser.find_element_by_id( 'id_period_row').find_element_by_class_name('warning').text self.assertIn('PERIOD', period_warning) submit = self.browser.find_element_by_id( 'id_submit_button').get_attribute("value") self.assertIn('Schedule this Object', submit)
def test_can_schedule_specific_calibsource(self): self.add_new_calib_sources() self.test_login() MockDateTime.change_datetime(2019, 1, 21, 5, 0, 0) # A new user, Daniel, goes to a hidden calibration page on the site target_url = "{0}{1}".format(self.live_server_url, reverse('calibsource-view')) self.browser.get(target_url) actual_url = self.browser.current_url self.assertEqual(actual_url, target_url) # He notices the page title has the name of the site and the header # mentions calibrations self.assertIn('Calibration Sources | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn('Calibration Sources', header_text) # He decides he would like to schedule a Solar Analog # He sees a Solar Analog Only button link = self.browser.find_element_by_id('show-solar-standards') target_url = "{0}{1}".format(self.live_server_url, reverse('solarstandard-view')) actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) table_text = self.browser.find_element_by_id('id_calibsources').text self.assertIn('Spectrophotometric', table_text) # He clicks the button to remove non-solar statndards with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(new_url, actual_url) table_text = self.browser.find_element_by_id('id_calibsources').text self.assertNotIn('Spectrophotometric', table_text) # He picks a star link = self.browser.find_element_by_link_text('Landolt SA98-978') target = StaticSource.objects.filter(name='Landolt SA98-978') target_key = target[0].id target_url = "{0}{1}".format( self.live_server_url, reverse('calibsource', kwargs={'pk': target_key})) actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to visit the Solar Standard detail page with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(new_url, actual_url) # He sees the detail page for his standard table_text = self.browser.find_element_by_id( 'id_staticsource_detail').text self.assertIn('06:51:34.00', table_text) self.assertIn('G2V', table_text) self.assertIn( 'Solar spectrum standard', self.browser.find_element_by_class_name("section-title").text) # He schedules a spectra link = self.browser.find_element_by_id('schedule-spectro-obs') target_url = "{0}{1}".format( self.live_server_url, reverse('schedule-calib-spectra', kwargs={ 'instrument_code': 'E10-FLOYDS', 'pk': target_key })) actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to schedule a spectra with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(new_url, actual_url) # He sees the scheduling parameters are displayed self.assertIn('NEOx spectroscopy scheduling | LCO NEOx', self.browser.title) self.assertIn("E10-FLOYDS", self.browser.current_url) header_text = self.browser.find_element_by_class_name( 'section-title').text self.assertIn('Parameters for: Landolt SA98-978', header_text) self.assertIn("06:51:34.00", header_text) self.assertIn("-00:11:33.0", header_text) self.assertIn('V=10.5', header_text) datebox = self.get_item_input_box('id_utc_date') datebox.clear() datebox.send_keys('2019-01-22') # Liking the selected star, he clicks Verify and is taken to a confirmation # page button = self.browser.find_element_by_id('verify-scheduling') with self.wait_for_page_load(timeout=10): button.click() self.assertIn('NEOx calibration scheduling | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn("Landolt SA98-978: Confirm Scheduling", header_text) filter_pattern = self.browser.find_element_by_id( "id_filter_pattern").get_attribute('value') self.assertIn("slit_6.0as", filter_pattern) exp_length = self.browser.find_element_by_id( 'id_exp_length').get_attribute('value') self.assertIn('180.0', exp_length) # Liking the selected star parameters, he clicks Submit and is returned to the # home page button = self.browser.find_element_by_id('id_submit_button') with self.wait_for_page_load(timeout=10): button.click() target_url = "{0}{1}".format(self.live_server_url, reverse('home')) actual_url = self.browser.current_url self.assertEqual(actual_url, target_url)
def test_can_schedule_calibsource_fts(self): self.add_new_calib_sources() self.test_login() MockDateTime.change_datetime(2018, 9, 21, 5, 0, 0) # A new user, Daniel, goes to a hidden calibration page on the site target_url = "{0}{1}".format(self.live_server_url, reverse('calibsource-view')) self.browser.get(target_url) actual_url = self.browser.current_url self.assertEqual(actual_url, target_url) # He notices the page title has the name of the site and the header # mentions calibrations self.assertIn('Calibration Sources | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn('Calibration Sources', header_text) # He decides he would like to schedule a standard on FTS # He sees a Schedule Calibration Observations button link = self.browser.find_element_by_id('schedule-calib-fts-obs') target_url = "{0}{1}".format( self.live_server_url, reverse('schedule-calib-spectra', kwargs={ 'instrument_code': 'E10-FLOYDS', 'pk': '-' })) actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to go to the Schedule Calibration Observations page with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(new_url, actual_url) # He sees a suggested standard comes up and the parameters are displayed self.assertIn('NEOx spectroscopy scheduling | LCO NEOx', self.browser.title) self.assertIn("E10-FLOYDS", self.browser.current_url) header_text = self.browser.find_element_by_class_name( 'section-title').text self.assertIn('Parameters for: CD-34d241', header_text) self.assertIn("00:41:46.92", header_text) self.assertIn("-33:39:08.5", header_text) self.assertIn('V=11.2', header_text) datebox = self.get_item_input_box('id_utc_date') datebox.clear() datebox.send_keys('2018-09-22') # Liking the selected star, he clicks Verify and is taken to a confirmation # page button = self.browser.find_element_by_id('verify-scheduling') with self.wait_for_page_load(timeout=10): button.click() self.assertIn('NEOx calibration scheduling | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn("CD-34d241: Confirm Scheduling", header_text) filter_pattern = self.browser.find_element_by_id( "id_filter_pattern").get_attribute('value') self.assertIn("slit_6.0as", filter_pattern) exp_length = self.browser.find_element_by_id( 'id_exp_length').get_attribute('value') self.assertIn('180.0', exp_length) # Liking the selected star parameters, he clicks Submit and is returned to the # home page button = self.browser.find_element_by_id('id_submit_button') with self.wait_for_page_load(timeout=10): button.click() target_url = "{0}{1}".format(self.live_server_url, reverse('home')) actual_url = self.browser.current_url self.assertEqual(actual_url, target_url)
def test_can_view_body_details_no_update(self): MockDateTime.change_datetime(2015, 3, 19, 6, 00, 00) self.body.update_time = None self.body.save() self.body.refresh_from_db() # A new user comes along to the site self.browser.get(self.live_server_url) # She sees a link from the targets' name on the front page to a more # detailed view. link = self.browser.find_element_by_link_text('N999r0q') body_url = self.live_server_url + reverse('target', kwargs={'pk': 1}) self.assertIn(link.get_attribute('href'), body_url) # She clicks the link and is taken to a page with the targets' details. with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), body_url) # She notices the page title has the name of the site and the header # mentions the current target self.assertIn(self.body.current_name() + ' details | LCO NEOx', self.browser.title) header_text = self.browser.find_element_by_class_name( 'headingleft').text self.assertIn(self.body.full_name(), header_text) title_text = self.browser.find_element_by_class_name('container').text self.assertNotIn('Characterization Target', title_text) # She notices there is a table which lists a lot more details about # the Body. sidebar_text = self.browser.find_element_by_class_name( 'rightsidebar').text self.assertIn( "Ingest Time: " + self.body.ingest.strftime("%Y-%b-%d %H:%M"), sidebar_text) testlines = [ 'ECCENTRICITY ' + str(self.body.eccentricity), 'MEAN DISTANCE (AU) ' + str(self.body.meandist), 'ABSOLUTE MAGNITUDE (H) ' + str(self.body.abs_mag), 'ALBEDO (AVERAGE) 0.17', 'ALBEDO (RANGE) 0.01 - 0.60', 'DIAMETER IN METERS (AVERAGE) ' + str(int(round(self.body.diameter(), 0))), 'DIAMETER IN METERS (RANGE) ' + str(int(round(self.body.diameter_range()[0], 0))) + ' - ' + str(int(round(self.body.diameter_range()[1], 0))) ] for line in testlines: self.check_for_row_in_table('id_orbelements', line) # She notices there is another table which lists details about # the follow-up of the Body. testlines = [ 'NEOCP DIGEST2 SCORE ' + str(self.body.score), 'NUMBER OF OBSERVATIONS ' + str(self.body.num_obs), 'ARC LENGTH (DAYS) ' + str(round(self.body.arc_length, 2)), 'TIME SINCE LAST OBSERVATION (DAYS) ' + str(round(self.body.not_seen, 2)) ] for line in testlines: self.check_for_row_in_table('id_followup', line)
def setUp(self): MockDateTime.change_datetime(2015, 12, 31, 22, 0, 0)
def test_can_schedule_cadence(self): self.test_login() # Bart has heard about a new website for NEOs. He goes to the # page of the first target # (XXX semi-hardwired but the targets link should be being tested in # test_targets_validation.TargetsValidationTest) start_url = reverse('target', kwargs={'pk': 1}) self.browser.get(self.live_server_url + start_url) # He sees a Schedule Observations button link = self.browser.find_element_by_id('schedule-obs') target_url = "{0}{1}".format( self.live_server_url, reverse('schedule-body', kwargs={'pk': 1})) actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to go to the Schedule Observations page with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), target_url) # He sees a Switch to Cadence Observations button link = self.browser.find_element_by_id('single-switch') target_url = "{0}{1}{2}".format( self.live_server_url, reverse('schedule-body', kwargs={'pk': 1}), '#') actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to Switch to Cadence Observations link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), target_url) # He notices a new selection for the proposal, site code, # UTC start date, UTC end date, period, and jitter and # chooses the NEO Follow-up Network, ELP (V37), period=2 hrs, # and jitter=0.25 hrs proposal_choices = Select( self.browser.find_element_by_id('id_proposal_code_cad')) self.assertIn(self.neo_proposal.title, [option.text for option in proposal_choices.options]) # Bart doesn't see the proposal to which he doesn't have permissions self.assertNotIn(self.test_proposal.title, [option.text for option in proposal_choices.options]) proposal_choices.select_by_visible_text(self.neo_proposal.title) # He enters the correct details site_choices = Select( self.browser.find_element_by_id('id_site_code_cad')) self.assertIn('ELP 1.0m - V37,V39; (McDonald, Texas)', [option.text for option in site_choices.options]) site_choices.select_by_visible_text( 'ELP 1.0m - V37,V39; (McDonald, Texas)') # Submits with a typo in the start date box MockDateTime.change_datetime(2015, 4, 20, 1, 30, 00) datebox = self.get_item_input_box('id_start_time') datebox.clear() datebox.send_keys('2005-04-21 01:30:00') MockDateTime.change_datetime(2015, 4, 20, 1, 30, 00) datebox = self.get_item_input_box('id_end_time') datebox.clear() datebox.send_keys('2015-04-21 07:30:00') jitterbox = self.get_item_input_box('id_jitter') jitterbox.clear() jitterbox.send_keys('0.5') periodbox = self.get_item_input_box('id_period') periodbox.clear() periodbox.send_keys('3.0') with self.wait_for_page_load(timeout=10): self.browser.find_element_by_xpath( '//button[@id="cadence-submit"]').click() # The page refreshes and he reaches the schedule cadence page target_url = "{0}{1}".format( self.live_server_url, reverse('schedule-body-cadence', kwargs={'pk': 1})) new_url = self.browser.current_url self.assertEqual(str(new_url), target_url) # He notices that a series of values for magnitude, speed, slot # length, number and length of exposures, period, and jitter appear magnitude = self.browser.find_element_by_id( 'id_magnitude_row').find_element_by_class_name('kv-value').text self.assertIn('20.37', magnitude) speed = self.browser.find_element_by_id( 'id_speed_row').find_element_by_class_name('kv-value').text self.assertIn('2.42 "/min', speed) slot_length = self.browser.find_element_by_id( 'id_slot_length').get_attribute('value') self.assertIn('22.5', slot_length) num_exp = self.browser.find_element_by_id( 'id_no_of_exps_row').find_element_by_class_name('kv-value').text self.assertIn('10', num_exp) exp_length = self.browser.find_element_by_id( 'id_exp_length').get_attribute('value') self.assertIn('95.0', exp_length) start_time = self.browser.find_element_by_id( 'id_start_time').get_attribute('value') self.assertIn('2015-04-20T01:30:00', start_time) jitter = self.browser.find_element_by_id('id_jitter').get_attribute( 'value') self.assertIn('0.5', jitter) period = self.browser.find_element_by_id('id_period').get_attribute( 'value') self.assertIn('3.0', period) cadence_cost = self.browser.find_element_by_id( 'id_cadence_cost_row').find_element_by_class_name('kv-value').text self.assertIn('10 / 3.75', cadence_cost) # At this point, a 'Schedule this object' button appears submit = self.browser.find_element_by_id( 'id_submit_button').get_attribute("value") self.assertIn('Schedule this Object', submit)
def test_schedule_page_short_block(self): self.test_login() # Bart has heard about a new website for NEOs. He goes to the # page of the first target # (XXX semi-hardwired but the targets link should be being tested in # test_targets_validation.TargetsValidationTest) start_url = reverse('target', kwargs={'pk': 1}) self.browser.get(self.live_server_url + start_url) # He sees a Schedule Observations button link = self.browser.find_element_by_id('schedule-obs') target_url = "{0}{1}".format( self.live_server_url, reverse('schedule-body', kwargs={'pk': 1})) actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to go to the Schedule Observations page with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), target_url) # He sees a Switch to Cadence Observations button link = self.browser.find_element_by_id('single-switch') target_url = "{0}{1}{2}".format( self.live_server_url, reverse('schedule-body', kwargs={'pk': 1}), '#') actual_url = link.get_attribute('href') self.assertEqual(actual_url, target_url) # He clicks the link to Switch to Cadence Observations link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), target_url) # He notices a new selection for the proposal, site code, # UTC start date, UTC end date, period, and jitter and # chooses the NEO Follow-up Network, ELP (V37), period=2 hrs, # and jitter=0.1 hrs proposal_choices = Select( self.browser.find_element_by_id('id_proposal_code_cad')) self.assertIn(self.neo_proposal.title, [option.text for option in proposal_choices.options]) proposal_choices.select_by_visible_text(self.neo_proposal.title) site_choices = Select( self.browser.find_element_by_id('id_site_code_cad')) self.assertIn('ELP 1.0m - V37,V39; (McDonald, Texas)', [option.text for option in site_choices.options]) site_choices.select_by_visible_text( 'ELP 1.0m - V37,V39; (McDonald, Texas)') MockDateTime.change_datetime(2015, 4, 20, 1, 30, 00) datebox = self.get_item_input_box('id_start_time') datebox.clear() datebox.send_keys('2015-04-21 01:30:00') MockDateTime.change_datetime(2015, 4, 20, 7, 30, 00) datebox = self.get_item_input_box('id_end_time') datebox.clear() datebox.send_keys('2015-04-21 07:30:00') # He wants a very small jitter jitterbox = self.get_item_input_box('id_jitter') jitterbox.clear() jitterbox.send_keys('0.1') periodbox = self.get_item_input_box('id_period') periodbox.clear() periodbox.send_keys('1.0') with self.wait_for_page_load(timeout=10): self.browser.find_element_by_xpath( '//button[@id="cadence-submit"]').click() # The page refreshes and he reaches the schedule cadence page target_url = "{0}{1}".format( self.live_server_url, reverse('schedule-body-cadence', kwargs={'pk': 1})) new_url = self.browser.current_url self.assertEqual(str(new_url), target_url) # He notices that a series of values for magnitude, speed, slot # length, number and length of exposures, period, and jitter appear magnitude = self.browser.find_element_by_id( 'id_magnitude_row').find_element_by_class_name('kv-value').text self.assertIn('20.40', magnitude) speed = self.browser.find_element_by_id( 'id_speed_row').find_element_by_class_name('kv-value').text self.assertIn('2.37 "/min', speed) slot_length = self.browser.find_element_by_id( 'id_slot_length').get_attribute('value') self.assertIn('22.5', slot_length) num_exp = self.browser.find_element_by_id( 'id_no_of_exps_row').find_element_by_class_name('kv-value').text self.assertIn('9', num_exp) exp_length = self.browser.find_element_by_id( 'id_exp_length').get_attribute('value') self.assertIn('100.0', exp_length) # He notices the Jitter automatically adjusts to fit the slot length. jitter = self.browser.find_element_by_id('id_jitter').get_attribute( 'value') self.assertIn('0.39', jitter) period = self.browser.find_element_by_id('id_period').get_attribute( 'value') self.assertIn('1.0', period) cadence_cost = self.browser.find_element_by_id( 'id_cadence_cost_row').find_element_by_class_name('kv-value').text self.assertIn('2 / 0.75', cadence_cost) # Bart wants to change the slot length so it is very short and recalculate the number of exposures slot_length_box = self.browser.find_element_by_id('id_slot_length') slot_length_box.clear() slot_length_box.send_keys('2.') with self.wait_for_page_load(timeout=10): self.browser.find_element_by_id("id_edit_button").click() # The page refreshes and slot length is automatically adjusted to minimum possible length new_slot_length = self.browser.find_element_by_id( 'id_slot_length').get_attribute('value') self.assertIn('4', new_slot_length) warn_num = self.browser.find_element_by_id( 'id_no_of_exps_row').find_element_by_class_name('warning').text self.assertIn('1', warn_num)
def test_characterization_rank(self): MockDateTime.change_datetime(2015, 7, 1, 17, 0, 0) self.body.origin = 'N' # First target is from NASA self.body.source_type = 'N' # First target is an NEO self.body.abs_mag = 15.5 self.body.save() self.insert_extra_test_body() self.insert_another_extra_test_body() self.insert_another_other_extra_test_body() characterization_page_url = self.live_server_url + '/characterization/' self.browser.get(characterization_page_url) # Position below computed for 2015-07-01 17:00:00 testlines = [ u'2 V38821zi 23 43 14.40 +19 59 08.2 18.7 1.27 LC 19.0 Goldstone Vis+NIR 08/15-09/15', u'3 q382918r 23 43 14.40 +19 59 08.2 20.7 1.27 Spec/LC 21.0 NASA NIR Yes [-----]', u'1 N999r0q 23 43 14.40 +19 59 08.2 15.2 1.27 LC 15.5 NASA Vis+NIR NIR Now->' ] for line in testlines: self.check_for_row_in_table('characterization_targets', line) # Kildorn cares not for ALL Characterization targets. He wants to see only spectroscopy targets! button = self.browser.find_element_by_id('filter_spec') with self.wait_for_page_load(timeout=10): button.click() self.check_for_row_not_in_table('characterization_targets', testlines[0]) self.check_for_row_not_in_table('characterization_targets', testlines[2]) self.check_for_row_in_table( 'characterization_targets', u'1 q382918r 23 43 14.40 +19 59 08.2 20.7 1.27 Spec/LC 21.0 NASA NIR Yes [-----]' ) # Kildorn notices a link to the body page link = self.browser.find_element_by_link_text('q382918r') body_url = self.live_server_url + reverse('target', kwargs={'pk': 3}) self.assertIn(link.get_attribute('href'), body_url) with self.wait_for_page_load(timeout=10): link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), body_url) # He then sees that there is information from other surveys that have already gotten spectra for his targets testlines = [ 'SMASS SPECTRA NIR', 'MANOS TARGET (No Data Yet)', ] for line in testlines: self.check_for_row_in_table('id_spectralinfo', line) # He sees a link for plots that piques his curiosity. plot_link = self.browser.find_element_by_link_text('(Plots)') with self.wait_for_page_load(timeout=10): plot_link.click() new_url = self.browser.current_url self.assertEqual(str(new_url), body_url + 'spectra/')