blob: 0e5fbf8e3a9fcc4f6c3962ba50902ac5a5d526b6 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# Copyright 2020 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4"""Tests for the componentexport module."""
5
6from __future__ import absolute_import
7from __future__ import division
8from __future__ import print_function
9
10import mock
11import unittest
12import webapp2
13
14import settings
15from features import componentexport
16from framework import urls
17
18
19class ComponentTrainingDataExportTest(unittest.TestCase):
20
21 def test_handler_definition(self):
22 instance = componentexport.ComponentTrainingDataExport()
23 self.assertIsInstance(instance, webapp2.RequestHandler)
24
25 @mock.patch('framework.cloud_tasks_helpers._get_client')
26 def test_enqueues_task(self, get_client_mock):
27 componentexport.ComponentTrainingDataExport().get()
28
29 queue = 'componentexport'
30 task = {
31 'app_engine_http_request':
32 {
33 'http_method': 'GET',
34 'relative_uri': urls.COMPONENT_DATA_EXPORT_TASK
35 }
36 }
37
38 get_client_mock().queue_path.assert_called_with(
39 settings.app_id, settings.CLOUD_TASKS_REGION, queue)
40 get_client_mock().create_task.assert_called_once()
41 ((_parent, called_task), _kwargs) = get_client_mock().create_task.call_args
42 self.assertEqual(called_task, task)