Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • djangoldp-packages/djangoldp
  • decentral1se/djangoldp
  • femmefaytale/djangoldp
  • jvtrudel/djangoldp
4 results
Show changes
Showing
with 1740 additions and 369 deletions
# Generated by Django 4.2.3 on 2023-09-03 20:26
from django.db import migrations
import djangoldp.fields
class Migration(migrations.Migration):
dependencies = [
('djangoldp', '0016_alter_activity_options_alter_follower_options_and_more'),
]
operations = [
migrations.AlterField(
model_name='activity',
name='urlid',
field=djangoldp.fields.LDPUrlField(blank=True, db_index=True, null=True, unique=True),
),
migrations.AlterField(
model_name='follower',
name='urlid',
field=djangoldp.fields.LDPUrlField(blank=True, db_index=True, null=True, unique=True),
),
migrations.AlterField(
model_name='ldpsource',
name='urlid',
field=djangoldp.fields.LDPUrlField(blank=True, db_index=True, null=True, unique=True),
),
]
# Generated by Django 4.2.3 on 2023-10-17 19:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('djangoldp', '0017_alter_activity_urlid_alter_follower_urlid_and_more'),
]
operations = [
migrations.AlterField(
model_name='activity',
name='payload',
field=models.TextField(),
),
migrations.AlterField(
model_name='activity',
name='response_body',
field=models.TextField(null=True),
),
]
from django.contrib.auth.models import User
import json
import logging
import uuid
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.core.exceptions import ObjectDoesNotExist, ValidationError, FieldDoesNotExist
from django.db import models
from django.db.models.base import ModelBase
from django.db.models.signals import post_save, pre_save, pre_delete, m2m_changed
from django.dispatch import receiver
from django.urls import get_resolver
from django.utils.datastructures import MultiValueDictKeyError
from django.utils.decorators import classonlymethod
from guardian.shortcuts import assign_perm
from rest_framework.utils import model_meta
from djangoldp.fields import LDPUrlField
from djangoldp.permissions import DEFAULT_DJANGOLDP_PERMISSIONS, OwnerPermissions, InheritPermissions, ReadOnly
from djangoldp.permissions import LDPPermissions
logger = logging.getLogger('djangoldp')
User._meta.rdf_type = "foaf:user"
Group._meta.serializer_fields = ['name', 'user_set']
Group._meta.rdf_type = 'foaf:Group'
# Group._meta.rdf_context = {'user_set': 'foaf:member'}
Group._meta.permission_classes = [(OwnerPermissions&ReadOnly)|InheritPermissions]
Group._meta.owner_field = 'user'
Group._meta.inherit_permissions = []
class LDPModelManager(models.Manager):
def local(self):
'''an alternative to all() which exlcudes external resources'''
queryset = super(LDPModelManager, self).all()
internal_ids = [x.pk for x in queryset if not Model.is_external(x)]
return queryset.filter(pk__in=internal_ids)
class Model(models.Model):
urlid = LDPUrlField(blank=True, null=True, unique=True, db_index=True)
is_backlink = models.BooleanField(default=False, help_text='set automatically to indicate the Model is a backlink')
allow_create_backlink = models.BooleanField(default=True,
help_text='set to False to disable backlink creation after Model save')
objects = LDPModelManager()
@classmethod
def get_view_set(cls):
view_set = getattr(cls._meta, 'view_set', getattr(cls.Meta, 'view_set', None))
if view_set is None:
from djangoldp.views import LDPViewSet
view_set = LDPViewSet
return view_set
class Meta:
default_permissions = DEFAULT_DJANGOLDP_PERMISSIONS
abstract = True
depth = 0
def __init__(self, *args, **kwargs):
super(Model, self).__init__(*args, **kwargs)
@classmethod
def get_container_path(cls):
'''returns the url path which is used to access actions on this model (e.g. /users/)'''
path = getattr(cls._meta, 'container_path', getattr(cls.Meta, 'container_path', None))
if path is None:
path = "{}s".format(cls._meta.object_name.lower())
return path
return cls.__clean_path(path)
def get_absolute_url(self):
return Model.resource_id(self)
return Model.absolute_url(self)
@classonlymethod
def absolute_url(cls, instance_or_model):
if isinstance(instance_or_model, ModelBase) or not instance_or_model.urlid:
return '{}{}'.format(settings.SITE_URL, Model.resource(instance_or_model))
else:
return instance_or_model.urlid
def get_container_id(self):
return Model.container_id(self)
@classonlymethod
def resource(cls, instance_or_model):
if isinstance(instance_or_model, ModelBase):
return cls.container_id(instance_or_model)
else:
return cls.resource_id(instance_or_model)
@classonlymethod
def resource_id(cls, instance):
r_id = "{}{}".format(cls.container_id(instance), getattr(instance, cls.slug_field(instance)))
r_id = "{}{}".format(cls.container_id(instance), getattr(instance, cls.slug_field(instance), ""))
return cls.__clean_path(r_id)
@classonlymethod
def slug_field(cls, instance_or_model):
if isinstance(instance_or_model, ModelBase):
object_name = instance_or_model.__name__.lower()
model = instance_or_model
else:
object_name = instance_or_model._meta.object_name.lower()
model = type(instance_or_model)
# Use cached value if present
if hasattr(model, "_slug_field"):
return model._slug_field
object_name = model.__name__.lower()
view_name = '{}-detail'.format(object_name)
slug_field = '/{}'.format(get_resolver().reverse_dict[view_name][0][0][1][0])
try:
slug_field = '/{}'.format(get_resolver().reverse_dict[view_name][0][0][1][0])
except MultiValueDictKeyError:
slug_field = getattr(model._meta, 'lookup_field', 'pk')
if slug_field.startswith('/'):
slug_field = slug_field[1:]
model._slug_field = slug_field
return slug_field
@classonlymethod
......@@ -62,25 +118,44 @@ class Model(models.Model):
return path
class Meta:
default_permissions = ('add', 'change', 'delete', 'view', 'control')
abstract = True
depth = 0
@classonlymethod
def resolve_id(cls, id):
'''
Resolves the id of a given path (e.g. /container/1/)
Raises Resolver404 if the path cannot be found, ValidationError if the path is for a model base
and an ObjectDoesNotExist exception if the resource does not exist
'''
id = cls.__clean_path(id)
view, args, kwargs = get_resolver().resolve(id)
match = get_resolver().resolve(id)
kwargs = match.kwargs
view = match.func
if match.url_name.endswith('-list') or len(match.kwargs.keys()) == 0:
raise ValidationError('resolve_id received a path for a container or nested container')
return view.initkwargs['model'].objects.get(**kwargs)
@classonlymethod
def resolve_parent(cls, path):
split = path.strip('/').split('/')
parent_path = "/".join(split[:-1])
return Model.resolve_id(parent_path)
@classonlymethod
def resolve_container(cls, path):
'''retruns the model container of passed URL path'''
path = cls.__clean_path(path)
view, args, kwargs = get_resolver().resolve(path)
return view.initkwargs['model']
@classonlymethod
def resolve(cls, path):
'''
resolves the containing model and associated id in the path. If there is no id in the path returns None
:param path: a URL path to check
:return: the container model and resolved id in a tuple
'''
if path.startswith(settings.BASE_URL):
path = path.replace(settings.BASE_URL, '')
container = cls.resolve_container(path)
try:
resolve_id = cls.resolve_id(path)
......@@ -90,6 +165,7 @@ class Model(models.Model):
@classonlymethod
def __clean_path(cls, path):
'''ensures path is Django-friendly'''
if not path.startswith("/"):
path = "/{}".format(path)
if not path.endswith("/"):
......@@ -97,36 +173,199 @@ class Model(models.Model):
return path
@classonlymethod
def get_permission_classes(cls, related_model, default_permissions_classes):
return cls.get_meta(related_model, 'permission_classes', default_permissions_classes)
def get_or_create(cls, model, urlid, update=False, **field_tuples):
'''
gets an object with the passed urlid if it exists, creates it if not
:param model: the model class which the object belongs to
:param update: if set to True the object will be updated with the passed field_tuples
:param field_tuples: kwargs for the model creation/updating
:return: the object, fetched or created
:raises Exception: if the object does not exist, but the data passed is invalid
'''
try:
rval = model.objects.get(urlid=urlid)
if update:
for field in field_tuples.keys():
setattr(rval, field, field_tuples[field])
rval.save()
return rval
except ObjectDoesNotExist:
if model is get_user_model():
field_tuples['username'] = str(uuid.uuid4())
return model.objects.create(urlid=urlid, is_backlink=True, **field_tuples)
@classonlymethod
def get_meta(cls, model_class, meta_name, default=None):
if hasattr(model_class, 'Meta'):
meta = getattr(model_class.Meta, meta_name, default)
else:
meta = default
return getattr(model_class._meta, meta_name, meta)
def get_or_create_external(cls, model, urlid, **kwargs):
'''
checks that the parameterised urlid is external and then returns the result of Model.get_or_create
:raises ObjectDoesNotExist: if the urlid is not external and the object doesn't exist
'''
if not Model.is_external(urlid) and not model.objects.filter(urlid=urlid).exists():
raise ObjectDoesNotExist
return Model.get_or_create(model, urlid, **kwargs)
@classonlymethod
def get_subclass_with_rdf_type(cls, type):
#TODO: deprecate
'''returns Model subclass with Meta.rdf_type matching parameterised type, or None'''
if type == 'foaf:user':
return get_user_model()
for subcls in Model.__subclasses__():
if getattr(subcls._meta, "rdf_type", None) == type:
return subcls
return None
@staticmethod
def get_permissions(obj_or_model, user_or_group, filter):
permissions = filter
for permission_class in Model.get_permission_classes(obj_or_model, [LDPPermissions]):
permissions = permission_class().filter_user_perms(user_or_group, obj_or_model, permissions)
return [{'mode': {'@type': name.split('_')[0]}} for name in permissions]
@classmethod
def is_external(cls, value):
'''
:param value: string urlid or an instance with urlid field
:return: True if the urlid is external to the server, False otherwise
'''
try:
if not value:
return False
if not isinstance(value, str):
value = value.urlid
# This expects all @ids to start with http which mlight not be universal. Maybe needs a fix.
return value.startswith('http') and not value.startswith(settings.SITE_URL)
except:
return False
#TODO: this breaks the serializer, which probably assumes that traditional models don't have a urlid.
# models.Model.urlid = property(lambda self: '{}{}'.format(settings.SITE_URL, Model.resource(self)))
class LDPSource(models.Model):
container = models.URLField()
class LDPSource(Model):
federation = models.CharField(max_length=255)
class Meta:
rdf_type = 'sib:source'
class Meta(Model.Meta):
rdf_type = 'sib:federatedContainer'
ordering = ('federation',)
permissions = (
('view_source', 'acl:Read'),
('control_source', 'acl:Control'),
)
container_path = 'sources'
lookup_field = 'federation'
def __str__(self):
return "{}: {}".format(self.federation, self.container)
return "{}: {}".format(self.federation, self.urlid)
class Activity(Model):
'''Models an ActivityStreams Activity'''
local_id = LDPUrlField(help_text='/inbox or /outbox url (local - this server)') # /inbox or /outbox full url
external_id = LDPUrlField(null=True, help_text='the /inbox or /outbox url (from the sender or receiver)')
payload = models.TextField()
response_location = LDPUrlField(null=True, blank=True, help_text='Location saved activity can be found')
response_code = models.CharField(null=True, blank=True, help_text='Response code sent by receiver', max_length=8)
response_body = models.TextField(null=True)
type = models.CharField(null=True, blank=True, help_text='the ActivityStreams type of the Activity',
max_length=64)
is_finished = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)
success = models.BooleanField(default=False, help_text='set to True when an Activity is successfully delivered')
class Meta(Model.Meta):
container_path = "activities"
rdf_type = 'as:Activity'
disable_url = True
def to_activitystream(self):
return json.loads(self.payload)
def response_to_json(self):
return self.to_activitystream()
# temporary database-side storage used for scheduled tasks in the ActivityQueue
class ScheduledActivity(Activity):
failed_attempts = models.PositiveIntegerField(default=0,
help_text='a log of how many failed retries have been made sending the activity')
def save(self, *args, **kwargs):
self.is_finished = False
super(ScheduledActivity, self).save(*args, **kwargs)
class Meta(Model.Meta):
disable_url = True
class Follower(Model):
'''Models a subscription on a model. When the model is saved, an Update activity will be sent to the inbox'''
object = models.URLField(help_text='the object being followed')
inbox = models.URLField(help_text='the inbox recipient of updates')
follower = models.URLField(help_text='(optional) the resource/actor following the object', blank=True)
def __str__(self):
return 'Inbox ' + str(self.inbox) + ' on ' + str(self.object)
class Meta(Model.Meta):
disable_url = True
class DynamicNestedField:
'''
Used to define a method as a nested_field.
Usage:
LDPUser.circles = lambda self: Circle.objects.filter(members__user=self)
LDPUser.circles.field = DynamicNestedField(Circle, 'circles')
'''
related_query_name = None
one_to_many = False
many_to_many = True
many_to_one = False
one_to_one = False
read_only = True
name = ''
def __init__(self, model:models.Model|None, remote_name:str, name:str='', remote:object|None=None) -> None:
self.model = model
self.name = name
if remote:
self.remote_field = remote
else:
self.remote_field = DynamicNestedField(None, '', remote_name, self)
@receiver([post_save])
def auto_urlid(sender, instance, **kwargs):
if isinstance(instance, Model):
changed = False
if getattr(instance, Model.slug_field(instance), None) is None:
setattr(instance, Model.slug_field(instance), instance.pk)
changed = True
if (not instance.urlid or 'None' in instance.urlid):
instance.urlid = instance.get_absolute_url()
changed = True
if changed:
instance.save()
@receiver(post_save)
def create_role_groups(sender, instance, created, **kwargs):
if created:
for name, params in getattr(instance._meta, 'permission_roles', {}).items():
group, x = Group.objects.get_or_create(name=f'LDP_{instance._meta.model_name}_{name}_{instance.id}')
setattr(instance, name, group)
instance.save()
if params.get('add_author'):
assert hasattr(instance._meta, 'auto_author'), "add_author requires to also define auto_author"
author = getattr(instance, instance._meta.auto_author)
if author:
group.user_set.add(author)
for permission in params.get('perms', []):
assign_perm(f'{permission}_{instance._meta.model_name}', group, instance)
def invalidate_cache_if_has_entry(entry):
from djangoldp.serializers import GLOBAL_SERIALIZER_CACHE
if GLOBAL_SERIALIZER_CACHE.has(entry):
GLOBAL_SERIALIZER_CACHE.invalidate(entry)
def invalidate_model_cache_if_has_entry(model):
entry = getattr(model._meta, 'label', None)
invalidate_cache_if_has_entry(entry)
@receiver([pre_save, pre_delete])
def invalidate_caches(sender, instance, **kwargs):
invalidate_model_cache_if_has_entry(sender)
@receiver([m2m_changed])
def invalidate_caches_m2m(sender, instance, action, *args, **kwargs):
invalidate_model_cache_if_has_entry(kwargs['model'])
\ No newline at end of file
from rest_framework.pagination import LimitOffsetPagination
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
class LDPOffsetPagination(LimitOffsetPagination):
def get_paginated_response(self, data):
next_url = self.get_next_link()
previous_url = self.get_previous_link()
links = []
for url, label in ((previous_url, 'prev'), (next_url, 'next')):
if url is not None:
links.append('<{}>; rel="{}"'.format(url, label))
headers = {'Link': ', '.join(links)} if links else {}
return Response(data, headers=headers)
class LDPPagination(PageNumberPagination):
page_query_param = 'p'
page_size_query_param = 'limit'
def get_paginated_response(self, data):
next_url = self.get_next_link()
previous_url = self.get_previous_link()
links = []
for url, label in ((previous_url, 'prev'), (next_url, 'next')):
if url is not None:
links.append('<{}>; rel="{}"'.format(url, label))
headers = {'Link': ', '.join(links)} if links else {}
return Response(data, headers=headers)
This diff is collapsed.
from rest_framework.utils import model_meta
def get_prefetch_fields(model, serializer, depth, prepend_string=''):
'''
This method should then be used with queryset.prefetch_related, to auto-fetch joined resources (to speed up nested serialization)
This can speed up ModelViewSet and LDPViewSet alike by as high a factor as 2
:param model: the model to be analysed
:param serializer: an LDPSerializer instance. Used to extract the fields for each nested model
:param depth: the depth at which to stop the recursion (should be set to the configured depth of the ViewSet)
:param prepend_string: should be set to the default. Used in recursive calls
:return: set of strings to prefetch for a given model. Including serialized nested fields and foreign keys recursively
called on many-to-many fields until configured depth reached
'''
# the objective is to build a list of fields and nested fields which should be prefetched for the optimisation
# of database queries
fields = set()
# get a list of all fields which would be serialized on this model
# TODO: dynamically generating serializer fields is necessary to retrieve many-to-many fields at depth > 0,
# but the _all_ default has issues detecting reverse many-to-many fields
# meta_args = {'model': model, 'depth': 0, 'fields': getattr(model._meta, 'serializer_fields', '__all__')}
# meta_class = type('Meta', (), meta_args)
# serializer = (type(LDPSerializer)('TestSerializer', (LDPSerializer,), {'Meta': meta_class}))()
serializer_fields = set([f for f in serializer.get_fields()])
empty_containers = getattr(model._meta, 'empty_containers', [])
# we are only interested in foreign keys (and many-to-many relationships)
model_relations = model_meta.get_field_info(model).relations
for field_name, relation_info in model_relations.items():
# foreign keys can be added without fuss
if not relation_info.to_many:
fields.add((prepend_string + field_name))
continue
# nested fields should be added if serialized
if field_name in serializer_fields and field_name not in empty_containers:
fields.add((prepend_string + field_name))
# and they should also have their immediate foreign keys prefetched if depth not reached
if depth >= 0:
new_prepend_str = prepend_string + field_name + '__'
fields = fields.union(get_prefetch_fields(relation_info.related_model, serializer, depth - 1, new_prepend_str))
return fields
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
<title>Swagger</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@3/swagger-ui.css">
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
<script>
const ui = SwaggerUIBundle({
url: "{% url 'schema' %}",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
layout: "BaseLayout",
requestInterceptor: (request) => {
request.headers['X-CSRFToken'] = "{{ csrf_token }}"
return request;
}
})
</script>
</body>
</html>
\ No newline at end of file
"""
This module is meant to be used as a testing LDP package.
It contains configuration elements imported by a djangoldp-package
when the django server is setup.
"""
# define an extra variables
MYPACKAGEVAR = 'ok'
USE_I18N = False
# register an extra middleware
MIDDLEWARE = [
'djangoldp.tests.dummy.middleware.DummyMiddleware'
]
# register an extra installed app
INSTALLED_APPS = [
'djangoldp.tests.dummy.apps.DummyConfig'
]
SECRET_KEY = "$r&)p-4k@h5b!1yrft6&q%j)_p$lxqh6#)jeeu0z1iag&y&wdu"
from django.conf import settings
from django.conf.urls import url, include
from djangoldp.tests.models import Skill, JobOffer, Message, Conversation, Dummy
from django.urls import path
from djangoldp.tests.models import Message, Conversation, Dummy, PermissionlessDummy, Task, DateModel, LDPDummy
from djangoldp.permissions import ACLPermissions
from djangoldp.views import LDPViewSet
urlpatterns = [
url(r'^messages/', LDPViewSet.urls(model=Message, permission_classes=[], fields=["@id", "text", "conversation"], nested_fields=['conversation'])),
url(r'^conversations/', LDPViewSet.urls(model=Conversation, nested_fields=["message_set"], permission_classes=())),
url(r'^users/', LDPViewSet.urls(model=settings.AUTH_USER_MODEL, permission_classes=[])),
url(r'^dummys/', LDPViewSet.urls(model=Dummy, permission_classes=[], lookup_field='slug',)),
path('messages/', LDPViewSet.urls(model=Message, fields=["@id", "text", "conversation"], nested_fields=['conversation'])),
path('tasks/', LDPViewSet.urls(model=Task)),
path('conversations/', LDPViewSet.urls(model=Conversation, nested_fields=["message_set", "observers"])),
path('dummys/', LDPViewSet.urls(model=Dummy, lookup_field='slug',)),
path('permissionless-dummys/', LDPViewSet.urls(model=PermissionlessDummy, lookup_field='slug', permission_classes=[ACLPermissions])),
]
"""This module contains apps for testing."""
from django.apps import AppConfig
class DummyConfig(AppConfig):
# 'djangoldp.tests' is already registered as an installed app (it simulates a LDP package)
name = 'djangoldp.tests.dummy'
"""This module contains a dummy middleware for djangoldp testing."""
class DummyMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
return self.get_response(request)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Machine,Date,Auth,WithPermsCache,volume,test+AF8-get+AF8-resource,test+AF8-get+AF8-container,test+AF8-get+AF8-filtered+AF8-fields,test+AF8-get+AF8-reverse+AF8-filtered+AF8-fields,test+AF8-get+AF8-nested,test+AF8-get+AF8-users+AF8-container,Prefetch,default depth
jbl+AC0-T440p,Sep 22 2020 10:50:51,False,False,200,0.003339644670486,0.006944504976273,0.038935685157776,0.024031536579132,0.000708421468735,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:51:46,False,False,200,0.0035072016716,0.006944673061371,0.039835988283157,0.025360778570175,0.000757339000702,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:52:42,False,False,200,0.003284044265747,0.006942090988159,0.038870732784271,0.023859632015228,0.000705161094666,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:53:16,False,False,100,0.003656179904938,0.005776383876801,0.025797350406647,0.01539302110672,0.000770201683044,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:53:33,False,False,100,0.003554759025574,0.005703027248383,0.024777753353119,0.015221126079559,0.000770528316498,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:53:49,False,False,100,0.003367004394531,0.005602278709412,0.023594326972962,0.014168989658356,0.000726828575134,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:54:03,False,False,50,0.003355793952942,0.005232772827148,0.016062431335449,0.009248399734497,0.000776686668396,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:54:09,False,False,50,0.003454508781433,0.005315055847168,0.016247057914734,0.009447617530823,0.00073832988739,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:54:15,False,False,50,0.003420171737671,0.005717425346375,0.016275815963745,0.009424614906311,0.001325125694275,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:57:41,False,False,300,0.003357520103455,0.009047945340474,0.055130259990692,0.033688295682271,0.000706691741943,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 10:59:35,False,False,300,0.003680046399434,0.009138919512431,0.056478141943614,0.0363059147199,0.000769446690877,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 11:01:29,False,False,300,0.003643860816956,0.008885918458303,0.059775860309601,0.035221153100332,0.000756018956502,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 11:47:40,False,False,100,0.003384988307953,0.006034939289093,0.024095425605774,0.014140074253082,0.000722093582153,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 11:47:57,False,False,100,0.003611071109772,0.005775241851807,0.023724327087402,0.014749829769135,0.000745611190796,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 11:48:15,False,False,100,0.003316740989685,0.005551462173462,0.023505146503449,0.014274184703827,0.000737235546112,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 11:51:06,False,False,200,0.003252120018005,0.006922056674957,0.038872839212418,0.025012502670288,0.000715854167938,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 11:52:07,False,False,200,0.003315222263336,0.007173013687134,0.039467182159424,0.0239526450634,0.000736322402954,,FALSE,0
jbl+AC0-T440p,Sep 22 2020 11:53:59,False,False,200,0.003276619911194,0.006898198127747,0.038627609014511,0.023467609882355,0.000708512067795,,FALSE,0
jbl+AC0-T440p,Sep 23 2020 15:19:39,True,False,100,0.006617827415466,0.245147013664246,0.261345520019531,0.209938230514526,0.001274492740631,0.01203465461731,TRUE,0
jbl+AC0-T440p,Sep 23 2020 15:23:58,True,False,100,0.006518981456757,0.263970799446106,0.139407794475555,0.113074848651886,0.001235642433167,0.642078399658203,TRUE,0
jbl+AC0-T440p,Sep 23 2020 15:25:33,True,False,100,0.006539282798767,0.263329057693481,0.143536510467529,0.115545327663422,0.00125715970993,0.520937442779541,TRUE,0
jbl+AC0-T440p,Sep 23 2020 15:47:31,True,True,100,0.003864502906799,0.019258742332459,0.01636646270752,0.008915212154388,0.000782597064972,0.354249000549316,TRUE,0
jbl+AC0-T440p,Sep 23 2020 15:48:30,True,True,100,0.003590517044067,0.019879310131073,0.016916983127594,0.009615495204926,0.000798478126526,0.364127635955811,TRUE,0
jbl+AC0-T440p,Sep 23 2020 15:49:19,True,True,100,0.003716588020325,0.023860175609589,0.016380727291107,0.009003615379334,0.000774307250977,0.35044002532959,TRUE,0
jbl+AC0-T440p,Sep 23 2020 16:56:57,True,True,100,0.004425497055054,0.019956090450287,0.017114706039429,0.010911240577698,0.000832149982452,0.336694478988647,TRUE,0
jbl+AC0-T440p,Sep 23 2020 16:57:23,True,True,100,0.004397692680359,0.021222379207611,0.01826550245285,0.010625832080841,0.000812151432037,0.344640016555786,TRUE,0
jbl+AC0-T440p,Sep 23 2020 16:57:45,True,True,100,0.004602279663086,0.020297501087189,0.017129955291748,0.010850946903229,0.000865814685822,0.339866161346436,TRUE,0
jbl+AC0-T440p,Sep 23 2020 16:58:37,True,True,200,0.004463336467743,0.036689649820328,0.025502071380615,0.015932221412659,0.000898872613907,0.681740045547485,TRUE,0
jbl+AC0-T440p,Sep 23 2020 16:59:37,True,True,200,0.004517335891724,0.036278907060623,0.025654143095017,0.01576028585434,0.000849905014038,0.660790681838989,TRUE,0
jbl+AC0-T440p,Sep 23 2020 17:14:05,True,False,100,0.006808481216431,0.252511320114136,0.139744215011597,0.111351528167725,0.001188087463379,0.564764976501465,TRUE,0
jbl+AC0-T440p,Sep 23 2020 17:16:58,True,False,100,0.006502165794373,0.242799952030182,0.137602522373199,0.108403618335724,0.001143708229065,0.556174516677856,TRUE,0
jbl+AC0-T440p,Sep 24 2020 06:53:53,True,False,100,0.007479875087738,0.252197952270508,0.141312582492828,0.109222292900085,0.001601278781891,0.52592396736145,TRUE,0
jbl+AC0-T440p,Sep 24 2020 06:56:06,True,False,100,0.020340206623077,1.31586099863052,0.729812262058258,0.577438371181488,0.00078241109848,1.78533124923706,FALSE,0
jbl+AC0-T440p,Sep 24 2020 07:04:00,True,False,100,0.006233677864075,0.242916750907898,0.135480484962463,0.10392139673233,0.000762076377869,0.569819927215576,TRUE,0
jbl+AC0-T440p,Sep 24 2020 07:05:19,True,True,100,0.006471273899078,0.023659512996674,0.020732533931732,0.015365273952484,0.000769484043121,0.549034357070923,FALSE,0
jbl+AC0-T440p,Sep 24 2020 07:05:50,True,True,100,0.005183663368225,0.021180493831635,0.016473467350006,0.010494797229767,0.000771188735962,0.321053028106689,TRUE,0
jbl+AC0-T440p,Sep 24 2020 07:33:51,True,True,100,0.004018228054047,0.019896368980408,0.024588730335236,0.015463829040527,0.000797684192657,0.375835657119751,TRUE,0
jbl+AC0-T440p,Oct 08 2020 15:01:01,True,True,100,0.004086337089539,0.022444577217102,1.26581408977509,0.014725821018219,0.002466685771942,0.310548305511475,TRUE,1
jbl+AC0-T440p,Oct 08 2020 15:25:42,True,True,100,0.004928917884827,0.020494124889374,1.19440255403519,0.01545866727829,0.000807287693024,0.304153442382812,TRUE,1
jbl+AC0-T440p,Oct 08 2020 15:44:13,True,True,100,0.00410740852356,0.020648219585419,1.24338629007339,0.01569117307663,0.00077033996582,0.33369255065918,TRUE,1
jbl+AC0-T440p,Oct 08 2020 16:19:05,True,True,100,0.004798595905304,0.022070643901825,1.24563392400742,0.015214123725891,0.000787632465363,0.333659410476685,TRUE,1
jbl+AC0-T440p,Oct 09 2020 11:23:54,True,True,100,0.004018263816834,0.020824022293091,1.16614150524139,0.015614166259766,0.000755190849304,0.34318208694458,TRUE,1
jbl+AC0-T440p,Oct 09 2020 11:54:15,True,True,100,0.003045120239258,0.005557940006256,0.009205477237701,0.003398790359497,0.00073746919632,0.356267929077148,TRUE,1
jbl+AC0-T440p,Oct 09 2020 11:56:19,True,True,100,0.003119325637817,0.005602471828461,0.009082851409912,0.003396863937378,0.000744948387146,0.303446769714356,TRUE,2
jbl+AC0-T440p,Oct 09 2020 11:58:22,True,True,100,0.003008058071136,0.005401248931885,0.010658957958222,0.003909242153168,0.000718443393707,0.301162958145142,TRUE,3
jbl+AC0-T440p,Oct 09 2020 11:59:16,True,True,100,0.003015418052673,0.005526115894318,0.010740044116974,0.00400491476059,0.000724492073059,0.313828229904175,TRUE,4
jbl+AC0-T440p,Oct 09 2020 12:00:32,True,True,100,0.002969658374786,0.005434756278992,0.018136837482452,0.003030817508698,0.000726938247681,0.320115327835083,TRUE,0
jbl+AC0-T440p,Oct 09 2020 12:21:00,True,True,100,0.003493466377258,0.006103293895721,0.01923253774643,0.003091294765472,0.000737550258636,0.369867086410522,TRUE,0
jbl+AC0-T440p,Oct 15 2020 22:00:10,True,True,100,0.003004941940308,0.00546817779541,0.018348352909088,0.003068554401398,0.000729415416718,0.320573329925537,TRUE,0
jbl+AC0-T440p,Oct 15 2020 22:15:26,True,True,100,0.003350086212158,0.005898218154907,0.011625332832337,0.004264788627625,0.000795011520386,0.319289922714233,TRUE,1
import sys
import yaml
import django
from django.conf import settings as django_settings
from djangoldp.conf.ldpsettings import LDPSettings
from djangoldp.tests.server_settings import yaml_config
# load test config
config = yaml.safe_load(yaml_config)
ldpsettings = LDPSettings(config)
django_settings.configure(ldpsettings,
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': None
},
ANONYMOUS_USER_NAME=None)
django.setup()
from django.test.runner import DiscoverRunner
test_runner = DiscoverRunner(verbosity=1)
failures = test_runner.run_tests([
# 'djangoldp.tests.tests_performance',
'djangoldp.tests.tests_perf_get'
])
if failures:
sys.exit(failures)