Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: tests/crowdin_mock_api.py

Issue 29355396: Issue 4380 - Add Mock Crowdin API and Sync Test (Closed)
Left Patch Set: Add basic assertion for sync test Created Oct. 5, 2016, 3:50 a.m.
Right Patch Set: formatting fix Created Oct. 25, 2016, 8:15 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « tests/conftest.py ('k') | tests/expected_output/translate » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 from flask import Flask, send_from_directory, jsonify, request
2
3 app = Flask(__name__)
4 app.request_log = []
5
6
7 @app.before_request
8 def log_request_info():
9 log = (request.url, str(request.get_data()))
10 app.request_log.append(log)
11
12
13 @app.route('/api/project/test/info', methods=['GET'])
14 def info():
15 return jsonify(
16 {
17 'languages': [
18 {
19 'name': 'German',
20 'code': 'de',
21 'can_translate': 1,
22 'can_approve': 1,
23
24 },
25 {
26 'name': 'English',
27 'code': 'en',
28 'can_translate': 1,
29 'can_approve': 1,
30
31 },
32
33 ],
34 'files': [
35 {
36 'node_type': 'directory',
37 'name': 'en',
38 'files': [
39 {
40 'node_type': 'file',
41 'name': 'translate.json',
42 'created': '2016-09-26 08:30:07',
43 'last_updated': '2016-09-26 08:30:08',
44 'last_accessed': None,
45 'last_revision': '1'
46 },
47 ]
48 },
49 {
50 'node_type': 'directory',
51 'name': 'de',
52 'files': [
53 {
54 'node_type': 'file',
55 'name': 'translate.json',
56 'created': '2016-09-26 08:30:07',
57 'last_updated': '2016-09-26 08:30:08',
58 'last_accessed': None,
59 'last_revision': '1'
60 }
61 ]
62 }
63 ]
64 }
65 )
66
67
68 @app.route('/api/project/test/supported-languages', methods=['GET'])
69 def supported_langs():
70 return jsonify(
71 [
72 {
73 'name': 'German',
74 'crowdin_code': 'de',
75 'editor_code': 'de',
76 'iso_639_1': 'de',
77 'iso_639_3': 'deu',
78 'locale': 'de-DE'
79 },
80 {
81 'name': 'English',
82 'crowdin_code': 'en',
83 'editor_code': 'en',
84 'iso_639_1': 'en',
85 'iso_639_3': 'eng',
86 'locale': 'en-US'
87 },
88 ]
89 )
90
91
92 @app.route('/api/project/test/add-file', methods=['POST'])
93 def add_file():
94 app.string = request.get_data()
95 return jsonify()
96
97
98 @app.route('/api/project/test/upload-translation', methods=['POST'])
99 def upload_translation():
100 return jsonify()
101
102
103 @app.route('/api/project/test/delete-directory', methods=['POST'])
104 def delete_directory():
105 return jsonify()
106
107
108 @app.route('/api/project/test/delete-file', methods=['POST'])
109 def delete_file():
110 return jsonify()
111
112
113 @app.route('/api/project/test/export', methods=['GET'])
114 def export():
115 return jsonify({'success': {'status': 'skipped'}})
116
117
118 @app.route('/api/project/test/download/all.zip', methods=['GET'])
119 def get_zip():
120 return send_from_directory('', 'all.zip')
LEFTRIGHT

Powered by Google App Engine
This is Rietveld