Wykres commitów

75 Commity (commandline)

Autor SHA1 Wiadomość Data
Marnanel Thurman 94309cc77d KepiTestCase
The only difference from django.test.TestCase is that KepiTestCase
redirects logging to stdout in setUp, and undoes it again in
tearDown. This is because Django's "./manage.py test" suppresses
stderr, so you can't read the debug logs otherwise.

Put into use in a couple of files where it was needed immediately.
Will add more later.
2023-09-22 16:36:51 +01:00
Marnanel Thurman 8a0deb6c93 AppConfigs set default_auto_field
Django used to default this, but it generates a warning now.
2023-09-22 16:36:47 +01:00
Marnanel Thurman 37d53b2e4e Status.content and Status.spoiler_text are now Status.content_source and Status.spoiler_source.
HTML renderings of each one are cached. You can access them at Status.content_as_html
and Status.spoiler_as_html.
2021-02-16 22:58:42 +00:00
Marnanel Thurman ac9fb3d2bf sombrero's fake HttpRequest for ACTIVITY_GET requests supplies an Accept header.
Otherwise it doesn't get routed to the right view now that we route based on Accept.
2020-11-25 19:36:48 +00:00
Marnanel Thurman 4903af61fc Drop sombrero's test_send. The idea is flawed and nothing in it works anyway. 2020-10-29 23:08:18 +00:00
Marnanel Thurman 65593a41e1 fix a test in test_send 2020-10-27 19:07:45 +00:00
Marnanel Thurman 4fbad0a949 Removed loads of @skip decorators from tests, as part of issue 47.
Tests now fail quite a lot. :)
2020-10-26 22:29:55 +00:00
Marnanel Thurman ba27b594a2 Deserialisation methods were split between sombrero_sendpub.fetch() and bowler_pub.create(). They're now all in create().
Tests updated.

test_announce filled in and made to pass. Closes issue #45.
2020-10-19 16:54:22 +01:00
Marnanel Thurman b6d5039f6c rename url to remote_url per policy 2020-10-19 16:52:43 +01:00
Marnanel Thurman 5d6c209fde Collection ends iteration gracefully if a page can't be found.
Also renamed __init__'s url param to remote_url, per policy.
2020-10-19 16:48:39 +01:00
Marnanel Thurman 4eabf2dd1a sombrero gains "Failure" model to record HTTP failures 2020-10-19 16:22:14 +01:00
Marnanel Thurman df35f1c389 Sombrero notifies remote users when a local status is posted.
Closes issue #42.
2020-10-10 02:17:05 +01:00
Marnanel Thurman b5a7f7114d Attempts to fetch(None) get None.
It sometimes happens in the wild that someone submits "inReplyTo: null" or similar.
2020-09-30 16:13:02 +01:00
Marnanel Thurman dbc5e47b4b Messages posted to user inboxes, and to the shared inbox, will be acted upon.
Closes issue #37.
2020-09-21 18:10:34 +01:00
Marnanel Thurman 513c2d52e5 logger.warn is now logger.warning (pylint W1505) 2020-09-19 16:25:31 +01:00
Marnanel Thurman 1ce2d41e1e Updated all copyright dates to 2020 2020-09-19 16:18:32 +01:00
Marnanel Thurman 48fbb745de removed trailing whitespace throughout (pylint C0303) 2020-09-19 15:58:35 +01:00
Marnanel Thurman 0a9d266305 test_send_to_followers_of_remote_user() implemented and passing. 2020-09-19 14:42:57 +01:00
Marnanel Thurman c22f8d7c0e If fetch() rejects a message because the JSON was malformed, show the JSON parsing error in the log. 2020-09-19 14:42:31 +01:00
Marnanel Thurman 193faf061b Sombrero's test_delivery gains test_send_to_remote_user().
Thanks to Patrick Gosling for pointing out that lambdas in a loop need their own copies of a closure variable!
https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result
2020-09-19 12:52:00 +01:00
Marnanel Thurman 1f57997802 Several small fixes related to code moved out of a previous version
which hadn't yet been tested.
2020-09-19 12:51:25 +01:00
Marnanel Thurman c1368cd128 sombrero's test_delivery has assertions in. (The previous stub version didn't.)
The tests for remote delivery are still unimplemented. Soon.
2020-09-16 23:18:25 +01:00
Marnanel Thurman d02042f247 bowler's Collection views refactored. It feels a bit like being the redactor of the book of Genesis.
The refactoring is more complicated than it sounds. The file activitypub.py
was created by merging two sets of views from the old bowler_heavy
branch. This resulted in two classes called InboxView, and of course
the second one in the file won out. I have merged them and fixed
the errors therein.

As part of this, I have discovered that d-r-f adds the requirement
that view methods return HttpResponse objects. Therefore we've had
to add a new class, ActivityResponse, whose only purpose is to
get around this requirement.

fetch() has been updated as appropriate.
2020-09-16 23:14:38 +01:00
Marnanel Thurman 5539aec729 Sombrero uses "inbox_url" rather than "inbox" on Trilby's Persons.
This should have been in commit 66373041, but it wasn't.
2020-09-16 01:09:02 +01:00
Marnanel Thurman 66373041e7 Trilby keeps track of all the URLs given for a RemotePerson. 2020-09-15 17:59:47 +01:00
Marnanel Thurman a02a7a302c extra debug statement 2020-09-15 17:59:07 +01:00
Marnanel Thurman 3173249da1 Initialise some variables that weren't 2020-09-15 17:41:31 +01:00
Marnanel Thurman c4cf668cc2 Partial checkin: deliver() now iterates over a given user's followers. This is insufficiently tested as yet.
deliver()'s target_people param now has a default of [], for parallelism with target_followers_of.
2020-09-14 01:15:27 +01:00
Marnanel Thurman 4530a517ca Intermediate checkin: major overhaul of deliver() to meet the requirements of issue #40.
Tests for local delivery added. These tests don't yet check the results. When they do, they will fail because of
issue #37.

No tests for remote delivery yet. They're coming soon.
2020-09-10 23:25:31 +01:00
Marnanel Thurman f5e040d746 Sombrero's fetch() can now retrieve Collections and OrderedCollections.
Tests updated.
2020-09-09 23:55:55 +01:00
Marnanel Thurman 26a56611a2 log_one_message, a start at a common logging system for messages.
Submitted messages aren't currently logged because the whole
message submission system is currently broken.
2020-09-03 15:23:50 +01:00
Marnanel Thurman 0ab9fecea4 suppress_thread_exceptions doesn't fail under Python 3.6.
It uses threading.excepthook, which doesn't exist in pre-3.8 Python. But there's no need to break all the tests under 3.6.

suppress_thread_exceptions was introduced in commit 001698cd.
2020-08-24 19:16:03 +01:00
Marnanel Thurman f4d05bba40 Cleaning up header blocks, and making sure we use getLogger instead of creating a new one in each module 2020-08-23 17:40:54 +01:00
Marnanel Thurman f0d9a7203e create(), when asked to look up something atstyle, checks that it's a Person.
Previously this always failed because 1) "isinstance" was typoed as "isintance" and 2) "issubclass" was what was needed anyway.

Test now passes.
2020-08-23 00:18:18 +01:00
Marnanel Thurman 33555806e8 The great types in trilby_api, Person and Status, now have
local_form() and remote_form() class methods. This is to
allow fetch() to check whether something is already cached
before fetching it.

LocalPerson also gains a status() method for symmetry with
RemotePerson; it always returns 200.

Tests updated.
2020-08-22 22:26:22 +01:00
Marnanel Thurman 1278fca221 test_expected_localtype() was reversed in sense; fixed 2020-08-06 23:00:57 +01:00
Marnanel Thurman 404e418a26 fetch() checks return type for local urls 2020-08-06 23:00:32 +01:00
Marnanel Thurman 99cff55897 fetch() implemented for local URLs. The views haven't yet been adapted,
so the tests still fail.

Much of this code was adapted from old stuff in the bowler-heavy branch.
2020-08-06 19:42:57 +01:00
Marnanel Thurman af9541233d fetch() -- local by atstyle. Local by url still to be implemented. 2020-08-06 19:30:31 +01:00
Marnanel Thurman 37241441a9 test_fetch errors fixed-- missing import & formal param name 2020-08-06 19:14:27 +01:00
Marnanel Thurman 9efa1fafda Added tests for localhost fetch(); they all fail at present because it isn't implemented yet 2020-08-05 17:02:29 +01:00
Marnanel Thurman 824fad0ba9 docstring for fetch() 2020-08-05 15:49:42 +01:00
Marnanel Thurman a26e26e946 moving _parse_address() down beneath fetch() so fetch() is at the top of the file 2020-08-05 15:34:02 +01:00
Marnanel Thurman da12b10a47 Major refactor of fetch(). Tests pass.
This is so that we can implement fetches of local objects.
I haven't yet done that, but it's coming up soon.
2020-08-05 15:32:03 +01:00
Marnanel Thurman 83f30d26db Logging is now via getLogger(name="kepi"), and this is done
before any other imports. This change is only partially finished;
it affects nothing except the logging but it should happen in all
the source files. There's just a lot of them.
2020-08-04 17:19:37 +01:00
Marnanel Thurman ccd1b0c26b fetch() rewritten to replace fetch_user() and fetch_status();
it now fetches anything, then checks the type.
Tests updated.

If create() is passed a dict where the "object" is a URL,
it fetches that URL and replaces "object" with its contents.
2020-08-04 17:19:17 +01:00
Marnanel Thurman 8c5637726b If get_webfinger() says the status is 0 (i.e. couldn't even connect),
fetch() doesn't amend that to 404.

test_fetch uses suppress_thread_exceptions, as added in commit 001698cd.
2020-08-03 20:16:29 +01:00
Marnanel Thurman 0ab2dae738 fetch() returns the existing record for a known remote user,
instead of fetching it again
2020-08-03 20:06:06 +01:00
Marnanel Thurman 001698cda6 Sombrero's webfinger support doesn't break if the remote host is unreachable
or times out. Tests updated.

Sombrero webfinger tests gain a context manager suppress_thread_exceptions(), to stop spurious exceptions being
reported if they occur in threads other than the main thread. See https://stackoverflow.com/questions/63206653/ .
2020-08-03 19:43:20 +01:00
Marnanel Thurman 3a34ee7a6c Make sombrero support webfinger more completely.
Added tests, and some of them still fail.
2020-08-01 00:26:56 +01:00