| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from telemetry import user_story |
| 9 from telemetry.user_story import shared_user_story_state |
| 8 from telemetry.user_story import user_story_set | 10 from telemetry.user_story import user_story_set |
| 9 from telemetry.util import cloud_storage | 11 from telemetry.util import cloud_storage |
| 10 | 12 |
| 11 | 13 |
| 14 # pylint: disable=abstract-method |
| 15 class SharedUserStoryStateBar(shared_user_story_state.SharedUserStoryState): |
| 16 pass |
| 17 |
| 18 |
| 19 class UserStoryFoo(user_story.UserStory): |
| 20 def __init__(self, name='', labels=None): |
| 21 super(UserStoryFoo, self).__init__( |
| 22 SharedUserStoryStateBar, name, labels) |
| 23 |
| 24 |
| 12 class UserStorySetFoo(user_story_set.UserStorySet): | 25 class UserStorySetFoo(user_story_set.UserStorySet): |
| 13 """ UserStorySetFoo is a user story created for testing purpose. """ | 26 """ UserStorySetFoo is a user story created for testing purpose. """ |
| 14 pass | 27 pass |
| 15 | 28 |
| 16 | 29 |
| 17 class UserStorySetTest(unittest.TestCase): | 30 class UserStorySetTest(unittest.TestCase): |
| 18 | 31 |
| 19 def testUserStoryTestName(self): | 32 def testUserStoryTestName(self): |
| 20 self.assertEquals('user_story_set_unittest', UserStorySetFoo.Name()) | 33 self.assertEquals('user_story_set_unittest', UserStorySetFoo.Name()) |
| 21 | 34 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 self.assertEqual(public_uss.bucket, cloud_storage.PUBLIC_BUCKET) | 52 self.assertEqual(public_uss.bucket, cloud_storage.PUBLIC_BUCKET) |
| 40 | 53 |
| 41 partner_uss = user_story_set.UserStorySet( | 54 partner_uss = user_story_set.UserStorySet( |
| 42 cloud_storage_bucket=cloud_storage.PARTNER_BUCKET) | 55 cloud_storage_bucket=cloud_storage.PARTNER_BUCKET) |
| 43 self.assertEqual(partner_uss.bucket, cloud_storage.PARTNER_BUCKET) | 56 self.assertEqual(partner_uss.bucket, cloud_storage.PARTNER_BUCKET) |
| 44 | 57 |
| 45 internal_uss = user_story_set.UserStorySet( | 58 internal_uss = user_story_set.UserStorySet( |
| 46 cloud_storage_bucket=cloud_storage.INTERNAL_BUCKET) | 59 cloud_storage_bucket=cloud_storage.INTERNAL_BUCKET) |
| 47 self.assertEqual(internal_uss.bucket, cloud_storage.INTERNAL_BUCKET) | 60 self.assertEqual(internal_uss.bucket, cloud_storage.INTERNAL_BUCKET) |
| 48 | 61 |
| 49 self.assertRaises(ValueError, user_story_set.UserStorySet, | 62 with self.assertRaises(ValueError): |
| 50 cloud_storage_bucket='garbage_bucket') | 63 user_story_set.UserStorySet(cloud_storage_bucket='garbage_bucket') |
| 64 |
| 65 def testRemoveWithEmptySetRaises(self): |
| 66 uss = user_story_set.UserStorySet() |
| 67 foo_story = UserStoryFoo() |
| 68 with self.assertRaises(ValueError): |
| 69 uss.RemoveUserStory(foo_story) |
| 70 |
| 71 def testBasicAddRemove(self): |
| 72 uss = user_story_set.UserStorySet() |
| 73 foo_story = UserStoryFoo() |
| 74 uss.AddUserStory(foo_story) |
| 75 self.assertEqual([foo_story], uss.user_stories) |
| 76 |
| 77 uss.RemoveUserStory(foo_story) |
| 78 self.assertEqual([], uss.user_stories) |
| OLD | NEW |