Commit 60384224 authored by Raphaël Hertzog's avatar Raphaël Hertzog

debci: no longer rely on duration_human, compute our own

parent 673d0364
Pipeline #76517 passed with stage
in 32 minutes and 23 seconds
......@@ -56,7 +56,6 @@ class UpdateDebciStatusTaskTest(TestCase):
"blame": [],
"previous_status": "pass",
"duration_seconds": "91",
"duration_human": "0h 1m 31s",
"message": "Tests failed"
}
]
......@@ -117,7 +116,7 @@ class UpdateDebciStatusTaskTest(TestCase):
log = "https://ci.debian.net/data/packages/unstable/amd64/d/" + \
"dummy-package/latest-autopkgtest/log.gz"
self.assertIn(self.url, action_item.short_description)
self.assertEqual(action_item.extra_data[0]['duration'], "0h 1m 31s")
self.assertEqual(action_item.extra_data[0]['duration'], "0:01:31")
self.assertEqual(action_item.extra_data[0]['previous_status'], "pass")
self.assertEqual(action_item.extra_data[0]['date'],
"2014-07-05 14:55:57")
......@@ -195,6 +194,26 @@ class UpdateDebciStatusTaskTest(TestCase):
self.assertEqual(0, self.package.action_items.count())
def test_no_exception_on_null_entry(self, mock_requests):
"""
Tests that no exception is raised when getting a null entry
is present in the JSON data.
"""
self.json_data.append(None)
set_mock_response(mock_requests, json=self.json_data)
self.run_task()
def test_no_exception_on_null_duration(self, mock_requests):
"""
Tests that no exception is raised when getting a null duration
in the JSON data.
"""
self.json_data[0]['duration_seconds'] = None
set_mock_response(mock_requests, json=self.json_data)
self.run_task()
@override_settings(DISTRO_TRACKER_DEBCI_REPOSITORIES=['debcirepo'])
def test_debci_repository_variable_enforced(self, mock_requests):
"""
......
......@@ -12,6 +12,7 @@ The Distro-Tracker-specific tasks for :mod:`distro_tracker.debci_status` app.
"""
import collections
import datetime
import json
import logging
import os.path
......@@ -122,8 +123,14 @@ class UpdateDebciStatusTask(BaseTask):
log = self.__get_debci_url_logfile(package_name, repo_codename)
result = debci_status['result']
try:
duration = str(datetime.timedelta(
seconds=int(result['duration_seconds'])))
except TypeError:
duration = 'an unknown time'
debci_action_item.extra_data.append({
'duration': result['duration_human'],
'duration': duration,
'previous_status': result['previous_status'],
'status': result['status'],
'date': result['date'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment