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

Side by Side Diff: unittests/args_test.py

Issue 2237593002: Add support for operational arguments protobuf. (Closed) Base URL: https://github.com/luci/recipes-py@proto3-release
Patch Set: Better protobuf comments. Created 4 years, 4 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
« recipes.py ('K') | « 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
martiniss 2016/08/10 21:38:25 Could you rename this file to be unittests/recipes
dnj 2016/08/10 22:04:41 Okay.
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': {'properties': {
31 'property': {
32 'foo': {'s': 'FOO!'},
33 'bar': {'properties': {
34 'property': {
35 'baz': {'s': 'BAZ!'},
36 },
37 }},
38 }},
39 },
40 }},
41 'annotationFlags': {
42 'emitTimestamp': True,
43 },
44 }), arguments_pb2.Arguments())
45
46 self.assertEqual(
47 recipes._op_properties_to_dict(op_args.properties.property),
48 {
49 u'a': u'Hello',
50 u'b': -12345L,
51 u'c': 12345L,
52 u'd': 3.14159,
53 u'e': True,
54 u'f': '\x60\x0d\xd0\x65',
55 u'g': {
56 u'foo': u'FOO!',
57 u'bar': {
58 u'baz': u'BAZ!',
59 },
60 },
61 })
62
63
64 if __name__ == '__main__':
65 result = unittest.main()
OLDNEW
« recipes.py ('K') | « recipes.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698