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 project_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 project_pb2 |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 14 | |
| 15 | |
| 16 | class ProjectPb2Test(unittest.TestCase): |
| 17 | |
| 18 | def testMakeProject_Defaults(self): |
| 19 | project = project_pb2.MakeProject('proj') |
| 20 | self.assertEqual('proj', project.project_name) |
| 21 | self.assertEqual(project_pb2.ProjectState.LIVE, project.state) |
| 22 | self.assertEqual(project_pb2.ProjectAccess.ANYONE, project.access) |
| 23 | self.assertFalse(project.read_only_reason) |
| 24 | |
| 25 | def testMakeProject_Everything(self): |
| 26 | project = project_pb2.MakeProject( |
| 27 | 'proj', project_id=789, state=project_pb2.ProjectState.ARCHIVED, |
| 28 | access=project_pb2.ProjectAccess.MEMBERS_ONLY, summary='sum', |
| 29 | description='desc', moved_to='example.com', |
| 30 | cached_content_timestamp=1234567890, owner_ids=[111], |
| 31 | committer_ids=[222], contributor_ids=[333], |
| 32 | read_only_reason='being migrated', |
| 33 | home_page='example.com', docs_url='example.com/docs', |
| 34 | source_url='example.com/src', logo_gcs_id='logo_id', |
| 35 | logo_file_name='logo.gif') |
| 36 | self.assertEqual('proj', project.project_name) |
| 37 | self.assertEqual(789, project.project_id) |
| 38 | self.assertEqual(project_pb2.ProjectState.ARCHIVED, project.state) |
| 39 | self.assertEqual(project_pb2.ProjectAccess.MEMBERS_ONLY, project.access) |
| 40 | self.assertEqual('sum', project.summary) |
| 41 | self.assertEqual('desc', project.description) |
| 42 | self.assertEqual('example.com', project.moved_to) |
| 43 | self.assertEqual(1234567890, project.cached_content_timestamp) |
| 44 | self.assertEqual([111], project.owner_ids) |
| 45 | self.assertEqual([222], project.committer_ids) |
| 46 | self.assertEqual([333], project.contributor_ids) |
| 47 | self.assertEqual('being migrated', project.read_only_reason) |
| 48 | self.assertEqual('example.com', project.home_page) |
| 49 | self.assertEqual('example.com/docs', project.docs_url) |
| 50 | self.assertEqual('example.com/src', project.source_url) |
| 51 | self.assertEqual('logo_id', project.logo_gcs_id) |
| 52 | self.assertEqual('logo.gif', project.logo_file_name) |