From 9ae34685e2362545ae5a0abe9d195173d6addceb Mon Sep 17 00:00:00 2001 From: Marnanel Thurman Date: Sun, 14 Apr 2019 19:27:59 +0100 Subject: [PATCH] test_asyncresult -> test_tasks. Still updating this. --- tests/{test_asyncresult.py => test_tasks.py} | 17 +++++++++++++++-- things_for_testing/__init__.py | 15 +++------------ 2 files changed, 18 insertions(+), 14 deletions(-) rename tests/{test_asyncresult.py => test_tasks.py} (93%) diff --git a/tests/test_asyncresult.py b/tests/test_tasks.py similarity index 93% rename from tests/test_asyncresult.py rename to tests/test_tasks.py index b0995ef..1739f56 100644 --- a/tests/test_asyncresult.py +++ b/tests/test_tasks.py @@ -1,12 +1,25 @@ from django.test import TestCase, Client -from django_kepi.models import Activity, QuarantinedMessage, QuarantinedMessageNeeds +from django_kepi.models import Activity +from django_kepi.validation import CachedPublicKey, IncomingMessage from django_kepi import create from things_for_testing import KepiTestCase import logging import httpretty import json -class TestAsyncResult(KepiTestCase): +######################### +# Cases: +# - Request information; success +# - Request information; not found +# - Request information; GONE +# - Submit information; success +# - Submit information; fail +# +######################### + +logger = logging.getLogger(name='django_kepi') + +class TestTasks(KepiTestCase): @httpretty.activate def test_simple(self): diff --git a/things_for_testing/__init__.py b/things_for_testing/__init__.py index 5ebdaa8..39867e4 100644 --- a/things_for_testing/__init__.py +++ b/things_for_testing/__init__.py @@ -11,18 +11,9 @@ class KepiTestCase(TestCase): def _mock_remote_object(self, url, ftype = 'Object', - fields = None, + content = '', status = 200): - if fields is None: - fields = {} - - if 'id' not in fields: - fields['id'] = url - - if 'type' not in fields: - fields['type'] = ftype - headers = { 'Content-Type': 'application/activity+json', } @@ -32,12 +23,12 @@ class KepiTestCase(TestCase): url, status=status, headers=headers, - body=bytes(str(fields), encoding='UTF-8')) + body=bytes(content, encoding='UTF-8')) logger.debug('Mocking %s as %d: %s', url, status, - fields) + content) # For some reason, this allows Celery to # access /async_result in the test version;