当前位置: 首页>>代码示例>>Python>>正文


Python HttpRequest.POST方法代码示例

本文整理汇总了Python中django.http.request.HttpRequest.POST方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest.POST方法的具体用法?Python HttpRequest.POST怎么用?Python HttpRequest.POST使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.http.request.HttpRequest的用法示例。


在下文中一共展示了HttpRequest.POST方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_upload_file

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST [as 别名]
    def test_upload_file(self):
        VARIANT_SET_NAME = 'newVariant'
        self.assertEqual(0, VariantSet.objects.count())
        refGenome = self.common_entities['reference_genome']
        request = HttpRequest()
        request.POST = {
            'refGenomeUid': refGenome.uid,
            'variantSetName': VARIANT_SET_NAME,
            'createSetType': 'from-file'
        }
        request.method = 'POST'
        request.user = self.common_entities['user']
        authenticate(username=TEST_USERNAME, password=TEST_PASSWORD)
        self.assertTrue(request.user.is_authenticated())

        #random test file selected
        variant_set_file = os.path.join(GD_ROOT, 'test_data',
                'recoli_321UAG_variant_set_upload.vcf')
        mock_uploaded_file = UploadedFile(
                file=StringIO.StringIO(),
                name=variant_set_file)
        request.FILES['vcfFile'] = mock_uploaded_file

        response = create_variant_set(request)
        self.assertEqual(STATUS_CODE__SUCCESS, response.status_code)

        variantsets = VariantSet.objects.all()
        self.assertEqual(1, len(variantsets))
        self.assertEqual(VARIANT_SET_NAME, VariantSet.objects.get().label)
        self.assertEqual(refGenome, VariantSet.objects.get().reference_genome)
开发者ID:woodymit,项目名称:millstone,代码行数:32,代码来源:test_xhr_handlers.py

示例2: test_upload_single_sample__unpaired

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST [as 别名]
    def test_upload_single_sample__unpaired(self):
        project = self.common_entities['project']
        request = HttpRequest()
        request.POST = {
            'projectUid': project.uid
        }
        request.method = 'POST'
        request.user = self.common_entities['user']
        authenticate(username=TEST_USERNAME, password=TEST_PASSWORD)
        self.assertTrue(request.user.is_authenticated())

        EXPERIMENT_SAMPLE_LABEL = 'my sample'
        request.POST['sampleLabel'] = EXPERIMENT_SAMPLE_LABEL

        request.FILES['fastq1'] = UploadedFile(
                file=open(TEST_FQ1_FILE),
                name='read1.fq')

        response = upload_single_sample(request)
        self.assertEqual(STATUS_CODE__SUCCESS, response.status_code)
        self.assertFalse('error' in json.loads(response.content))

        sample = ExperimentSample.objects.get(label=EXPERIMENT_SAMPLE_LABEL)
        self.assertTrue(sample)

        datasets = sample.dataset_set.all()
        # num_datasets: 1 fastq + 1 fastqc = 2
        self.assertEqual(2, len(datasets))
        for dataset in datasets:
            self.assertEqual(Dataset.STATUS.READY, dataset.status)
开发者ID:woodymit,项目名称:millstone,代码行数:32,代码来源:test_xhr_handlers.py

示例3: test_get_from_request

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST [as 别名]
 def test_get_from_request(self):
     request = HttpRequest()
     request.POST = {'param1': 'str1'}
     self.assertEqual('str1',
                      DjangoAppUtils.get_from_request(request, 'param1'))
     self.assertIsNone(DjangoAppUtils.get_from_request(request, 'param2'))
     self.assertEqual('default',
                      DjangoAppUtils.get_from_request(
                          request, 'param2', 'default')
     )
开发者ID:eaudeweb,项目名称:informea.ai_manager,代码行数:12,代码来源:tests.py

示例4: test_form

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST [as 别名]
 def test_form(self):
     request = HttpRequest()
     request.POST = {
         'name': 'test form tag',
         'app_label': self.committee_content_type.app_label,
         'object_type': self.committee_content_type.model,
         'object_id': self.committee_meeting.id
     }
     request.method = 'POST'
     request.user = self.user
     suggest_tag_post(request)
     tag_suggestion = TagSuggestion.objects.get(name='test form tag')
     self.assertEqual(tag_suggestion.object, self.committee_meeting)
     self.assertEqual(tag_suggestion.suggested_by, self.user)
开发者ID:Daphna-Shalev,项目名称:Open-Knesset,代码行数:16,代码来源:tests.py

示例5: test_form

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST [as 别名]
 def test_form(self):
     request = HttpRequest()
     request.POST = {
         "name": "test form tag",
         "app_label": self.committee_content_type.app_label,
         "object_type": self.committee_content_type.model,
         "object_id": self.committee_meeting.id,
     }
     request.method = "POST"
     request.user = self.user
     suggest_tag_post(request)
     tag_suggestion = TagSuggestion.objects.get(name="test form tag")
     self.assertEqual(tag_suggestion.object, self.committee_meeting)
     self.assertEqual(tag_suggestion.suggested_by, self.user)
开发者ID:nirfuzz,项目名称:Open-Knesset,代码行数:16,代码来源:tests.py

示例6: test_upload_file

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST [as 别名]
    def test_upload_file(self):
        project = self.common_entities['project']
        request = HttpRequest()
        request.POST = {
            'projectUid': project.uid
        }
        request.method = 'POST'
        request.user = self.common_entities['user']
        authenticate(username=TEST_USERNAME, password=TEST_PASSWORD)
        self.assertTrue(request.user.is_authenticated())

        # Fake having uploaded a template.
        row_data = {
            SAMPLE_BROWSER_UPLOAD_KEY__SAMPLE_NAME: 'red',
            SAMPLE_BROWSER_UPLOAD_KEY__READ_1: 'red1.fq',
            SAMPLE_BROWSER_UPLOAD_KEY__READ_2: 'red2.fq'
        }
        _create_sample_and_placeholder_dataset(project, row_data)
        datasets = Dataset.objects.all()
        self.assertEqual(2, len(datasets))
        for dataset in datasets:
            self.assertEqual(Dataset.STATUS.AWAITING_UPLOAD, dataset.status)

        def _upload_file_and_check_response(name):
            # Add mock file to request.
            mock_uploaded_file = UploadedFile(
                    file=StringIO.StringIO(),
                    name=name)
            request.FILES = {
                'file': mock_uploaded_file
            }
            response = samples_upload_through_browser_sample_data(request)
            self.assertEqual(STATUS_CODE__SUCCESS, response.status_code)
            self.assertFalse('error' in json.loads(response.content))

        _upload_file_and_check_response('red1.fq')
        _upload_file_and_check_response('red2.fq')

        datasets = Dataset.objects.all()
        self.assertEqual(2, len(datasets))
        for dataset in datasets:
            self.assertEqual(Dataset.STATUS.READY, dataset.status)
开发者ID:woodymit,项目名称:millstone_accidental_source,代码行数:44,代码来源:test_xhr_handlers.py

示例7: test_upload_long_id_genbank

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST [as 别名]
    def test_upload_long_id_genbank(self):
        project = self.common_entities['project']
        ref_genome_label = 'dirty_upload'
        request = HttpRequest()
        request.POST = {
            'projectUid': project.uid,
            'refGenomeLabel': ref_genome_label,
            'importFileFormat': 'genbank'
        }
        request.method = 'POST'
        request.user = self.common_entities['user']
        authenticate(username=TEST_USERNAME, password=TEST_PASSWORD)
        self.assertTrue(request.user.is_authenticated())

        request.FILES['refGenomeFile'] = UploadedFile(
                file=open(LONG_ID_GENBANK),
                name='dirty_genbank.gb')

        response = create_ref_genome_from_browser_upload(request)
        self.assertEqual(STATUS_CODE__SUCCESS, response.status_code)
        self.assertFalse(json.loads(response.content).get('error', False))
开发者ID:woodymit,项目名称:millstone,代码行数:23,代码来源:test_xhr_handlers.py

示例8: _generate_test_instance

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST [as 别名]
        def _generate_test_instance(rg_files, rg_names=None):

            if rg_names == None:
                rg_names = [str(i) for i in range(len(rg_files))]

            project = self.common_entities['project']
            ref_genomes = []
            for i,rg_file in enumerate(rg_files):
                file_type = 'fasta' if rg_file.endswith('.fa') else 'genbank'
                ref_genomes.append(import_reference_genome_from_local_file(
                    project, rg_names[i], rg_file, file_type, move=False))

            test_label = 'concat_test'
            request_data = {
                'newGenomeLabel': test_label,
                'refGenomeUidList': [rg.uid for rg in ref_genomes]
            }

            request = HttpRequest()
            request.POST = {'data':json.dumps(request_data)}
            request.method = 'POST'
            request.user = self.common_entities['user']

            authenticate(username=TEST_USERNAME, password=TEST_PASSWORD)
            self.assertTrue(request.user.is_authenticated())

            response = ref_genomes_concatenate(request)

            concat_ref=ReferenceGenome.objects.get(label=test_label)

            # Assert correct number of chromosomes
            self.assertEqual(concat_ref.num_chromosomes,
                    sum([rg.num_chromosomes for rg in ref_genomes]))

            # Assert correct number of bases
            self.assertEqual(concat_ref.num_bases,
                    sum([rg.num_bases for rg in ref_genomes]))

            # Delete Reference Genome
            concat_ref.delete()
开发者ID:woodymit,项目名称:millstone_accidental_source,代码行数:42,代码来源:test_xhr_handlers.py

示例9: test_run_alignment_with_spaces_in_genbank_filename

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import POST [as 别名]
    def test_run_alignment_with_spaces_in_genbank_filename(self):
        project = self.common_entities['project']
        ref_genome_label = 'dirty_upload'
        request = HttpRequest()
        request.POST = {
            'projectUid': project.uid,
            'refGenomeLabel': ref_genome_label,
            'importFileFormat': 'genbank'
        }
        request.method = 'POST'
        request.user = self.common_entities['user']
        authenticate(username=TEST_USERNAME, password=TEST_PASSWORD)
        self.assertTrue(request.user.is_authenticated())

        request.FILES['refGenomeFile'] = UploadedFile(
                file=open(TEST_GENBANK),
                name='dirty_genbank (spaces).gb')

        response = create_ref_genome_from_browser_upload(request)
        self.assertEqual(STATUS_CODE__SUCCESS, response.status_code)
        self.assertFalse(json.loads(response.content).get('error', False))

        # Get reference genome
        ref_genome = ReferenceGenome.objects.get(
                project=project,
                label=ref_genome_label)

        # Create sample model
        sample = ExperimentSample.objects.create(
                project=project,
                label='test_sample')

        # Add fastq datasets to sample
        add_dataset_to_entity(
                sample,
                Dataset.TYPE.FASTQ1,
                Dataset.TYPE.FASTQ1,
                filesystem_location=TEST_DIRTY_FQ_1)

        # Add fastq datasets to sample
        add_dataset_to_entity(
                sample,
                Dataset.TYPE.FASTQ2,
                Dataset.TYPE.FASTQ2,
                filesystem_location=TEST_DIRTY_FQ_2)

        # Run alignment of sample to reference
        alignment_group_label = 'test_alignment'
        sample_list = [sample]

        result = run_pipeline(
                alignment_group_label, ref_genome, sample_list)

        alignment_group = result[0]
        alignment_async_result = result[1]
        variant_calling_async_result = result[2]
        alignment_async_result.get()
        variant_calling_async_result.get()
        alignment_group = AlignmentGroup.objects.get(uid=alignment_group.uid)
        self.assertEqual(AlignmentGroup.STATUS.COMPLETED,
                alignment_group.status)
开发者ID:woodymit,项目名称:millstone,代码行数:63,代码来源:test_xhr_handlers.py


注:本文中的django.http.request.HttpRequest.POST方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。