def run( ): #Calls Script stream and the main function in it which starts the bot pre-processing stage stream.main()
def test_main(self): # It's easier to run a full integration test with stubbed-out # external interfaces and validate the trace than it is to test # each individual piece. # The components are mostly tested in make_*_test.py. db = model.Database(':memory:') fakesub = FakeSub([ [ ('a', Attrs({'eventType': 'OBJECT_DELETE'})), ], [ ('b', Attrs({ 'eventType': 'OBJECT_FINALIZE', 'objectId': 'logs/fake/123/finished.json', 'bucketId': 'kubernetes-jenkins' })), ], [], [ ('c', Attrs({ 'eventType': 'OBJECT_FINALIZE', 'objectId': 'logs/fake/123/finished.json', 'bucketId': 'kubernetes-jenkins' })), ], [], [ ('d', Attrs({ 'eventType': 'OBJECT_FINALIZE', 'objectId': 'logs/fake/124/started.json' })), ], [], ]) faketable = FakeTable('day', stream.load_schema(FakeSchemaField), fakesub.trace) tables = {'day': (faketable, 'incr')} stream.main(db, fakesub, tables, make_db_test.MockedClient, [1, 0, 0, 0].pop) # uncomment if the trace changes # import pprint; pprint.pprint(fakesub.trace) # self.maxDiff = 3000 now = make_db_test.MockedClient.NOW self.assertEqual( fakesub.trace, [['pull', False], ['pull', True], ['pull', True], ['ack', ['a']], ['modify-ack', ['b'], 180], ['ack', ['b']], [ 'insert-data', ([[ 5, now - 5, now, True, u'SUCCESS', None, u'gs://kubernetes-jenkins/logs/fake/123', u'fake', 123, [], [{ 'name': 'Foo', 'time': 3.0 }, { 'failed': True, 'failure_text': 'stacktrace', 'name': 'Bad', 'time': 4.0 }], 2, 1, None ]], [1]), { 'skip_invalid_rows': True } ], ['pull', False], ['pull', True], ['modify-ack', ['c'], 180], ['ack', ['c']], ['pull', False], ['pull', True], ['ack', ['d']]])
def test_main(self): # It's easier to run a full integration test with stubbed-out # external interfaces and validate the trace than it is to test # each individual piece. # The components are mostly tested in make_*_test.py. db = model.Database(':memory:') fake_sub = FakeSub([ FakePullResponse([ FakeReceivedMessage( 'b', FakePubSubMessage( 'no_data', { 'eventType': 'OBJECT_FINALIZE', 'objectId': 'logs/fake/123/finished.json', 'bucketId': 'kubernetes-jenkins' })) ]), FakePullResponse([]), FakePullResponse([ FakeReceivedMessage( 'c', FakePubSubMessage( 'no_data', { 'eventType': 'OBJECT_FINALIZE', 'objectId': 'logs/fake/123/finished.json', 'bucketId': 'kubernetes-jenkins' })) ]), FakePullResponse([]), FakePullResponse([ FakeReceivedMessage( 'd', FakePubSubMessage( 'no_data', { 'eventType': 'OBJECT_FINALIZE', 'objectId': 'logs/fake/124/started.json', 'bucketId': 'kubernetes-jenkins' })) ]), FakePullResponse([]), ]) fake_client = FakeClient() fake_table = FakeTable('day', stream.load_schema(FakeSchemaField)) fake_sub_path = 'projects/{project_id}/subscriptions/{sub}' tables = {'day': (fake_table, 'incr')} stream.main(db, fake_sub, fake_sub_path, fake_client, tables, self.fake_buckets, make_db_test.MockedClient, [1, 0, 0, 0].pop) # uncomment if the trace changes # import pprint; pprint.pprint(fake_sub.trace) # import pprint; pprint.pprint(fake_client.trace) # self.maxDiff = 3000 now = make_db_test.MockedClient.NOW self.assertEqual( fake_sub.trace, [['pull', fake_sub_path, False], ['pull', fake_sub_path, True], ['modify-ack', fake_sub_path, ['b'], 180], ['ack', fake_sub_path, ['b']], ['pull', fake_sub_path, False], ['pull', fake_sub_path, True], ['modify-ack', fake_sub_path, ['c'], 180], ['ack', fake_sub_path, ['c']], ['pull', fake_sub_path, False], ['pull', fake_sub_path, True], ['ack', fake_sub_path, ['d']]]) self.assertEqual(fake_client.trace, [[ 'insert-rows', ([{ 'elapsed': 5, 'finished': now, 'job': 'fake', 'number': 123, 'passed': True, 'path': 'gs://kubernetes-jenkins/logs/fake/123', 'result': 'SUCCESS', 'started': now - 5, 'test': [{ 'name': 'Foo', 'time': 3.0 }, { 'failed': True, 'failure_text': 'stacktrace', 'name': 'Bad', 'time': 4.0 }], 'tests_failed': 1, 'tests_run': 2 }], ), { 'skip_invalid_rows': True } ]])
def test_main(self): # It's easier to run a full integration test with stubbed-out # external interfaces and validate the trace than it is to test # each individual piece. # The components are mostly tested in make_*_test.py. db = model.Database(':memory:') fakesub = FakeSub([ [ ('a', Attrs({'eventType': 'OBJECT_DELETE'})), ], [ ('b', Attrs({ 'eventType': 'OBJECT_FINALIZE', 'objectId': 'logs/fake/123/finished.json', 'bucketId': 'kubernetes-jenkins'})), ], [], [ ('c', Attrs({ 'eventType': 'OBJECT_FINALIZE', 'objectId': 'logs/fake/123/finished.json', 'bucketId': 'kubernetes-jenkins'})), ], [], [ ('d', Attrs({ 'eventType': 'OBJECT_FINALIZE', 'objectId': 'logs/fake/124/started.json'})), ], [], ]) faketable = FakeTable('day', stream.load_schema(FakeSchemaField), fakesub.trace) tables = {'day': (faketable, 'incr')} stream.main( db, fakesub, tables, make_db_test.MockedClient, [1, 0, 0, 0].pop) # uncomment if the trace changes # import pprint; pprint.pprint(fakesub.trace) # self.maxDiff = 3000 now = make_db_test.MockedClient.NOW self.assertEqual( fakesub.trace, [['pull', False], ['pull', True], ['pull', True], ['ack', ['a']], ['modify-ack', ['b'], 180], ['ack', ['b']], ['insert-data', ([[5, now - 5, now, True, u'SUCCESS', None, u'gs://kubernetes-jenkins/logs/fake/123', u'fake', 123, [], [{'name': 'Foo', 'time': 3.0}, {'failed': True, 'failure_text': 'stacktrace', 'name': 'Bad', 'time': 4.0}], 2, 1, None]], [1]), {'skip_invalid_rows': True}], ['pull', False], ['pull', True], ['modify-ack', ['c'], 180], ['ack', ['c']], ['pull', False], ['pull', True], ['ack', ['d']]])
# -*- coding: utf-8 -*- from apscheduler.schedulers.blocking import BlockingScheduler import auto_follow import regular_tweet import stream schedule = BlockingScheduler() @schedule.scheduled_job('interval', seconds=70) def timed_auto_follow(): auto_follow.main() @schedule.scheduled_job( 'cron', hour='0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23') def timed_regular_tweet(): regular_tweet.main() # @schedule.scheduled_job('interval', seconds=70) # def timed_regular_tweet(): # regular_tweet.regular_tweet() if __name__ == '__main__': stream.main() schedule.start()