blob: 1fa099d819b128e0ac9748d433f257aabdaaf6fd [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# 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 project_pb2 functions."""
7
8from __future__ import print_function
9from __future__ import division
10from __future__ import absolute_import
11
12import unittest
13
14from proto import project_pb2
15
16
17class ProjectPb2Test(unittest.TestCase):
18
19 def testMakeProject_Defaults(self):
20 project = project_pb2.MakeProject('proj')
21 self.assertEqual('proj', project.project_name)
22 self.assertEqual(project_pb2.ProjectState.LIVE, project.state)
23 self.assertEqual(project_pb2.ProjectAccess.ANYONE, project.access)
24 self.assertFalse(project.read_only_reason)
25
26 def testMakeProject_Everything(self):
27 project = project_pb2.MakeProject(
28 'proj', project_id=789, state=project_pb2.ProjectState.ARCHIVED,
29 access=project_pb2.ProjectAccess.MEMBERS_ONLY, summary='sum',
30 description='desc', moved_to='example.com',
31 cached_content_timestamp=1234567890, owner_ids=[111],
32 committer_ids=[222], contributor_ids=[333],
33 read_only_reason='being migrated',
34 home_page='example.com', docs_url='example.com/docs',
35 source_url='example.com/src', logo_gcs_id='logo_id',
36 logo_file_name='logo.gif')
37 self.assertEqual('proj', project.project_name)
38 self.assertEqual(789, project.project_id)
39 self.assertEqual(project_pb2.ProjectState.ARCHIVED, project.state)
40 self.assertEqual(project_pb2.ProjectAccess.MEMBERS_ONLY, project.access)
41 self.assertEqual('sum', project.summary)
42 self.assertEqual('desc', project.description)
43 self.assertEqual('example.com', project.moved_to)
44 self.assertEqual(1234567890, project.cached_content_timestamp)
45 self.assertEqual([111], project.owner_ids)
46 self.assertEqual([222], project.committer_ids)
47 self.assertEqual([333], project.contributor_ids)
48 self.assertEqual('being migrated', project.read_only_reason)
49 self.assertEqual('example.com', project.home_page)
50 self.assertEqual('example.com/docs', project.docs_url)
51 self.assertEqual('example.com/src', project.source_url)
52 self.assertEqual('logo_id', project.logo_gcs_id)
53 self.assertEqual('logo.gif', project.logo_file_name)