From: Salim Fadhley Date: Fri, 31 May 2013 23:00:59 +0000 (+0100) Subject: Some small code tidy-ups, a version bump + correct the datetime behavior for build... X-Git-Tag: v0.2.23~236 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7096718d7f4cb8de14c49b5f8f7ac45180d7943;p=tools%2Fpython-jenkinsapi.git Some small code tidy-ups, a version bump + correct the datetime behavior for build.get_timestamp() --- diff --git a/jenkinsapi_tests/unittests/__init__.py b/jenkinsapi_tests/unittests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py new file mode 100644 index 0000000..980698c --- /dev/null +++ b/jenkinsapi_tests/unittests/test_build.py @@ -0,0 +1,37 @@ +import mock +import unittest +import datetime + +from jenkinsapi.build import Build + +class TestTimestamps(unittest.TestCase): + + DATA = { 'actions': [{'causes': [{'shortDescription': 'Started by user anonymous', + 'userId': None, + 'userName': 'anonymous'}]}], + 'artifacts': [], + 'building': False, + 'builtOn': '', + 'changeSet': {'items': [], 'kind': None}, + 'culprits': [], + 'description': None, + 'duration': 106, + 'estimatedDuration': 106, + 'executor': None, + 'fullDisplayName': 'foo #1', + 'id': '2013-05-31_23-15-40', + 'keepLog': False, + 'number': 1, + 'result': 'SUCCESS', + 'timestamp': 1370038540938, + 'url': 'http://localhost:8080/job/foo/1/'} + + @mock.patch.object(Build, '_poll') + def testTimestamp(self, _poll): + _poll.return_value = self.DATA + + j = mock.MagicMock() + b = Build('http://', 0, j) + + self.assertIsInstance(b.get_timestamp(), datetime.datetime) + self.assertEqual(b.get_timestamp(), datetime.datetime(2013, 5, 31, 23, 15, 40)) \ No newline at end of file