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)
test_channels.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录