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


Python HttpRequest.method方法代码示例

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


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

示例1: test_movie_no_add_during_get_request

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
    def test_movie_no_add_during_get_request(self):
        request = HttpRequest()
        request.method = 'GET'

        home_page(request)

        self.assertEqual(Movie.objects.count(), 0)
开发者ID:sivaa,项目名称:django-tdd,代码行数:9,代码来源:tests.py

示例2: test_upload_file

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [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

示例3: test_upload_single_sample__unpaired

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [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

示例4: get_request

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
 def get_request(self):
     request = HttpRequest()
     request.META['REMOTE_ADDR'] = '1.2.3.4'
     request.method = 'POST'
     request.session = SessionStore()
     request._messages = default_storage(request)
     request.user = AnonymousUser()
     return request
开发者ID:nijel,项目名称:weblate,代码行数:10,代码来源:test_ratelimit.py

示例5: test_home_page_redirects_after_POST

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
 def test_home_page_redirects_after_POST(self):
     request = HttpRequest()
     request.method = "POST"
     request.POST["item_text"] = 'A new list item'
     
     response = home_page(request)
     
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response['location'], '/')
开发者ID:tobiaszgithub,项目名称:test-driven-development-with-python,代码行数:11,代码来源:tests.py

示例6: test_movie_save_post_content_and_redirect

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
    def test_movie_save_post_content_and_redirect(self):
        request = HttpRequest()
        request.method = 'POST'
        request.POST['movie_name'] = 'Troy'

        response = home_page(request)

        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['location'], "/")
开发者ID:sivaa,项目名称:django-tdd,代码行数:11,代码来源:tests.py

示例7: test_movie_save_post_content_and_return

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
    def test_movie_save_post_content_and_return(self):
        request = HttpRequest()
        request.method = 'POST'
        request.POST['movie_name'] = 'Troy'

        home_page(request)

        self.assertEqual(Movie.objects.count(), 1)
        self.assertEqual(Movie.objects.first().name, "Troy")
开发者ID:sivaa,项目名称:django-tdd,代码行数:11,代码来源:tests.py

示例8: test

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
 def test(self):     
     module = PositiveIntegerInputModule()
     request = HttpRequest()
     
     request.method = 'GET'
     
     response = module.view(request)
     data = json.loads(response.content)
     self.assertNotEqual(len(data['module']), 0)
     self.assertEqual(data['moduleDisplay'], "1 is a valid positive integer")
     self.assertEqual(data['moduleResult'], 1)
     
     request.method = 'POST'
     request.POST['value'] = '4'
     
     response = module.view(request)  
     data = json.loads(response.content)      
     self.assertEqual(data['moduleDisplay'], "4 is a valid positive integer")
     self.assertEqual(data['moduleResult'], 4)
开发者ID:hzhao1230,项目名称:nanomine,代码行数:21,代码来源:tests.py

示例9: test_home_page_can_save_a_POST_requeste

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
 def test_home_page_can_save_a_POST_requeste(self):
     request = HttpRequest()
     request.method = "POST"
     request.POST["item_text"] = 'A new list item'
     
     response = home_page(request)
     
     self.assertEqual(Item.objects.count(), 1)
     newItem = Item.objects.first()
     self.assertEqual(newItem.text, 'A new list item')
开发者ID:tobiaszgithub,项目名称:test-driven-development-with-python,代码行数:12,代码来源:tests.py

示例10: test_home_page_can_save_a_POST_request

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
    def test_home_page_can_save_a_POST_request(self):
        request = HttpRequest()
        request.method = 'POST'
        request.POST['item_text'] = 'A new list item'

        response = home_page(request)

        self.assertEqual(Item.objects.all().count(), 1)
        new_item = Item.objects.all()[0]
        self.assertEqual(new_item.text, 'A new list item')
开发者ID:finnira,项目名称:superlists,代码行数:12,代码来源:tests.py

示例11: test_movie_list_in_table

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
    def test_movie_list_in_table(self):
        Movie.objects.create(name = "Troy")
        Movie.objects.create(name = "Terminator")

        request = HttpRequest()
        request.method = 'GET'
        response = home_page(request)

        self.assertIn("Troy", response.content)
        self.assertIn("Terminator", response.content)
开发者ID:sivaa,项目名称:django-tdd,代码行数:12,代码来源:tests.py

示例12: setUp

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
    def setUp(self):
        super(TestGradingViewInternals, self).setUp()
        r = HttpRequest()
        r.user = User.objects.get(username = "teacher")
        r.method = "get"
        args = []
        kwargs = {"group_id" : self.group.pk, "activity_id": self.activity.pk}
        view = GradeGroupActivity()
        view.request = r
        view.dispatch(r,*args, **kwargs)

        self.view = view
开发者ID:jbzdak,项目名称:data-base-checker,代码行数:14,代码来源:test_views.py

示例13: test_add_online_course_save_given_course

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [as 别名]
    def test_add_online_course_save_given_course(self):
        request = HttpRequest()
        request.method = 'POST'
        request.POST['course_name'] = 'Apache Spark'
        request.POST['course_url'] = 'www.coursera.com/apache_spark'
        request.POST['course_description'] = 'Introduction to Apache Spark'

        add_online_course(request)

        courses = Course.objects.all()
        self.assertEqual("Apache Spark",courses[0].name)
        self.assertEqual('Introduction to Apache Spark',courses[0].description)
开发者ID:liscju,项目名称:Nauczka,代码行数:14,代码来源:tests.py

示例14: test_form

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [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

示例15: test_form

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import method [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


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