Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame^] | 1 | # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style |
| 3 | # license that can be found in the LICENSE file or at |
| 4 | # https://developers.google.com/open-source/licenses/bsd |
| 5 | |
| 6 | """Tests for features_pb2 functions.""" |
| 7 | |
| 8 | from __future__ import print_function |
| 9 | from __future__ import division |
| 10 | from __future__ import absolute_import |
| 11 | |
| 12 | import unittest |
| 13 | |
| 14 | from proto import features_pb2 |
| 15 | |
| 16 | |
| 17 | class FeaturesPb2Test(unittest.TestCase): |
| 18 | |
| 19 | def testMakeHotlist_Defaults(self): |
| 20 | hotlist = features_pb2.MakeHotlist('summer-issues') |
| 21 | self.assertEqual('summer-issues', hotlist.name) |
| 22 | self.assertEqual([], hotlist.items) |
| 23 | |
| 24 | def testMakeHotlist_Everything(self): |
| 25 | ts = 20011111111111 |
| 26 | hotlist = features_pb2.MakeHotlist( |
| 27 | 'summer-issues', [(1000, 1, 444, ts, ''), (1001, 2, 333, ts, ''), |
| 28 | (1009, None, None, ts, '')], |
| 29 | description='desc') |
| 30 | self.assertEqual('summer-issues', hotlist.name) |
| 31 | self.assertEqual( |
| 32 | [features_pb2.MakeHotlistItem( |
| 33 | 1000, rank=1, adder_id=444, date_added=ts, note=''), |
| 34 | features_pb2.MakeHotlistItem( |
| 35 | 1001, rank=2, adder_id=333, date_added=ts, note=''), |
| 36 | features_pb2.MakeHotlistItem(1009, date_added=ts, note=''), |
| 37 | ], |
| 38 | hotlist.items) |
| 39 | self.assertEqual('desc', hotlist.description) |
| 40 | |
| 41 | def testMakeHotlistItem(self): |
| 42 | ts = 20011111111111 |
| 43 | item_1 = features_pb2.MakeHotlistItem( |
| 44 | 1000, rank=1, adder_id=111, date_added=ts, note='short note') |
| 45 | self.assertEqual(1000, item_1.issue_id) |
| 46 | self.assertEqual(1, item_1.rank) |
| 47 | self.assertEqual(111, item_1.adder_id) |
| 48 | self.assertEqual(ts, item_1.date_added) |
| 49 | self.assertEqual('short note', item_1.note) |
| 50 | |
| 51 | item_2 = features_pb2.MakeHotlistItem(1001) |
| 52 | self.assertEqual(1001, item_2.issue_id) |
| 53 | self.assertEqual(None, item_2.rank) |
| 54 | self.assertEqual(None, item_2.adder_id) |
| 55 | self.assertEqual('', item_2.note) |
| 56 | self.assertEqual(features_pb2.ADDED_TS_FEATURE_LAUNCH_TS, item_2.date_added) |