updates test data and serialization

This commit is contained in:
Mouse Reeve 2020-11-02 16:23:18 -08:00
parent 8a4e00c6b9
commit 0c73a1f42e
6 changed files with 64 additions and 75 deletions

View file

@ -68,7 +68,6 @@ class ActivitypubMixin:
if not hasattr(self, mapping.model_key) or not mapping.activity_key: if not hasattr(self, mapping.model_key) or not mapping.activity_key:
continue continue
value = getattr(self, mapping.model_key) value = getattr(self, mapping.model_key)
print(value)
if hasattr(value, 'local_id'): if hasattr(value, 'local_id'):
value = value.local_id value = value.local_id
elif hasattr(value, 'remote_id'): elif hasattr(value, 'remote_id'):

View file

@ -50,5 +50,5 @@ class BookWyrmConnector(TestCase):
def test_get_date(self): def test_get_date(self):
date = get_date(self.edition_data['published_date']) date = get_date(self.edition_data['published_date'])
expected = parser.parse("2017-05-10T00:00:00+00:00") expected = parser.parse("2020-09-15T00:00:00+00:00")
self.assertEqual(date, expected) self.assertEqual(date, expected)

View file

@ -1,42 +1,40 @@
{ {
"@context": "https://www.w3.org/ns/activitystreams", "id": "https://bookwyrm.social/book/5989",
"type": "Document", "type": "Edition",
"book_type": "Edition",
"name": "Jonathan Strange and Mr Norrell",
"url": "https://example.com/book/122",
"authors": [ "authors": [
"https://example.com/author/25" "https://bookwyrm.social/author/417"
], ],
"published_date": "2017-05-10T00:00:00+00:00", "first_published_date": null,
"work": { "published_date": "2020-09-15T00:00:00+00:00",
"@context": "https://www.w3.org/ns/activitystreams", "title": "Piranesi",
"type": "Document", "sort_title": null,
"book_type": "Work", "subtitle": null,
"name": "Jonathan Strange and Mr Norrell", "description": "Piranesi's house is no ordinary building; its rooms are infinite, its corridors endless, its walls are lined with thousands upon thousands of statues, each one different from all the others. Within the labyrinth of halls an ocean is imprisoned; waves thunder up staircases, rooms are flooded in an instant. But Piranesi is not afraid; he understands the tides as he understands the pattern of the labyrinth itself. He lives to explore the house.\r\n\r\nThere is one other person in the house--a man called The Other, who visits Piranesi twice a week and asks for help with research into A Great and Secret Knowledge. But as Piranesi explores, evidence emerges of another person, and a terrible truth begins to unravel, revealing a world beyond the one Piranesi has always known.\r\n\r\nFor readers of Neil Gaiman's The Ocean at the End of the Lane and fans of Madeline Miller's Circe, Piranesi introduces an astonishing new world, an infinite labyrinth full of startling images of surreal beauty, haunted by the tides and the clouds.",
"url": "https://example.com/book/121", "languages": [
"authors": [ "English"
"https://example.com/author/25" ],
], "series": null,
"title": "Jonathan Strange and Mr Norrell", "series_number": null,
"attachment": [ "subjects": [],
{ "subject_places": [],
"type": "Document", "openlibrary_key": "OL29486417M",
"mediaType": "image/jpg", "librarything_key": null,
"url": "https://example.com/images/covers/8775540-M.jpg", "goodreads_key": null,
"name": "Cover of \"Jonathan Strange and Mr Norrell\""
}
]
},
"title": "Jonathan Strange and Mr Norrell",
"subtitle": "Bloomsbury Modern Classics",
"isbn_13": "9781408891469",
"physical_format": "paperback",
"attachment": [ "attachment": [
{ {
"type": "Document", "url": "https://bookwyrm.social/images/covers/50202953._SX318_.jpg",
"mediaType": "image/jpg", "type": "Image"
"url": "https://example.com/images/covers/9155821-M.jpg",
"name": "Cover of \"Jonathan Strange and Mr Norrell\""
} }
] ],
"isbn_10": "1526622424",
"isbn_13": "9781526622426",
"oclc_number": null,
"asin": null,
"pages": 272,
"physical_format": null,
"publishers": [
"Bloomsbury Publishing Plc"
],
"work": "https://bookwyrm.social/book/5988",
"@context": "https://www.w3.org/ns/activitystreams"
} }

View file

@ -1,44 +1,36 @@
{ {
"@context": "https://www.w3.org/ns/activitystreams", "id": "https://bookwyrm.social/book/5988",
"type": "Document", "type": "Work",
"book_type": "Work",
"name": "Jonathan Strange and Mr Norrell",
"url": "https://example.com/book/121",
"authors": [ "authors": [
"https://example.com/author/25" "https://bookwyrm.social/author/417"
], ],
"editions": [ "first_published_date": null,
{ "published_date": null,
"@context": "https://www.w3.org/ns/activitystreams", "title": "Piranesi",
"type": "Document", "sort_title": null,
"book_type": "Edition", "subtitle": null,
"name": "Jonathan Strange and Mr Norrell", "description": "**From the *New York Times* bestselling author of *Jonathan Strange & Mr. Norrell*, an intoxicating, hypnotic new novel set in a dreamlike alternative reality.**\r\n\r\nPiranesi's house is no ordinary building; its rooms are infinite, its corridors endless, its walls are lined with thousands upon thousands of statues, each one different from all the others. Within the labyrinth of halls an ocean is imprisoned; waves thunder up staircases, rooms are flooded in an instant. But Piranesi is not afraid; he understands the tides as he understands the pattern of the labyrinth itself. He lives to explore the house.\r\n\r\nThere is one other person in the house--a man called The Other, who visits Piranesi twice a week and asks for help with research into A Great and Secret Knowledge. But as Piranesi explores, evidence emerges of another person, and a terrible truth begins to unravel, revealing a world beyond the one Piranesi has always known.\r\n\r\nFor readers of Neil Gaiman's *The Ocean at the End of the Lane* and fans of Madeline Miller's *Circe*, *Piranesi* introduces an astonishing new world, an infinite labyrinth full of startling images of surreal beauty, haunted by the tides and the clouds.\r\n\r\nThis description comes from the publisher.",
"url": "https://example.com/book/122", "languages": [],
"authors": [ "series": null,
"https://example.com/author/25" "series_number": null,
], "subjects": [
"published_date": "2017-05-10T00:00:00+00:00", "English literature"
"title": "Jonathan Strange and Mr Norrell",
"subtitle": "Bloomsbury Modern Classics",
"isbn_13": "9781408891469",
"physical_format": "paperback",
"attachment": [
{
"type": "Document",
"mediaType": "image/jpg",
"url": "https://example.com/images/covers/9155821-M.jpg",
"name": "Cover of \"Jonathan Strange and Mr Norrell\""
}
]
}
], ],
"title": "Jonathan Strange and Mr Norrell", "subject_places": [],
"openlibrary_key": "OL20893680W",
"librarything_key": null,
"goodreads_key": null,
"attachment": [ "attachment": [
{ {
"type": "Document", "url": "https://bookwyrm.social/images/covers/10226290-M.jpg",
"mediaType": "image/jpg", "type": "Image"
"url": "https://example.com/images/covers/8775540-M.jpg",
"name": "Cover of \"Jonathan Strange and Mr Norrell\""
} }
] ],
"lccn": null,
"editions": [
"https://bookwyrm.social/book/5989",
"OL28439584M",
"OL28300471M"
],
"@context": "https://www.w3.org/ns/activitystreams"
} }

View file

@ -50,7 +50,7 @@ class User(TestCase):
self.assertEqual(activity['inbox'], self.user.inbox) self.assertEqual(activity['inbox'], self.user.inbox)
self.assertEqual(activity['outbox'], self.user.outbox) self.assertEqual(activity['outbox'], self.user.outbox)
self.assertEqual(activity['followers'], self.user.ap_followers) self.assertEqual(activity['followers'], self.user.ap_followers)
self.assertEqual(activity['bookwyrmUser'], False) self.assertEqual(activity['bookwyrmUser'], True)
self.assertEqual(activity['discoverable'], True) self.assertEqual(activity['discoverable'], True)
self.assertEqual(activity['type'], 'Person') self.assertEqual(activity['type'], 'Person')

View file

@ -61,7 +61,7 @@ class Signature(TestCase):
digest=None, digest=None,
date=None): date=None):
now = date or http_date() now = date or http_date()
data = json.dumps(get_follow_data(sender, self.rat)).encode('utf-8') data = json.dumps(get_follow_data(sender, self.rat))
digest = digest or make_digest(data) digest = digest or make_digest(data)
signature = make_signature( signature = make_signature(
signer or sender, self.rat.inbox, now, digest) signer or sender, self.rat.inbox, now, digest)