Revert of [Telemetry] Introduce shared_user_story_state for real. (patchset #3 id...
[chromium-blink-merge.git] / tools / telemetry / telemetry / user_story / user_story_unittest.py
blob6b926938e0e07a223c93a27a098303c6a4eeea2f
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
3 # found in the LICENSE file.
5 import unittest
7 from telemetry import user_story
9 class UserStoryFoo(user_story.UserStory):
10 pass
13 class UserStoryTest(unittest.TestCase):
14 def testUserStoriesHaveDifferentIds(self):
15 u0 = user_story.UserStory('foo')
16 u1 = user_story.UserStory('bar')
17 self.assertNotEqual(u0.id, u1.id)
19 def testNamelessUserStoryDisplayName(self):
20 u = UserStoryFoo()
21 self.assertEquals('UserStoryFoo', u.display_name)
23 def testNamedUserStoryDisplayName(self):
24 u = UserStoryFoo('Bar')
25 self.assertEquals('Bar', u.display_name)
27 def testUserStoryFileSafeName(self):
28 u = UserStoryFoo('Foo Bar:Baz~0')
29 self.assertEquals('Foo_Bar_Baz_0', u.file_safe_name)
31 def testNamelessUserStoryAsDict(self):
32 u = user_story.UserStory()
33 u_dict = u.AsDict()
34 self.assertEquals(u_dict['id'], u.id)
35 self.assertNotIn('name', u_dict)
37 def testNamedUserStoryAsDict(self):
38 u = user_story.UserStory('Foo')
39 u_dict = u.AsDict()
40 self.assertEquals(u_dict['id'], u.id)
41 self.assertEquals('Foo', u_dict['name'])