Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1829)

Unified Diff: appengine/monorail/project/test/projectsummary_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/monorail/project/test/projectsummary_test.py
diff --git a/appengine/monorail/project/test/projectsummary_test.py b/appengine/monorail/project/test/projectsummary_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..398babc9b134b982a89d326f3218fb8eeb8b611d
--- /dev/null
+++ b/appengine/monorail/project/test/projectsummary_test.py
@@ -0,0 +1,74 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Unittests for Project Summary servlet."""
+
+import unittest
+
+from framework import permissions
+from project import projectsummary
+from proto import project_pb2
+from services import service_manager
+from testing import fake
+from testing import testing_helpers
+
+
+class ProjectSummaryTest(unittest.TestCase):
+
+ def setUp(self):
+ services = service_manager.Services(
+ project=fake.ProjectService(),
+ user=fake.UserService(),
+ project_star=fake.ProjectStarService())
+ self.project = services.project.TestAddProject(
+ 'proj', project_id=123, summary='sum',
+ description='desc')
+ self.servlet = projectsummary.ProjectSummary(
+ 'req', 'res', services=services)
+
+ def testGatherPageData(self):
+ mr = testing_helpers.MakeMonorailRequest(project=self.project)
+ page_data = self.servlet.GatherPageData(mr)
+ self.assertEqual(
+ '<p>desc</p>', page_data['formatted_project_description'])
+ self.assertEqual(
+ int(project_pb2.ProjectAccess.ANYONE), page_data['access_level'].key)
+ self.assertEqual(0, page_data['num_stars'])
+ self.assertEqual('s', page_data['plural'])
+
+ def testGatherHelpData(self):
+ mr = testing_helpers.MakeMonorailRequest(project=self.project)
+
+ # Non-members cannot edit project, so cue is not relevant.
+ mr.perms = permissions.READ_ONLY_PERMISSIONSET
+ help_data = self.servlet.GatherHelpData(mr, {})
+ self.assertEqual(None, help_data['cue'])
+
+ # Members (not owners) cannot edit project, so cue is not relevant.
+ mr.perms = permissions.READ_ONLY_PERMISSIONSET
+ help_data = self.servlet.GatherHelpData(mr, {})
+ self.assertEqual(None, help_data['cue'])
+
+ # This is a project member who has set up mailing lists and added
+ # members, but has not noted any duties.
+ mr = testing_helpers.MakeMonorailRequest(project=self.project)
+ self.project.issue_notify_address = 'example@domain.com'
+ self.project.committer_ids.extend([111L, 222L])
+ help_data = self.servlet.GatherHelpData(mr, {})
+ self.assertEqual('document_team_duties', help_data['cue'])
+
+ # Now he set up notes too.
+ project_commitments = project_pb2.ProjectCommitments()
+ project_commitments.project_id = self.project.project_id
+ project_commitments.commitments.append(
+ project_pb2.ProjectCommitments.MemberCommitment())
+ self.servlet.services.project.TestStoreProjectCommitments(
+ project_commitments)
+ help_data = self.servlet.GatherHelpData(mr, {})
+ self.assertEqual(None, help_data['cue'])
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « appengine/monorail/project/test/projectexport_test.py ('k') | appengine/monorail/project/test/projectupdates_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698