Skip to content
Snippets Groups Projects
Commit a88c5d79 authored by Jean-Baptiste's avatar Jean-Baptiste
Browse files

Add failing test for Hubl #766

parent be67e7d3
No related branches found
No related tags found
1 merge request!165Sub object can't be updated
......@@ -12,20 +12,20 @@ from django.test.runner import DiscoverRunner
test_runner = DiscoverRunner(verbosity=1)
failures = test_runner.run_tests([
'djangoldp.tests.tests_ldp_model',
'djangoldp.tests.tests_save',
'djangoldp.tests.tests_user_permissions',
'djangoldp.tests.tests_guardian',
'djangoldp.tests.tests_anonymous_permissions',
'djangoldp.tests.tests_update',
'djangoldp.tests.tests_auto_author',
'djangoldp.tests.tests_get',
'djangoldp.tests.tests_delete',
'djangoldp.tests.tests_sources',
'djangoldp.tests.tests_pagination',
'djangoldp.tests.tests_inbox',
'djangoldp.tests.tests_backlinks_service',
# 'djangoldp.tests.tests_temp'
# 'djangoldp.tests.tests_ldp_model',
# 'djangoldp.tests.tests_save',
# 'djangoldp.tests.tests_user_permissions',
# 'djangoldp.tests.tests_guardian',
# 'djangoldp.tests.tests_anonymous_permissions',
# 'djangoldp.tests.tests_update',
# 'djangoldp.tests.tests_auto_author',
# 'djangoldp.tests.tests_get',
# 'djangoldp.tests.tests_delete',
# 'djangoldp.tests.tests_sources',
# 'djangoldp.tests.tests_pagination',
# 'djangoldp.tests.tests_inbox',
# 'djangoldp.tests.tests_backlinks_service',
'djangoldp.tests.tests_temp'
])
if failures:
......
......@@ -318,7 +318,6 @@ class Save(TestCase):
self.assertEqual(response.data['circle']['@id'],
"http://testserver/circles/{}/".format(circle.pk))
def test_nested_container_federated(self):
resource = Resource.objects.create()
body = {
......
......@@ -2,7 +2,7 @@ import json
from guardian.shortcuts import assign_perm
from .models import PermissionlessDummy, Dummy
from .models import PermissionlessDummy, Dummy, Resource, UserProfile
from django.contrib.auth import get_user_model
from django.test import TestCase
from rest_framework.test import APIRequestFactory, APIClient
......@@ -33,15 +33,75 @@ class TestTemp(TestCase):
def tearDown(self):
pass
# def test_nested_container_federated_609(self):
# resource = Resource.objects.create()
# body = {
# 'http://happy-dev.fr/owl/#@id': "http://testserver/resources/{}".format(resource.pk),
# 'http://happy-dev.fr/owl/#joboffers': [
# {
# 'http://happy-dev.fr/owl/#@id': "https://external.com/job-offers/1"
# },
# {
# 'http://happy-dev.fr/owl/#@id': "https://external.com/job-offers/2"
# }
# ]
# }
#
# response = self.client.put('/resources/{}/'.format(resource.pk),
# data=json.dumps(body),
# content_type='application/ld+json')
# self.assertEqual(response.status_code, 200)
# self.assertEqual(len(response.data['joboffers']['ldp:contains']), 2)
#
# body2 = {
# 'http://happy-dev.fr/owl/#@id': "http://testserver/resources/{}".format(resource.pk),
# 'http://happy-dev.fr/owl/#joboffers': [
# {
# 'http://happy-dev.fr/owl/#@id': "https://external.com/job-offers/1"
# },
# {
# 'http://happy-dev.fr/owl/#@id': "https://external.com/job-offers/3"
# },
# {
# 'http://happy-dev.fr/owl/#@id': "https://external.com/job-offers/4"
# }
# ]
# }
# response = self.client.put('/resources/{}/'.format(resource.pk),
# data=json.dumps(body2),
# content_type='application/ld+json')
#
# self.assertEqual(response.status_code, 200)
# self.assertEqual(len(response.data['joboffers']['ldp:contains']), 3)
#
# response = self.client.put('/resources/{}/job-offers'.format(resource.pk),
# data=json.dumps(body2),
# content_type='application/ld+json')
# test with anonymous user
def test_invalidate_cache_permissions(self):
self.setUpLoggedInUser()
self.setUpGuardianDummyWithPerms()
response = self.client.get('/permissionless-dummys/{}/'.format(self.dummy.slug))
self.assertEqual(response.status_code, 403)
assign_perm('view' + '_' + PermissionlessDummy._meta.model_name, self.user, self.dummy)
LDPPermissions.invalidate_cache()
response = self.client.get('/permissionless-dummys/{}/'.format(self.dummy.slug))
def test_create_sub_object_in_existing_object_with_existing_reverse_1to1_relation(self):
user = get_user_model().objects.create(username="alex", password="test")
profile = UserProfile.objects.create(user=user, description="user description")
body = {
'@id': '/users/{}/'.format(user.pk),
"first_name": "Alexandre",
"last_name": "Bourlier",
"username": "alex",
'userprofile': {
'@id': "http://happy-dev.fr/userprofiles/{}/".format(profile.pk),
'description': "user update"
},
'@context': {
"@vocab": "http://happy-dev.fr/owl/#",
}
}
response = self.client.put('/users/{}/'.format(user.pk), data=json.dumps(body),
content_type='application/ld+json')
self.assertEqual(response.status_code, 200)
self.assertIn('userprofile', response.data)
response = self.client.get('/userprofiles/{}/'.format(profile.pk),
content_type='application/ld+json')
self.assertEqual(response.data['description'], "user update")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment