Moved Subversion stuff to its own module, and unified push & pull approaches

This commit is contained in:
2016-11-01 11:58:12 +01:00
parent b8d12d1a4d
commit bc58b6d5ac
7 changed files with 198 additions and 114 deletions

View File

@@ -1,3 +1,5 @@
# -*- coding=utf-8 -*-
"""Unit test for SVN interface."""
from __future__ import absolute_import
@@ -97,6 +99,7 @@ class TestCommitLogObserver(unittest.TestCase):
self.observer.fetch_and_observe()
self.mock_client.log_default.assert_called_with(revision_from=43)
self.assertEqual(self.observer.last_seen_revision, 46)
self.observer.fetch_and_observe()
self.mock_client.log_default.assert_called_with(revision_from=47)
@@ -117,11 +120,11 @@ class TestCommitLogObserver(unittest.TestCase):
self.observer.fetch_and_observe()
self.assertEqual(3, len(blinks))
self.assertEqual({'log_entry': SVN_LOG_BATCH_WITH_TASK_MARKERS[1], 'task_id': 'T1234'},
self.assertEqual({'log_entry': SVN_LOG_BATCH_WITH_TASK_MARKERS[1], 'shortcode': '1234'},
blinks[0])
self.assertEqual({'log_entry': SVN_LOG_BATCH_WITH_TASK_MARKERS[2], 'task_id': 'T4415'},
self.assertEqual({'log_entry': SVN_LOG_BATCH_WITH_TASK_MARKERS[2], 'shortcode': '4415'},
blinks[1])
self.assertEqual({'log_entry': SVN_LOG_BATCH_WITH_TASK_MARKERS[2], 'task_id': 'T4433'},
self.assertEqual({'log_entry': SVN_LOG_BATCH_WITH_TASK_MARKERS[2], 'shortcode': '4433'},
blinks[2])
def test_svn_error(self):
@@ -138,3 +141,49 @@ class TestCommitLogObserver(unittest.TestCase):
record_blink.assert_not_called()
self.mock_client.log_default.assert_called_once()
def test_create_log_entry(self):
entry = subversion.create_log_entry(date_text=u'2016-10-21 17:40:17 +0200',
msg=u'Ünicøde is good',
revision='123',
author=u'børk',
changelist='nothing')
self.assertEqual(tuple(entry), (
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
u'Ünicøde is good',
'123',
u'børk',
'nothing'
))
self.assertRaises(ValueError, subversion.create_log_entry,
date_text='Unparseable date',
msg=u'Ünicøde is good',
revision='123',
author=u'børk',
changelist='nothing')
entry = subversion.create_log_entry(date_text=u'2016-10-21 17:40:17 +0200',
msg=u'Ünicøde is good',
revision='123',
author=u'børk')
self.assertEqual(tuple(entry), (
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
u'Ünicøde is good',
'123',
u'børk',
None
))
entry = subversion.create_log_entry(
date=datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
msg=u'Ünicøde is good',
revision='123',
author=u'børk')
self.assertEqual(tuple(entry), (
datetime.datetime(2016, 10, 21, 15, 40, 17, 0, tzinfo=tzutc()),
u'Ünicøde is good',
'123',
u'børk',
None
))