Esempio n. 1
0
 def test_is_creator(self):
     """Test to verify is_creator method of the Question Rights Domain
     object.
     """
     question_rights = question_domain.QuestionRights(
         self.question_id, self.user_id)
     self.assertTrue(question_rights.is_creator(self.user_id))
     self.assertFalse(question_rights.is_creator('fakeuser'))
    def test_to_dict(self):
        question_rights = question_domain.QuestionRights(
            self.question_id, self.user_id)
        expected_dict = {
            'question_id': self.question_id,
            'creator_id': self.user_id
        }

        self.assertEqual(expected_dict, question_rights.to_dict())
Esempio n. 3
0
    def test_to_dict(self):
        """Test to verify to_dict method of the Question Rights Domain
        object.
        """
        question_rights = question_domain.QuestionRights(
            self.question_id, self.user_id)
        expected_dict = {
            'question_id': self.question_id,
            'creator_id': self.user_id
        }

        self.assertEqual(expected_dict, question_rights.to_dict())
Esempio n. 4
0
def create_new_question_rights(question_id, committer_id):
    """Creates a new question rights object and saves it to the datastore.

    Args:
        question_id: str. ID of the question.
        committer_id: str. ID of the committer.
    """
    question_rights = question_domain.QuestionRights(question_id, committer_id)
    commit_cmds = [{'cmd': question_domain.CMD_CREATE_NEW}]

    question_models.QuestionRightsModel(
        id=question_rights.id, creator_id=question_rights.creator_id).commit(
            committer_id, 'Created new question rights', commit_cmds)
Esempio n. 5
0
def get_question_rights_from_model(question_rights_model):
    """Constructs a QuestionRights object from the given question rights model.

    Args:
        question_rights_model: QuestionRightsModel. Question rights from the
            datastore.

    Returns:
        QuestionRights. The rights object created from the model.
    """

    return question_domain.QuestionRights(question_rights_model.id,
                                          question_rights_model.creator_id)
 def test_is_creator(self):
     question_rights = question_domain.QuestionRights(
         self.question_id, self.user_id)
     self.assertTrue(question_rights.is_creator(self.user_id))
     self.assertFalse(question_rights.is_creator('fakeuser'))