(test_config=None)
| 5 | |
| 6 | |
| 7 | def create_app(test_config=None): |
| 8 | app = flask.Flask(__name__) |
| 9 | |
| 10 | @app.route("/api/repos/<github_user>/<github_repo>/contents/") |
| 11 | def github_plugins_repo_api(github_user, github_repo): |
| 12 | '''This emulates api.github.com calls to lightningd/plugins''' |
| 13 | user = escape(github_user) |
| 14 | repo = escape(github_repo) |
| 15 | canned_api = os.environ.get('REDIR_GITHUB') + f'/rkls_api_{user}_{repo}.json' |
| 16 | with open(canned_api, 'rb') as f: |
| 17 | canned_data = f.read(-1) |
| 18 | print(f'serving canned api data from {canned_api}') |
| 19 | resp = flask.Response(response=canned_data, |
| 20 | headers={'Content-Type': 'application/json; charset=utf-8'}) |
| 21 | return resp |
| 22 | |
| 23 | @app.route("/api/repos/<github_user>/<github_repo>/git/trees/<plugin_name>") |
| 24 | def github_plugin_tree_api(github_user, github_repo, plugin_name): |
| 25 | dir_json = \ |
| 26 | { |
| 27 | "url": f"https://api.github.com/repos/{github_user}/{github_repo}/git/trees/{plugin_name}", |
| 28 | "tree": [] |
| 29 | } |
| 30 | # FIXME: Pull contents from directory |
| 31 | for file in os.listdir(f'tests/data/recklessrepo/{github_user}/{plugin_name}'): |
| 32 | dir_json["tree"].append({"path": file}) |
| 33 | resp = flask.Response(response=json.dumps(dir_json), |
| 34 | headers={'Content-Type': 'application/json; charset=utf-8'}) |
| 35 | return resp |
| 36 | |
| 37 | return app |
| 38 | |
| 39 | |
| 40 | if __name__ == '__main__': |
no outgoing calls
no test coverage detected