コード例 #1
0
    def test_remove_team_member(self):
        team = synapseclient.Team(id=123)
        user = synapseclient.UserProfile(ownerId=2222)

        with patch.object(self.syn, "restDELETE") as patch_rest:
            teams.remove_team_member(self.syn, team, user)
            patch_rest.assert_called_once_with("/team/123/member/2222")
コード例 #2
0
def test_get_forum_participants():
    '''Test get forum participants'''
    threads = [THREAD_OBJ]
    profile = synapseclient.UserProfile(ownerId="test")
    with mock.patch.object(discussion,
                           "get_forum_threads",
                           return_value=threads) as patch_get_threads,\
         mock.patch.object(syn,
                           "getUserProfile",
                           return_value=profile) as patch_getuserprofile:
        participants = discussion.get_forum_participants(syn, PROJECTID)
        patch_get_threads.assert_called_once_with(syn, PROJECTID)
        patch_getuserprofile.assert_called_once_with('2222')
        assert participants == [profile]
コード例 #3
0
def test_copy_reply():
    """Tests copying of replies"""
    profile = synapseclient.UserProfile(ownerId="test", userName="******")
    reply_text = str(uuid.uuid1())
    on_behalf_of = "On behalf of @{user}\n\n".format(user=profile.userName)
    new_reply_text = on_behalf_of + reply_text

    with mock.patch.object(syn, "getUserProfile",
                           return_value=profile) as patch_getuserprofile,\
         mock.patch.object(discussion, "get_thread_reply_text",
                           return_value=reply_text) as patch_reply_text,\
         mock.patch.object(discussion, "create_thread_reply",
                           return_value=REPLY_OBJ) as patch_create_reply:
        reply = discussion.copy_reply(syn, REPLY_OBJ, THREAD_OBJ)
        patch_getuserprofile.assert_called_once_with(REPLY_OBJ['createdBy'])
        patch_reply_text.assert_called_once_with(syn, REPLY_OBJ['messageKey'])
        patch_create_reply.assert_called_once_with(syn, THREAD_OBJ['id'],
                                                   new_reply_text)
        assert reply == REPLY_OBJ
コード例 #4
0
def test__copy_thread():
    """Tests copying of threads"""
    profile = synapseclient.UserProfile(ownerId="test", userName="******")
    thread_text = str(uuid.uuid1())
    on_behalf_of = "On behalf of @{user}\n\n".format(user=profile.userName)
    new_thread_text = on_behalf_of + thread_text

    with mock.patch.object(syn, "getUserProfile",
                           return_value=profile) as patch_getuserprofile,\
         mock.patch.object(discussion, "get_thread_text",
                           return_value=thread_text) as patch_thread_text,\
         mock.patch.object(discussion, "create_thread",
                           return_value=THREAD_OBJ) as patch_create_thread:
        thread = discussion._copy_thread(syn, THREAD_OBJ, PROJECTID)
        patch_getuserprofile.assert_called_once_with(THREAD_OBJ.createdby)
        patch_thread_text.assert_called_once_with(syn, THREAD_OBJ)
        patch_create_thread.assert_called_once_with(syn, PROJECTID,
                                                    THREAD_OBJ.title,
                                                    new_thread_text)
        assert thread == THREAD_OBJ
コード例 #5
0
CHALLENGE_SYNID = "syn1234"

SUBMISSION = synapseclient.Submission(name="foo",
                                      entityId="syn123",
                                      evaluationId=2,
                                      versionNumber=1,
                                      id="syn222",
                                      filePath="foo",
                                      userId="222")
SUBMISSION_STATUS = synapseclient.SubmissionStatus(status="RECEIVED",
                                                   id="111",
                                                   etag="222")
EVALUATION = synapseclient.Evaluation(name="foo",
                                      id="222",
                                      contentSource=CHALLENGE_SYNID)
SYN_USERPROFILE = synapseclient.UserProfile(ownerId="111", userName="******")
BUNDLE = [(SUBMISSION, SUBMISSION_STATUS)]
SUB_INFO = {
    'valid': True,
    'annotations': ANNOTATIONS,
    'error': None,
    'message': MESSAGE
}


@pytest.fixture
def scorer():
    """Invoke validator, must patch get evaluation"""
    with patch.object(SYN, "getEvaluation", return_value=EVALUATION),\
         patch.object(SYN, "getUserProfile", return_value={'ownerId': 111}):
        score = EvaluationQueueScorer(SYN, EVALUATION)