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 usergroup_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 usergroup_pb2 |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 14 | |
| 15 | |
| 16 | class UserGroupPb2Test(unittest.TestCase): |
| 17 | |
| 18 | def testMakeSettings_Defaults(self): |
| 19 | usergroup = usergroup_pb2.MakeSettings('anyone') |
| 20 | self.assertEqual( |
| 21 | usergroup_pb2.MemberVisibility.ANYONE, |
| 22 | usergroup.who_can_view_members) |
| 23 | self.assertIsNone(usergroup.ext_group_type) |
| 24 | self.assertEqual(0, usergroup.last_sync_time) |
| 25 | self.assertEqual([], usergroup.friend_projects) |
| 26 | |
| 27 | def testMakeSettings_Everything(self): |
| 28 | usergroup = usergroup_pb2.MakeSettings( |
| 29 | 'Members', ext_group_type_str='mdb', |
| 30 | last_sync_time=1234567890, friend_projects=[789]) |
| 31 | self.assertEqual( |
| 32 | usergroup_pb2.MemberVisibility.MEMBERS, |
| 33 | usergroup.who_can_view_members) |
| 34 | self.assertEqual(usergroup_pb2.GroupType.MDB, usergroup.ext_group_type) |
| 35 | self.assertEqual(1234567890, usergroup.last_sync_time) |
| 36 | self.assertEqual([789], usergroup.friend_projects) |