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

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

Issue 2996623002: Include zone in GCE instance base name (Closed)
Patch Set: Unit test Created 3 years, 4 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
« no previous file with comments | « appengine/gce-backend/instance_group_managers.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 expected_keys = [ 442 expected_keys = [
443 key, 443 key,
444 ] 444 ]
445 445
446 self.assertItemsEqual( 446 self.assertItemsEqual(
447 instance_group_managers.get_drained_instance_group_managers(), 447 instance_group_managers.get_drained_instance_group_managers(),
448 expected_keys, 448 expected_keys,
449 ) 449 )
450 450
451 451
452 class GetBaseNameTest(test_case.TestCase):
453 """Tests for instance_group_managers.get_base_name."""
454
455 def test_get_base_name(self):
456 """Ensures base instance name is generated correctly."""
457 key = models.InstanceGroupManager(
458 key=instance_group_managers.get_instance_group_manager_key(
459 'base-name',
460 'revision-extra-long',
461 'zone',
462 ),
463 minimum_size=10,
464 maximum_size=10,
465 url='https://example.com',
466 ).put()
467 models.InstanceTemplateRevision(
468 key=key.parent(),
469 ).put()
470 models.InstanceTemplate(key=key.parent().parent()).put()
471
472 self.assertEqual(
473 instance_group_managers.get_base_name(key.get()),
474 'base-name-revision-zone',
475 )
476
477
452 class GetInstanceGroupManagerToDeleteTest(test_case.TestCase): 478 class GetInstanceGroupManagerToDeleteTest(test_case.TestCase):
453 """Tests for instance_group_managers.get_instance_group_manager_to_delete.""" 479 """Tests for instance_group_managers.get_instance_group_manager_to_delete."""
454 480
455 def test_entity_doesnt_exist(self): 481 def test_entity_doesnt_exist(self):
456 """Ensures no URL when the entity doesn't exist.""" 482 """Ensures no URL when the entity doesn't exist."""
457 key = ndb.Key(models.InstanceGroupManager, 'fake-key') 483 key = ndb.Key(models.InstanceGroupManager, 'fake-key')
458 self.failIf( 484 self.failIf(
459 instance_group_managers.get_instance_group_manager_to_delete(key)) 485 instance_group_managers.get_instance_group_manager_to_delete(key))
460 486
461 def test_instances(self): 487 def test_instances(self):
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 ), 1147 ),
1122 ).put() 1148 ).put()
1123 1149
1124 instance_group_managers.update_url(key, 'url') 1150 instance_group_managers.update_url(key, 'url')
1125 1151
1126 self.assertEqual(key.get().url, 'url') 1152 self.assertEqual(key.get().url, 'url')
1127 1153
1128 1154
1129 if __name__ == '__main__': 1155 if __name__ == '__main__':
1130 unittest.main() 1156 unittest.main()
OLDNEW
« no previous file with comments | « appengine/gce-backend/instance_group_managers.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698