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