def test_skill_rights_to_dict(self): expected_dict = { 'creator_id': 'user', 'skill_is_private': True, 'skill_id': 'skill_id' } skill_rights = skill_domain.SkillRights('skill_id', True, 'user') self.assertDictEqual(expected_dict, skill_rights.to_dict())
def get_skill_rights_from_model(skill_rights_model): """Constructs a SkillRights object from the given skill rights model. Args: skill_rights_model: SkillRightsModel. Skill rights from the datastore. Returns: SkillRights. The rights object created from the model. """ return skill_domain.SkillRights(skill_rights_model.id, skill_rights_model.skill_is_private, skill_rights_model.creator_id)
def create_new_skill_rights(skill_id, committer_id): """Creates a new skill rights object and saves it to the datastore. Args: skill_id: str. ID of the skill. committer_id: str. ID of the committer. """ skill_rights = skill_domain.SkillRights(skill_id, True, committer_id) commit_cmds = [{'cmd': skill_domain.CMD_CREATE_NEW}] skill_models.SkillRightsModel( id=skill_rights.id, creator_id=skill_rights.creator_id, skill_is_private=skill_rights.skill_is_private ).commit(committer_id, 'Created new skill rights', commit_cmds)
def test_skill_rights_is_creator(self): skill_rights = skill_domain.SkillRights(self.SKILL_ID, True, 'user') self.assertTrue(skill_rights.is_creator('user')) self.assertFalse(skill_rights.is_creator('fakeuser'))