def test_update_activity_with_oauth_containing_user(self):
        url = 'http://testserver/XAPI/statements'
        guid = str(uuid.uuid1())
        stmt_data = {"id":guid,"actor":{"objectType": "Agent",
            "mbox":"mailto:bob@bob.com", "name":"bob"},"verb":{"id": "http://example.com/verbs/passed",
            "display": {"en-US":"passed"}},"object": {"id":"test://test/define/scope"}}
        stmt_post = self.client.post(reverse('lrs:statements'), json.dumps(stmt_data), content_type="application/json",
            Authorization=self.jane_auth, X_Experience_API_Version=settings.XAPI_VERSION)
        self.assertEqual(stmt_post.status_code, 200)

        # build stmt data and path
        put_guid = str(uuid.uuid1())
        stmt = json.dumps({"actor":{"objectType": "Agent", "mbox":"mailto:bill@bill.com", "name":"bill"},
            "verb":{"id": "http://example.com/verbs/accessed","display": {"en-US":"accessed"}},
            "object": {"id":"test://test/define/scope",
            'definition': {'name': {'en-US':'testname', 'en-GB': 'altname'},
            'description': {'en-US':'testdesc', 'en-GB': 'altdesc'},'type': 'type:course',
            'interactionType': 'other', 'correctResponsesPattern':[]}}})

        param = {"statementId":put_guid}
        path = "%s?%s" % (url, urllib.urlencode(param))
        
        # START PUT STMT
        oauth_header_resource_params, access_token = self.oauth_handshake(scope_type='statements/write statements/read define')
        
        # from_token_and_callback takes a dictionary        
        param_list = oauth_header_resource_params.split(",")
        oauth_header_resource_params_dict = {}
        for p in param_list:
            item = p.split("=")
            oauth_header_resource_params_dict[str(item[0]).strip()] = str(item[1]).strip('"')
        # from_request ignores realm, must remove so not input to from_token_and_callback
        del oauth_header_resource_params_dict['OAuth realm']

        # Create oauth request and add signature
        oauth_request = oauth.Request.from_token_and_callback(access_token, http_method='PUT',
            http_url=path, parameters=oauth_header_resource_params_dict)
        signature_method = oauth.SignatureMethod_HMAC_SHA1()
        signature = signature_method.sign(oauth_request, self.consumer, access_token)
        oauth_header_resource_params += ',oauth_signature="%s"' % signature
        
        # Put statements - should update existing activity since jane is in oauth group
        resp = self.client.put(path, data=stmt, content_type="application/json",
            Authorization=oauth_header_resource_params, X_Experience_API_Version=settings.XAPI_VERSION)

        self.assertEqual(resp.status_code, 204)
        acts = Activity.objects.all()
        self.assertEqual(len(acts), 1)
        act = acts[0].return_activity_with_lang_format()
        self.assertEqual(act['id'], 'test://test/define/scope')
        self.assertIn('definition', act)
dataset/ETHPy150Open adlnet/ADL_LRS/lrs/tests/test_OAuth.py/OAuthTests.test_update_activity_with_oauth_containing_user/original