From 64bd2150a43ea823400ac8c4fd3f59b345f6aa3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 4 Jan 2019 12:46:37 +0100 Subject: [PATCH] AbstractPillarTest.create_valid_auth_token() now also accepts string user ID Strings were already passed to this function, even though it was declared as taking an ObjectID. Instead of updating all callers, I just made it convert strings to ObjectID. --- pillar/tests/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pillar/tests/__init__.py b/pillar/tests/__init__.py index b502f9d0..4286fb90 100644 --- a/pillar/tests/__init__.py +++ b/pillar/tests/__init__.py @@ -351,13 +351,15 @@ class AbstractPillarTest(TestMinimal): # TODO: rename to 'create_auth_token' now that 'expire_in_days' can be negative. def create_valid_auth_token(self, - user_id: ObjectId, + user_id: typing.Union[str, ObjectId], token='token', *, oauth_scopes: typing.Optional[typing.List[str]]=None, expire_in_days=1) -> dict: from pillar.api.utils import utcnow + if isinstance(user_id, str): + user_id = ObjectId(user_id) future = utcnow() + datetime.timedelta(days=expire_in_days) with self.app.test_request_context():