예제 #1
0
    def test_process_event_task_no_credentials(
        self, ds_util_client_get_mock, ds_util_client_put_mock, withings_worker_mock
    ):

        service = Entity(ds_util.client.key('Service', 'withings'))
        Service._set_defaults(service)
        _setup_service_get_put(
            service, ds_util_client_get_mock, ds_util_client_put_mock
        )

        event_entity = Entity(
            ds_util.client.key('SubscriptionEvent', parent=service.key)
        )

        r = self.client.post(
            '/tasks/event',
            data=task_util.task_body_for_test(event=event_entity),
        )
        responses.assertResponse(self, responses.OK_NO_CREDENTIALS, r)
        withings_worker_mock.assert_not_called()
예제 #2
0
    def test_process_event_task_valid_strava(
        self, ds_util_client_get_mock, ds_util_client_put_mock, strava_worker_mock
    ):

        service = Entity(ds_util.client.key('Service', 'strava'))
        Service._set_defaults(service)
        service['credentials'] = {'refresh_token': 'validrefreshtoken'}
        _setup_service_get_put(
            service, ds_util_client_get_mock, ds_util_client_put_mock
        )

        event_entity = Entity(
            ds_util.client.key('SubscriptionEvent', parent=service.key)
        )

        r = self.client.post(
            '/tasks/event',
            data=task_util.task_body_for_test(event=event_entity),
        )
        responses.assertResponse(self, responses.OK, r)
        strava_worker_mock.assert_called_once()