def test_tbr_reviewer_nobody_on_rotation(self): host = MockHost() yesterday = (datetime.date.fromtimestamp(host.time()) - datetime.timedelta(days=1)).isoformat() host.web.urls[ROTATIONS_URL] = json.dumps({ 'calendar': [ { 'date': yesterday, 'participants': [['some-sheriff']], }, ], 'rotations': ['ecosystem_infra'] }) importer = TestImporter(host) self.assertEqual('qyearsley', importer.tbr_reviewer()) self.assertLog([]) today = datetime.date.fromtimestamp(host.time()).isoformat() host.web.urls[ROTATIONS_URL] = json.dumps({ 'calendar': [ { 'date': today, 'participants': [[''], ['some-sheriff']], }, ], 'rotations': ['ecosystem_infra', 'other-rotation'] }) self.assertEqual('qyearsley', importer.tbr_reviewer()) self.assertLog([])
def test_tbr_reviewer_date_not_found(self): host = MockHost() yesterday = (datetime.date.fromtimestamp(host.time()) - datetime.timedelta(days=1)).isoformat() host.web.urls[ROTATIONS_URL] = json.dumps({ 'calendar': [ { 'date': yesterday, 'participants': [['some-sheriff'], ['other-sheriff']], }, ], 'rotations': ['ecosystem_infra', 'other_rotation'] }) importer = TestImporter(host) self.assertEqual(TBR_FALLBACK, importer.tbr_reviewer()) # Use a variable here, otherwise we get different values depending on # the machine's time zone settings (e.g. "1969-12-31" vs "1970-01-01"). today = datetime.date.fromtimestamp(host.time()).isoformat() self.assertLog([ 'ERROR: No entry found for date %s in rotations table.\n' % today ])
def test_tbr_reviewer_with_full_email_address(self): host = MockHost() today = datetime.date.fromtimestamp(host.time()).isoformat() host.web.urls[ROTATIONS_URL] = json.dumps({ 'calendar': [ { 'date': today, 'participants': [['*****@*****.**']], }, ], 'rotations': ['ecosystem_infra'] }) importer = TestImporter(host) self.assertEqual('*****@*****.**', importer.tbr_reviewer()) self.assertLog([])
def test_tbr_reviewer_nobody_on_rotation(self): host = MockHost() today = datetime.date.fromtimestamp(host.time()).isoformat() host.web.urls[ROTATIONS_URL] = json.dumps({ 'calendar': [ { 'date': today, 'participants': [[], ['some-sheriff']], }, ], 'rotations': ['ecosystem_infra', 'other-rotation'] }) importer = TestImporter(host) self.assertEqual(TBR_FALLBACK, importer.tbr_reviewer()) self.assertLog(['INFO: No sheriff today.\n'])
def test_tbr_reviewer_date_not_found(self): host = MockHost() yesterday = (datetime.date.fromtimestamp(host.time()) - datetime.timedelta(days=1)).isoformat() host.web.urls[ROTATIONS_URL] = json.dumps({ 'calendar': [ { 'date': yesterday, 'participants': [['some-sheriff'], ['other-sheriff']], }, ], 'rotations': ['ecosystem_infra', 'other_rotation'] }) importer = TestImporter(host) self.assertEqual(TBR_FALLBACK, importer.tbr_reviewer()) self.assertLog([ 'ERROR: No entry found for date 1969-12-31 in rotations table.\n' ])
def test_tbr_reviewer(self): host = MockHost() today = datetime.date.fromtimestamp(host.time()).isoformat() host.web.urls[ROTATIONS_URL] = json.dumps({ 'calendar': [ { 'date': '2017-01-01', 'participants': [['other-sheriff'], ['last-sheriff']], }, { 'date': today, 'participants': [['other-sheriff'], ['current-sheriff']], }, ], 'rotations': ['other-rotation', 'ecosystem_infra'] }) importer = TestImporter(host) self.assertEqual('current-sheriff', importer.tbr_reviewer()) self.assertLog([])