test_channels.py 文件源码

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

项目:django-open-volunteering-platform 作者: OpenVolunteeringPlatform 项目源码 文件源码
def test_creating_project_creates_objects_on_correct_channel(self):
    """ Assert creating a project creates the object on the correct 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="test-channel")
    self.assertTrue(response.status_code == 201)
    self.assertTrue(Project.objects.last().channel.slug == "test-channel")
    self.assertTrue(Work.objects.last().channel.slug == "test-channel")

    # 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="test-channel")
    self.assertTrue(Job.objects.last().channel.slug == "test-channel")
    self.assertTrue(JobDate.objects.last().channel.slug == "test-channel")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号