test_channels.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:django-open-volunteering-platform 作者: OpenVolunteeringPlatform 项目源码 文件源码
def test_cant_create_modify_on_another_channel(self):
    """ Assert it's not possible to create or modify object on another channel """
    client = APIClient()
    client.login(email=self.email, password=self.password, channel="test-channel")

    # Create
    data = copy.copy(base_project)
    response = client.post(reverse("project-list"), data, format="json", HTTP_X_OVP_CHANNEL="default")
    self.assertTrue(response.status_code == 400)

    response = client.post(reverse("project-list"), data, format="json", HTTP_X_OVP_CHANNEL="test-channel")
    self.assertTrue(response.status_code == 201)

    # Modify
    updated_project = {"disponibility": {"type": "job", "job": {"dates": [{"name": "update", "start_date": "2013-01-29T12:34:56.123Z", "end_date": "2013-01-29T13:34:56.123Z"}, {"name": "test1", "start_date": "2013-02-01T12:34:56.123Z", "end_date": "2013-02-01T13:34:56.123Z"}]}}}
    response = client.patch(reverse("project-detail", ["test-project"]), updated_project, format="json", HTTP_X_OVP_CHANNEL="default")
    self.assertTrue(response.status_code == 400)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号