def test_run(fs_mock, ts_mock, yt_mock, tmp_path, fix_run_tasks, fix_run_results, fix_auth_token, fix_yt_empty_resp, fix_yt_valid_resp): fs_mock.side_effect = ['19800101_000000', '19800101_010000'] ts_mock.return_value = '1980-01-01T00:00:00Z' yt_mock.side_effect = [fix_yt_empty_resp, fix_yt_empty_resp, fix_yt_valid_resp, fix_yt_valid_resp] dir_work_data = tmp_path / 'data' dir_work_data.mkdir() config = { 'api_poll_int': 0, 'dir_work_data': dir_work_data, 'file_task_queue': tmp_path / 'task.queue', 'file_token': tmp_path / 'token.pkl' } with config['file_token'].open('wb') as fd_out: pickle.dump(fix_auth_token, fd_out) with patch.dict(settings.config, config): api.run(fix_run_tasks) results = [] with config['file_task_queue'].open() as fd_in: for line in fd_in: results.append(json.loads(line)) assert fix_run_results == results assert (config['dir_work_data'] / '19800101_000000_result.json').is_file() assert (config['dir_work_data'] / '19800101_010000_result.json').is_file()
#!python from app import api if __name__ == '__main__': api.run()
from app import api if __name__ == '__main__': api.run(debug=True)
from app import api if __name__ == '__main__': api.run(host="localhost", port=9000, debug=True)
#!/usr/bin/env python from app import api if __name__ == '__main__': api.run(host='0.0.0.0', port=5000, debug=True)
# -*- coding: utf-8 -*- from app import api if __name__ == '__main__': api.run()
#!.env/bin/python import os from app import api if __name__ == "__main__": api.run(host="0.0.0.0", port=5580, debug=True)
__author__ = 'Xiongc2' #!bin/python3.6 from app import api, blueprint if __name__ == '__main__': api.run(host='127.0.0.1', port=80, debug=True, threaded=True)