Example #1
0
 def test_post_api_update(self):
     '''It should update a post from the API'''
     post = PostFactory()
     data = post.to_dict()
     data['content'] = 'new content'
     self.login(AdminFactory())
     response = self.put(url_for('api.post', post=post), data)
     self.assert200(response)
     self.assertEqual(Post.objects.count(), 1)
     self.assertEqual(Post.objects.first().content, 'new content')
Example #2
0
 def test_post_api_update(self, api):
     '''It should update a post from the API'''
     post = PostFactory()
     data = post.to_dict()
     data['content'] = 'new content'
     api.login(AdminFactory())
     response = api.put(url_for('api.post', post=post), data)
     assert200(response)
     assert Post.objects.count() == 1
     assert Post.objects.first().content == 'new content'
Example #3
0
 def test_post_api_update(self, api):
     '''It should update a post from the API'''
     post = PostFactory()
     data = post.to_dict()
     data['content'] = 'new content'
     api.login(AdminFactory())
     response = api.put(url_for('api.post', post=post), data)
     assert200(response)
     assert Post.objects.count() == 1
     assert Post.objects.first().content == 'new content'
Example #4
0
    def test_post_api_update_with_related_dataset_and_reuse(self, api):
        '''It should update a post from the API with related dataset and reuse'''
        api.login(AdminFactory())
        post = PostFactory()
        data = post.to_dict()
        data['content'] = 'new content'

        # Add datasets
        data['datasets'] = [DatasetFactory().to_dict()]
        response = api.put(url_for('api.post', post=post), data)
        assert200(response)

        # Add reuses to the post value returned by the previous api call
        data = response.json
        data['reuses'] = [ReuseFactory().to_dict()]
        response = api.put(url_for('api.post', post=post), data)
        assert200(response)

        assert len(response.json['datasets']) == 1
        assert len(response.json['reuses']) == 1