Skip to content

Commit

Permalink
Skip tests when txgithub is not installed. Use dynamic datetime for s…
Browse files Browse the repository at this point in the history
…tart and end datetime.
  • Loading branch information
adiroiban committed May 27, 2013
1 parent 2edcfa6 commit c50d244
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions master/buildbot/test/unit/test_status_github.py
Expand Up @@ -16,14 +16,22 @@
Unit tests for GitHubStatus plugin.
"""
from __future__ import absolute_import
import datetime


from mock import Mock
from twisted.internet import defer
from twisted.trial import unittest

from buildbot.process.properties import Interpolate
from buildbot.status.builder import SUCCESS, FAILURE
from buildbot.status.github import GitHubStatus
try:
import txgithub
txgithub # Silence the linter.
from buildbot.status.github import GitHubStatus
except ImportError:
txgithub = None

from buildbot.test.fake.fakebuild import FakeBuild
from buildbot.test.util import logging

Expand All @@ -41,6 +49,9 @@ class TestGitHubStatus(unittest.TestCase, logging.LoggingMixin):

def setUp(self):
super(TestGitHubStatus, self).setUp()
if not txgithub:
raise unittest.SkipTest("txgithub not found.")

self.setUpLogging()
self.build = FakeBuild()
self.status = GitHubStatus(
Expand Down Expand Up @@ -229,6 +240,7 @@ def test_sendStartStatus_ok(self):
}
self.status._sendGitHubStatus = Mock(return_value=defer.succeed(None))
self.build.getTimes = lambda: (1, None)
startDateTime = datetime.datetime.fromtimestamp(1).isoformat(' ')

d = self.status._sendStartStatus('builder-name', self.build)
result = self.successResultOf(d)
Expand All @@ -244,7 +256,7 @@ def test_sendStartStatus_ok(self):
'state': 'pending',
'description': 'Build started.',
'builderName': 'builder-name',
'startDateTime': '1970-01-01 02:00:01',
'startDateTime': startDateTime,
'endDateTime': 'In progress',
'duration': 'In progress',
})
Expand Down Expand Up @@ -287,6 +299,8 @@ def test_sendFinishStatus_ok(self):
}
self.status._sendGitHubStatus = Mock(return_value=defer.succeed(None))
self.build.getTimes = lambda: (1, 3)
startDateTime = datetime.datetime.fromtimestamp(1).isoformat(' ')
endDateTime = datetime.datetime.fromtimestamp(3).isoformat(' ')

d = self.status._sendFinishStatus('builder-name', self.build, SUCCESS)
result = self.successResultOf(d)
Expand All @@ -302,8 +316,8 @@ def test_sendFinishStatus_ok(self):
'state': 'success',
'description': 'Build done.',
'builderName': 'builder-name',
'startDateTime': '1970-01-01 02:00:01',
'endDateTime': '1970-01-01 02:00:03',
'startDateTime': startDateTime,
'endDateTime': endDateTime,
'duration': '2 seconds',
})

Expand Down

0 comments on commit c50d244

Please sign in to comment.