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

Side by Side Diff: tests/mock_api.py

Issue 29355396: Issue 4380 - Add Mock Crowdin API and Sync Test (Closed)
Patch Set: Created Sept. 30, 2016, 7:20 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 from flask import Flask, send_from_directory, jsonify
Jon Sonesen 2016/09/30 07:35:11 I used this in order to keep the api code as light
2
3 app = Flask(__name__)
4
5
6 @app.route('/api/project/test/info', methods=['GET'])
7 def info():
8 return jsonify(
9 {
10 'languages': [
11 {
12 'name': 'German',
13 'code': 'de',
14 'can_translate': 1,
15 'can_approve': 1,
16
17 },
18 {
19 'name': 'English',
20 'code': 'en',
21 'can_translate': 1,
22 'can_approve': 1,
23
24 },
25
26 ],
27 'files': [
28 {
29 'node_type': 'directory',
30 'name': 'en',
31 'files': [
32 {
33 'node_type': 'file',
34 'name': 'translate.json',
35 'created': '2016-09-26 08:30:07',
36 'last_updated': '2016-09-26 08:30:08',
37 'last_accessed': None,
38 'last_revision': '1'
39 },
40 ]
41 },
42 {
43 'node_type': 'directory',
44 'name': 'de',
45 'files': [
46 {
47 'node_type': 'file',
48 'name': 'translate.json',
49 'created': '2016-09-26 08:30:07',
50 'last_updated': '2016-09-26 08:30:08',
51 'last_accessed': None,
52 'last_revision': '1'
53 }
54 ]
55 }
56 ]
57 }
58 )
59
60
61 @app.route('/api/project/test/supported-languages', methods=['GET'])
62 def supported_langs():
63 return jsonify(
64 [
65 {
66 'name': 'German',
67 'crowdin_code': 'de',
68 'editor_code': 'de',
69 'iso_639_1': 'de',
70 'iso_639_3': 'deu',
71 'locale': 'de-DE'
72 },
73 {
74 'name': 'English',
75 'crowdin_code': 'en',
76 'editor_code': 'en',
77 'iso_639_1': 'en',
78 'iso_639_3': 'eng',
79 'locale': 'en-US'
80 },
81 ]
82 )
83
84
85 @app.route('/api/project/test/add-file', methods=['POST'])
86 def add_file():
87 return jsonify()
88
89
90 @app.route('/api/project/test/upload-translation', methods=['POST'])
91 def upload_translation():
92 return jsonify()
93
94
95 @app.route('/api/project/test/delete-directory', methods=['POST'])
96 def delete_directory():
97 return jsonify()
98
99
100 @app.route('/api/project/test/delete-file', methods=['POST'])
101 def delete_file():
102 return jsonify()
103
104
105 @app.route('/api/project/test/export', methods=['GET'])
106 def export():
107 return jsonify(
108 {
109 'success': {
110 'status': 'skipped'
111 }
112 },
113 )
114
115
116 @app.route('/api/project/test/download/all.zip', methods=['GET'])
117 def get_zip():
118 return send_from_directory('', 'all.zip')
OLDNEW

Powered by Google App Engine
This is Rietveld