Project import generated by Copybara.
GitOrigin-RevId: d9e9e3fb4e31372ec1fb43b178994ca78fa8fe70
diff --git a/features/test/spammodel_test.py b/features/test/spammodel_test.py
new file mode 100644
index 0000000..3e99c8f
--- /dev/null
+++ b/features/test/spammodel_test.py
@@ -0,0 +1,39 @@
+# Copyright 2020 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+"""Tests for the spammodel module."""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import mock
+import unittest
+import webapp2
+
+from features import spammodel
+from framework import urls
+
+
+class TrainingDataExportTest(unittest.TestCase):
+
+ def test_handler_definition(self):
+ instance = spammodel.TrainingDataExport()
+ self.assertIsInstance(instance, webapp2.RequestHandler)
+
+ @mock.patch('framework.cloud_tasks_helpers._get_client')
+ def test_enqueues_task(self, get_client_mock):
+ spammodel.TrainingDataExport().get()
+ task = {
+ 'app_engine_http_request':
+ {
+ 'relative_uri': urls.SPAM_DATA_EXPORT_TASK + '.do',
+ 'body': '',
+ 'headers': {
+ 'Content-type': 'application/x-www-form-urlencoded'
+ }
+ }
+ }
+ get_client_mock().create_task.assert_called_once()
+ ((_parent, called_task), _kwargs) = get_client_mock().create_task.call_args
+ self.assertEqual(called_task, task)