Fix tests

This commit is contained in:
halcy 2022-11-25 00:09:54 +02:00
parent cbfb3977eb
commit 89678e0565
2 changed files with 6 additions and 7 deletions

View File

@ -3647,11 +3647,8 @@ class Mastodon:
else: else:
json_object[k] = dateutil.parser.parse(v) json_object[k] = dateutil.parser.parse(v)
except: except:
if isinstance(v, str) and len(v.strip()) == 0: # When we can't parse a date, we just leave the field out
# Pleroma bug workaround: Empty string becomes start of epoch del json_object[k]
json_object[k] = datetime.datetime.fromtimestamp(0)
else:
raise MastodonAPIError('Encountered invalid date.')
return json_object return json_object
@staticmethod @staticmethod

View File

@ -9,7 +9,9 @@ def test_constructor_from_filenames(tmpdir):
access.write_text(u'baz\n', 'UTF-8') access.write_text(u'baz\n', 'UTF-8')
api = Mastodon( api = Mastodon(
str(client), str(client),
access_token=str(access)) access_token=str(access),
api_base_url="mastodon.social"
)
assert api.client_id == 'foo' assert api.client_id == 'foo'
assert api.client_secret == 'bar' assert api.client_secret == 'bar'
assert api.access_token == 'baz' assert api.access_token == 'baz'