blob: 3e99c8f524a92755006fbc84c95ccade360116d5 [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 spammodel module."""
5
6from __future__ import absolute_import
7from __future__ import division
8from __future__ import print_function
9
10import mock
11import unittest
12import webapp2
13
14from features import spammodel
15from framework import urls
16
17
18class TrainingDataExportTest(unittest.TestCase):
19
20 def test_handler_definition(self):
21 instance = spammodel.TrainingDataExport()
22 self.assertIsInstance(instance, webapp2.RequestHandler)
23
24 @mock.patch('framework.cloud_tasks_helpers._get_client')
25 def test_enqueues_task(self, get_client_mock):
26 spammodel.TrainingDataExport().get()
27 task = {
28 'app_engine_http_request':
29 {
30 'relative_uri': urls.SPAM_DATA_EXPORT_TASK + '.do',
31 'body': '',
32 'headers': {
33 'Content-type': 'application/x-www-form-urlencoded'
34 }
35 }
36 }
37 get_client_mock().create_task.assert_called_once()
38 ((_parent, called_task), _kwargs) = get_client_mock().create_task.call_args
39 self.assertEqual(called_task, task)