def test_to_dict(self): user_ids = [self.USER_ID, self.USER_ID_1] story_rights = story_domain.StoryRights(self.STORY_ID, user_ids, False) expected_dict = { 'story_id': self.STORY_ID, 'manager_names': ['user', 'user1'], 'story_is_published': False } self.assertEqual(expected_dict, story_rights.to_dict())
def get_story_rights_from_model(story_rights_model): """Constructs a StoryRights object from the given story rights model. Args: story_rights_model: StoryRightsModel. Story rights from the datastore. Returns: StoryRights. The rights object created from the model. """ return story_domain.StoryRights(story_rights_model.id, story_rights_model.manager_ids, story_rights_model.story_is_published)
def create_new_story_rights(story_id, committer_id): """Creates a new story rights object and saves it to the datastore. Args: story_id: str. ID of the story. committer_id: str. ID of the committer. """ story_rights = story_domain.StoryRights(story_id, [], False) commit_cmds = [{'cmd': story_domain.CMD_CREATE_NEW}] story_models.StoryRightsModel( id=story_rights.id, manager_ids=story_rights.manager_ids, story_is_published=story_rights.story_is_published).commit( committer_id, 'Created new story rights', commit_cmds)
def test_is_manager(self): user_ids = [self.USER_ID, self.USER_ID_1] story_rights = story_domain.StoryRights(self.STORY_ID, user_ids, False) self.assertTrue(story_rights.is_manager(self.USER_ID)) self.assertTrue(story_rights.is_manager(self.USER_ID_1)) self.assertFalse(story_rights.is_manager('fakeuser'))