class TestGetText(unittest.TestCase): def setUp(self): self.message = ServerErrorMessage(API_RECORD) def test_call(self): self.assertEqual( self.message.get_text(), 'Server error [magazine_assets#cover]' )
def main(): arg_parser = init_arg_parser() args = arg_parser.parse_args() begin_time = datetime.strptime(args.begin, '%Y-%m-%dT%H:%M:%S') end_time = datetime.strptime(args.end, '%Y-%m-%dT%H:%M:%S') api_records = query_server_error_records(begin_time, end_time) if not api_records: return for api_record in api_records: ServerErrorMessage(api_record).post()
class TestGetAttachments(unittest.TestCase): def setUp(self): self.message = ServerErrorMessage(API_RECORD) def test_call(self): self.assertEqual( self.message.get_attachments(), [ { 'fallback': ( '2015-12-09T09:40:01.558972Z 500 500 ' 'GET /KPI2/magazines/565fac8a6b1ee/cover/medium' ), 'color': 'danger', 'text': API_RECORD['message'] } ] )
def setUp(self): self.message = ServerErrorMessage(API_RECORD)