diff options
-rw-r--r-- | scripts/sync_package_status.py | 5 | ||||
-rw-r--r-- | scripts/sync_package_status_unittest.py | 21 |
2 files changed, 21 insertions, 5 deletions
diff --git a/scripts/sync_package_status.py b/scripts/sync_package_status.py index 539240f37..8fec499e9 100644 --- a/scripts/sync_package_status.py +++ b/scripts/sync_package_status.py @@ -154,8 +154,9 @@ class Syncer(object): def Sync(self): """Do synchronization between Spreadsheet and Tracker.""" - - self.tracker_col_ix = self.scomm.GetColumnIndex('Tracker') + self.tracker_col_ix = self.scomm.GetColumnIndex(COL_TRACKER) + if None is self.tracker_col_ix: + raise SyncError('Unable to find "Tracker" column in spreadsheet') errors = [] diff --git a/scripts/sync_package_status_unittest.py b/scripts/sync_package_status_unittest.py index 5e3ab2091..963c439b6 100644 --- a/scripts/sync_package_status_unittest.py +++ b/scripts/sync_package_status_unittest.py @@ -204,6 +204,21 @@ class SyncerTest(test_lib.MoxTestCase): self.assertEquals(test['result'], result, msg) self.mox.VerifyAll() + def testSyncMissingTrackerColumn(self): + mocked_syncer = self.mox.CreateMock(sps.Syncer) + mocked_scomm = self.mox.CreateMock(gdata_lib.SpreadsheetComm) + mocked_tcomm = self.mox.CreateMock(gdata_lib.TrackerComm) + mocked_syncer.scomm = mocked_scomm + mocked_syncer.tcomm = mocked_tcomm + + # Replay script + mocked_scomm.GetColumnIndex(sps.COL_TRACKER).AndReturn(None) + self.mox.ReplayAll() + + # Verify + self.assertRaises(sps.SyncError, sps.Syncer.Sync, mocked_syncer) + self.mox.VerifyAll() + def testSyncNewIssues(self): mocked_syncer = self.mox.CreateMock(sps.Syncer) mocked_scomm = self.mox.CreateMock(gdata_lib.SpreadsheetComm) @@ -217,7 +232,7 @@ class SyncerTest(test_lib.MoxTestCase): ] # Replay script - mocked_scomm.GetColumnIndex('Tracker') + mocked_scomm.GetColumnIndex(sps.COL_TRACKER).AndReturn(1) # Any index ok. mocked_scomm.GetRows().AndReturn(rows) for ix in xrange(len(rows)): @@ -244,7 +259,7 @@ class SyncerTest(test_lib.MoxTestCase): ] # Replay script - mocked_scomm.GetColumnIndex('Tracker') + mocked_scomm.GetColumnIndex(sps.COL_TRACKER).AndReturn(1) # Any index ok. mocked_scomm.GetRows().AndReturn(rows) for ix in xrange(len(rows)): @@ -271,7 +286,7 @@ class SyncerTest(test_lib.MoxTestCase): ] # Replay script - mocked_scomm.GetColumnIndex('Tracker') + mocked_scomm.GetColumnIndex(sps.COL_TRACKER).AndReturn(1) # Any index ok. mocked_scomm.GetRows().AndReturn(rows) for ix in xrange(len(rows)): |