def test_write_table_data(self, mock_get_hostname): mock_get_hostname.return_value = self.hostname self.setup_db("This is my cool test!") target = topic_helpers.target self.db.write_table("target_history", [write_target_history(target, self.session_id)]) self.check_db_file_for_target_info()
def test_write_target_history_table(self): target_topic = topic_helpers.target session_id = 1001 result = tbls.write_target_history(target_topic, session_id) targets = tbls.create_target_history(self.metadata) self.check_ordered_dict_to_table(result, targets) self.assertEqual(result['Session_sessionId'], session_id) self.assertEqual(result['Field_fieldId'], target_topic.fieldId) self.assertEqual(result['groupId'], target_topic.groupId) self.assertEqual(result['filter'], target_topic.filter) self.assertEqual(result['dec'], target_topic.dec) self.assertEqual(result['requestedExpTime'], sum(target_topic.exposure_times)) self.assertEqual(result['airmass'], target_topic.airmass) self.assertEqual(result['cloud'], target_topic.cloud) self.assertEqual(result['seeing'], target_topic.seeing) self.assertEqual(result['rank'], target_topic.rank) self.assertEqual(result['numRequestingProps'], target_topic.num_proposals) self.assertEqual(result['moonRA'], target_topic.moon_ra) self.assertEqual(result['moonAz'], target_topic.moon_az) self.assertEqual(result['cost'], target_topic.cost)