summaryrefslogtreecommitdiff
path: root/py-fake-service
diff options
context:
space:
mode:
authorBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-08-08 11:31:49 -0300
committerBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-08-08 11:32:02 -0300
commitd3a31756c17165d4685287868f53265e49762377 (patch)
tree67ad3b10f4e6dd4223a622121e76ef78ef476fb0 /py-fake-service
parentfa6561875f085cb60f6ba81e90e33ab59c6c553d (diff)
Creating the fake python service
Diffstat (limited to 'py-fake-service')
-rw-r--r--py-fake-service/app/__init__.py0
-rw-r--r--py-fake-service/app/pixelated_user_agent.py91
-rw-r--r--py-fake-service/config/pixelated_ua.cfg6
-rwxr-xr-xpy-fake-service/go6
4 files changed, 103 insertions, 0 deletions
diff --git a/py-fake-service/app/__init__.py b/py-fake-service/app/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/py-fake-service/app/__init__.py
diff --git a/py-fake-service/app/pixelated_user_agent.py b/py-fake-service/app/pixelated_user_agent.py
new file mode 100644
index 00000000..7cc49d48
--- /dev/null
+++ b/py-fake-service/app/pixelated_user_agent.py
@@ -0,0 +1,91 @@
+from flask import Flask, request, Response, redirect
+
+import json
+import datetime
+import requests
+
+app = Flask(__name__, static_url_path='', static_folder='../../web-ui/app')
+client = None
+converter = None
+account = None
+
+def respond_json(entity):
+ response = json.dumps(entity)
+ return Response(response=response, mimetype="application/json")
+
+
+@app.route('/mails', methods=['POST'])
+def save_draft_or_send():
+ return respond_json({'ident': 123})
+
+
+@app.route('/mails', methods=['PUT'])
+def update_draft():
+ return respond_json({'ident': 123})
+
+
+@app.route('/mails')
+def mails():
+ mails = []
+ response = {
+ "stats": {
+ "total": len(mails),
+ "read": 0,
+ "starred": 0,
+ "replied": 0
+ },
+ "mails": mails
+ }
+
+ return respond_json(response)
+
+
+@app.route('/mail/<mail_id>', methods=['DELETE'])
+def delete_mails(mail_id):
+ return respond_json(None)
+
+
+@app.route('/tags')
+def tags():
+ tags = []
+ return respond_json(tags)
+
+
+@app.route('/mail/<mail_id>')
+def mail(mail_id):
+ return respond_json({})
+
+
+@app.route('/mail/<mail_id>/tags')
+def mail_tags(mail_id):
+ return respond_json([])
+
+
+@app.route('/mail/<mail_id>/read', methods=['POST'])
+def mark_mail_as_read(mail_id):
+ return ""
+
+
+@app.route('/contacts')
+def contacts():
+ return respond_json({'contacts': []})
+
+
+@app.route('/draft_reply_for/<mail_id>')
+def draft_reply_for(mail_id):
+ return respond_json(None)
+
+
+@app.route('/')
+def index():
+ return app.send_static_file('index.html')
+
+def setup():
+ app.config.from_envvar('PIXELATED_UA_CFG')
+ provider = app.config['PROVIDER']
+ account = app.config['ACCOUNT']
+
+ app.run(host=app.config['HOST'], debug=app.config['DEBUG'], port=app.config['PORT'])
+
+if __name__ == '__main__':
+ setup()
diff --git a/py-fake-service/config/pixelated_ua.cfg b/py-fake-service/config/pixelated_ua.cfg
new file mode 100644
index 00000000..083e1dd4
--- /dev/null
+++ b/py-fake-service/config/pixelated_ua.cfg
@@ -0,0 +1,6 @@
+DEBUG=True
+HOST="0.0.0.0"
+ACCOUNT="pixelatedinboxapp@gmail.com"
+PROVIDER="inboxapp"
+PORT=3333
+
diff --git a/py-fake-service/go b/py-fake-service/go
new file mode 100755
index 00000000..d0d83096
--- /dev/null
+++ b/py-fake-service/go
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+from app.pixelated_user_agent import setup
+import os
+os.environ['PIXELATED_UA_CFG']='../config/pixelated_ua.cfg'
+setup()
+