2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
14 <rappor-configuration>
17 <rappor-parameter-types>
20 <rappor-parameters name="TEST_RAPPOR_TYPE">
24 <parameters num-cohorts="128" bytes="1" hash-functions="2" fake-prob="0.5"
25 fake-one-prob="0.5" one-coin-prob="0.75" zero-coin-prob="0.25"
26 reporting-level="COARSE"/>
29 </rappor-parameter-types>
34 <rappor-metric name="Test.Rappor.Metric" type="TEST_RAPPOR_TYPE">
35 <owner>user1@chromium.org</owner>
36 <owner>user2@chromium.org</owner>
38 A fake metric summary.
44 </rappor-configuration>
49 'name': 'Test.Rappor.Metric',
50 'type': 'TEST_RAPPOR_TYPE',
51 'owners': ['user1@chromium.org', 'user2@chromium.org'],
52 'summary': 'A fake metric summary.',
56 class ActionXmlTest(unittest
.TestCase
):
58 def testIsPretty(self
):
59 result
= pretty_print
.UpdateXML(PRETTY_XML
)
60 self
.assertEqual(PRETTY_XML
, result
)
62 def testParsing(self
):
63 comments
, config
= pretty_print
.RAPPOR_XML_TYPE
.Parse(PRETTY_XML
)
64 self
.assertEqual(BASIC_METRIC
, config
['metrics']['metrics'][0])
65 self
.assertEqual(set(['TEST_RAPPOR_TYPE']),
66 pretty_print
.GetTypeNames(config
))
68 def testMissingOwners(self
):
69 self
.assertFalse(pretty_print
.HasMissingOwners([BASIC_METRIC
]))
70 no_owners
= BASIC_METRIC
.copy()
71 no_owners
['owners'] = []
72 self
.assertTrue(pretty_print
.HasMissingOwners([no_owners
]))
74 def testInvalidTypes(self
):
75 self
.assertFalse(pretty_print
.HasInvalidTypes(
76 set(['TEST_RAPPOR_TYPE']), [BASIC_METRIC
]))
77 self
.assertTrue(pretty_print
.HasInvalidTypes(
78 set(['OTHER_TYPE']), [BASIC_METRIC
]))
81 if __name__
== '__main__':