Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: appengine/gce-backend/instance_group_managers_test.py

Issue 2713533002: Refactor task enqueuing (Closed)
Patch Set: Remove metric Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2016 The LUCI Authors. All rights reserved. 2 # Copyright 2016 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 """Unit tests for instance_group_managers.py.""" 6 """Unit tests for instance_group_managers.py."""
7 7
8 import unittest 8 import unittest
9 9
10 import test_env 10 import test_env
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 ).put() 880 ).put()
881 models.InstanceTemplate(key=key.parent().parent()).put() 881 models.InstanceTemplate(key=key.parent().parent()).put()
882 882
883 instance_group_managers.resize(key) 883 instance_group_managers.resize(key)
884 884
885 885
886 class ScheduleCreationTest(test_case.TestCase): 886 class ScheduleCreationTest(test_case.TestCase):
887 """Tests for instance_group_managers.schedule_creation.""" 887 """Tests for instance_group_managers.schedule_creation."""
888 888
889 def setUp(self, *args, **kwargs): 889 def setUp(self, *args, **kwargs):
890 def enqueue_task(*args, **kwargs): 890 def enqueue_task(taskqueue, key):
891 self.failUnless(kwargs.get('params', {}).get('key')) 891 entity = key.get()
892 entity = ndb.Key(urlsafe=kwargs['params']['key']).get() 892 entity.url = key.urlsafe()
893 entity.url = kwargs['params']['key']
894 entity.put() 893 entity.put()
895 return True 894 return True
896 895
897 super(ScheduleCreationTest, self).setUp(*args, **kwargs) 896 super(ScheduleCreationTest, self).setUp(*args, **kwargs)
898 self.mock(instance_group_managers.utils, 'enqueue_task', enqueue_task) 897 self.mock(instance_group_managers.utilities, 'enqueue_task', enqueue_task)
899 898
900 def test_enqueues_task(self): 899 def test_enqueues_task(self):
901 """Ensures a task is enqueued.""" 900 """Ensures a task is enqueued."""
902 key = instance_group_managers.get_instance_group_manager_key( 901 key = instance_group_managers.get_instance_group_manager_key(
903 'base-name', 'revision', 'zone') 902 'base-name', 'revision', 'zone')
904 models.InstanceTemplate( 903 models.InstanceTemplate(
905 key=key.parent().parent(), 904 key=key.parent().parent(),
906 active=key.parent(), 905 active=key.parent(),
907 ).put() 906 ).put()
908 models.InstanceTemplateRevision( 907 models.InstanceTemplateRevision(
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 ), 1104 ),
1106 ).put() 1105 ).put()
1107 1106
1108 instance_group_managers.update_url(key, 'url') 1107 instance_group_managers.update_url(key, 'url')
1109 1108
1110 self.assertEqual(key.get().url, 'url') 1109 self.assertEqual(key.get().url, 'url')
1111 1110
1112 1111
1113 if __name__ == '__main__': 1112 if __name__ == '__main__':
1114 unittest.main() 1113 unittest.main()
OLDNEW
« no previous file with comments | « appengine/gce-backend/instance_group_managers.py ('k') | appengine/gce-backend/instance_templates.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698