Example #1
0
 def test_do_called(self, sync_helper_do_mock):
     r = self.client.post(
         '/tasks/livetrack',
         data=task_util.task_body_for_test(url='http://anyurl',
                                           publish=False),
     )
     self.assertTrue(sync_helper_do_mock.called)
     responses.assertResponse(self, responses.OK, r)
Example #2
0
    def test_process_event_task_no_service(
        self, ds_util_client_get_mock, ds_util_client_put_mock, withings_worker_mock
    ):
        _setup_service_get_put(None, ds_util_client_get_mock, ds_util_client_put_mock)

        event_entity = Entity(ds_util.client.key('SubscriptionEvent'))

        r = self.client.post(
            '/tasks/event',
            data=task_util.task_body_for_test(event=event_entity),
        )
        responses.assertResponse(self, responses.OK_NO_SERVICE, r)
        withings_worker_mock.assert_not_called()
Example #3
0
    def test_process_link_shared_called(self, slack_process_link_shared_mock):
        event_entity = Entity(
            ds_util.client.key('SubscriptionEvent', 'slack-E232eq2ee')
        )
        event_entity.update(LINK_SHARED_EVENT)

        self.client.post(
            '/tasks/event',
            data=task_util.task_body_for_test(event=event_entity),
        )
        # It doesn't matter what code gets returned, since the method returns
        # whatever _process_link_shared returns, which is a mock. Only test
        # that _process_link_shared is called.
        slack_process_link_shared_mock.assert_called_once()
Example #4
0
    def test_process_link_shared(self, mock_create_unfurls, mock_slack_client):
        mock_create_unfurls.return_value = {'http://example.com': 'unfurl'}

        event_entity = Entity(
            ds_util.client.key('SubscriptionEvent', 'slack-E232eq2ee')
        )
        event_entity.update(LINK_SHARED_EVENT)

        r = self.client.post(
            '/tasks/event',
            data=task_util.task_body_for_test(event=event_entity),
        )

        mock_slack_client.assert_called_once()
        responses.assertResponse(self, responses.OK, r)
Example #5
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()
Example #6
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()