コード例 #1
0
 def test_community_resource_api_update_w_previous_owner(self):
     '''Should update a community resource and keep the original author'''
     owner = UserFactory()
     community_resource = CommunityResourceFactory(owner=owner)
     self.login(AdminFactory())
     data = community_resource.to_dict()
     data['description'] = 'new description'
     response = self.put(
         url_for('api.community_resource', community=community_resource),
         data)
     self.assert200(response)
     self.assertEqual(CommunityResource.objects.first().owner, owner)
コード例 #2
0
 def test_community_resource_api_update(self):
     '''It should update a community resource from the API'''
     user = self.login()
     community_resource = CommunityResourceFactory(owner=user)
     data = community_resource.to_dict()
     data['description'] = 'new description'
     response = self.put(
         url_for('api.community_resource', community=community_resource),
         data)
     self.assert200(response)
     self.assertEqual(CommunityResource.objects.count(), 1)
     self.assertEqual(CommunityResource.objects.first().description,
                      'new description')