def test_missing_start_time(self): entry = self._create_history_entry('id1') entry.start_time = None translated_entries = to_short_execution_log([entry]) self.assertIn('startTime', translated_entries[0]) self.assertIsNone(translated_entries[0]['startTime'])
def test_running_status(self): entry = self._create_history_entry('id1') translated_entries = to_short_execution_log([entry], ['id0', 'id1', 'id2']) self._validate_translated_entry(translated_entries[0], 'id1', status='running')
def test_missing_start_time(self): entry = self._create_history_entry('id1') entry.start_time = None translated_entries = to_short_execution_log([entry]) self.assertIn('startTime', translated_entries[0]) self.assertIsNone(translated_entries[0]['startTime'])
def get(self, user): history_entries = self.application.execution_logging_service.get_history_entries(user.user_id) running_script_ids = [] for entry in history_entries: if self.application.execution_service.is_running(entry.id, user): running_script_ids.append(entry.id) short_logs = to_short_execution_log(history_entries, running_script_ids) self.write(json.dumps(short_logs))
def get(self): history_entries = self.application.execution_logging_service.get_history_entries() running_script_ids = [] for entry in history_entries: if self.application.execution_service.is_running(entry.id): running_script_ids.append(entry.id) short_logs = to_short_execution_log(history_entries, running_script_ids) self.write(json.dumps(short_logs))
def test_multiple_short_entries(self): entry1 = self._create_history_entry('id1', user_name='my user', ) entry2 = self._create_history_entry('id2', script_name='Destroy world', ) entry3 = self._create_history_entry('id3', exit_code='13') translated_entries = to_short_execution_log([entry1, entry2, entry3]) self.assertEqual(3, len(translated_entries)) self._validate_translated_entry(translated_entries[0], 'id1', user='******') self._validate_translated_entry(translated_entries[1], 'id2', script_name='Destroy world') self._validate_translated_entry(translated_entries[2], 'id3', exit_code='13')
def test_multiple_short_entries(self): entry1 = self._create_history_entry('id1', user_name='my user', ) entry2 = self._create_history_entry('id2', script_name='Destroy world', ) entry3 = self._create_history_entry('id3', exit_code='13') translated_entries = to_short_execution_log([entry1, entry2, entry3]) self.assertEqual(3, len(translated_entries)) self._validate_translated_entry(translated_entries[0], 'id1', user='******') self._validate_translated_entry(translated_entries[1], 'id2', script_name='Destroy world') self._validate_translated_entry(translated_entries[2], 'id3', exit_code='13')
def test_start_time_translation(self): entry = self._create_history_entry('id1', start_time=datetime.strptime( '18:25:22+0230_2018_04_03', "%H:%M:%S%z_%Y_%m_%d")) translated_entries = to_short_execution_log([entry]) self._validate_translated_entry( translated_entries[0], 'id1', start_time_string='2018-04-03T15:55:22+00:00')
def test_start_time_translation(self): entry = self._create_history_entry( 'id1', start_time=datetime.strptime('18:25:22+0230_2018_04_03', "%H:%M:%S%z_%Y_%m_%d") ) translated_entries = to_short_execution_log([entry]) self._validate_translated_entry( translated_entries[0], 'id1', start_time_string='2018-04-03T15:55:22+00:00' )
def test_simple_short_entry(self): entry = self._create_history_entry('id1', user_name='my user', script_name='Destroy world', exit_code='5') translated_entries = to_short_execution_log([entry]) self.assertEqual(1, len(translated_entries)) self._validate_translated_entry(translated_entries[0], 'id1', user='******', script_name='Destroy world', exit_code='5')
def test_start_time_without_timezone(self): start_time_local = datetime(2018, 4, 5, 12, 34, 56, tzinfo=timezone.utc).astimezone(tz=None) start_time_naive = start_time_local.replace(tzinfo=None) entry = self._create_history_entry( 'id1', start_time=start_time_naive ) translated_entries = to_short_execution_log([entry]) self._validate_translated_entry( translated_entries[0], 'id1', start_time_string=start_time_local.astimezone(tz=timezone.utc).isoformat() )
def test_start_time_without_timezone(self): start_time_local = datetime(2018, 4, 5, 12, 34, 56, tzinfo=timezone.utc).astimezone(tz=None) start_time_naive = start_time_local.replace(tzinfo=None) entry = self._create_history_entry( 'id1', start_time=start_time_naive ) translated_entries = to_short_execution_log([entry]) self._validate_translated_entry( translated_entries[0], 'id1', start_time_string=start_time_local.astimezone(tz=timezone.utc).isoformat() )
def test_simple_short_entry(self): entry = self._create_history_entry( 'id1', user_name='my user', script_name='Destroy world', exit_code='5' ) translated_entries = to_short_execution_log([entry]) self.assertEqual(1, len(translated_entries)) self._validate_translated_entry( translated_entries[0], 'id1', user='******', script_name='Destroy world', exit_code='5' )
def test_running_status(self): entry = self._create_history_entry('id1') translated_entries = to_short_execution_log([entry], ['id0', 'id1', 'id2']) self._validate_translated_entry(translated_entries[0], 'id1', status='running')