Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: unittests/recipes_py_test.py

Issue 2846703003: [recipes.py] move run arg parsing to its module. (Closed)
Patch Set: fix nits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « recipes.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2016 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file.
5
6 import base64
7 import json
8 import unittest
9
10 import repo_test_util
11
12 import recipes
13 from recipe_engine import arguments_pb2
14 from google.protobuf import json_format as jsonpb
15
16
17 class TestOperationalArgs(unittest.TestCase):
18
19 def test_operational_arg_parsing(self):
20 # For convenience, we'll define the JSONPB data as a Python dict that we
21 # will then dump into JSON.
22 op_args = jsonpb.Parse(json.dumps({
23 'properties': {'property': {
24 'a': {'s': 'Hello'},
25 'b': {'int': -12345},
26 'c': {'uint': 12345},
27 'd': {'d': 3.14159},
28 'e': {'b': True},
29 'f': {'data': base64.b64encode('\x60\x0d\xd0\x65')},
30 'g': {'map': {
31 'property': {
32 'foo': {'s': 'FOO!'},
33 'bar': {'map': {
34 'property': {
35 'baz': {'s': 'BAZ!'},
36 },
37 }},
38 }},
39 },
40 'h': {'list': {
41 'property': [
42 {'s': 'foo'},
43 {'s': 'bar'},
44 {'s': 'baz'},
45 ],
46 }},
47 }},
48 'annotationFlags': {
49 'emitTimestamp': True,
50 },
51 }), arguments_pb2.Arguments())
52
53 self.assertEqual(
54 recipes._op_properties_to_dict(op_args.properties.property),
55 {
56 u'a': u'Hello',
57 u'b': -12345L,
58 u'c': 12345L,
59 u'd': 3.14159,
60 u'e': True,
61 u'f': '\x60\x0d\xd0\x65',
62 u'g': {
63 u'foo': u'FOO!',
64 u'bar': {
65 u'baz': u'BAZ!',
66 },
67 },
68 u'h': [
69 u'foo',
70 u'bar',
71 u'baz',
72 ],
73 })
74
75
76 if __name__ == '__main__':
77 result = unittest.main()
OLDNEW
« no previous file with comments | « recipes.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698