@@ -227,7 +227,7 @@ def testGetVersions_InvalidModule(self):
227227 mock_request .execute ().AndRaise (self ._CreateHttpError (404 ))
228228 self .mox .ReplayAll ()
229229 with self .assertRaisesRegex (modules .InvalidModuleError ,
230- "Module 'foo' not found. " ):
230+ "" ):
231231 modules .get_versions (module = 'foo' )
232232
233233 # --- Tests for Legacy get_versions ---
@@ -366,7 +366,7 @@ def testGetDefaultVersion_InvalidModule(self):
366366 self .mox .ReplayAll ()
367367
368368 with self .assertRaisesRegex (modules .InvalidModuleError ,
369- "Module 'foo' not found. " ):
369+ "" ):
370370 modules .get_default_version (module = 'foo' )
371371
372372 # --- Tests for legacy get_default_version ---
@@ -456,7 +456,9 @@ def testGetNumInstances_NoManualScaling(self):
456456 versionsId = 'v1' ).AndReturn (mock_request )
457457 mock_request .execute ().AndReturn ({'automaticScaling' : {}})
458458 self .mox .ReplayAll ()
459- self .assertEqual (0 , modules .get_num_instances ())
459+
460+ with self .assertRaises (modules .InvalidVersionError ):
461+ modules .get_num_instances ()
460462
461463 def testGetNumInstances_InvalidVersion (self ):
462464 os .environ ['MODULES_USE_ADMIN_API' ] = 'true'
@@ -479,7 +481,7 @@ def testGetNumInstances_InvalidVersion(self):
479481 versionsId = 'v-bad' ).AndReturn (mock_request )
480482 mock_request .execute ().AndRaise (self ._CreateHttpError (404 ))
481483 self .mox .ReplayAll ()
482- with self .assertRaises (modules .InvalidVersionError ):
484+ with self .assertRaises (modules .InvalidModuleError ):
483485 modules .get_num_instances (version = 'v-bad' )
484486
485487 # --- Tests for updated get_num_instances ---
@@ -995,7 +997,7 @@ def testGetHostname_WithVersion_NoInstance(self):
995997 self .mox .StubOutWithMock (modules , '_get_project_id' )
996998 modules ._get_project_id ().AndReturn ('project' )
997999 self .mox .StubOutWithMock (modules , 'get_modules' )
998- modules .get_modules ().AndReturn (['default' , 'other' ])
1000+ modules .get_modules ().AndReturn (['default' , 'other' , 'foo' ])
9991001 mock_apps = self .mox .CreateMockAnything ()
10001002 mock_get_request = self .mox .CreateMockAnything ()
10011003 mock_admin_api_client .apps ().AndReturn (mock_apps )
@@ -1011,14 +1013,12 @@ def testGetHostname_Instance_Success(self):
10111013 mock_client_1 = self .mox .CreateMockAnything ()
10121014 mock_client_2 = self .mox .CreateMockAnything ()
10131015
1014- # Mock the two main dependencies of get_hostname
10151016 self .mox .StubOutWithMock (modules , '_get_admin_api_client_with_useragent' )
10161017 modules ._get_admin_api_client_with_useragent (
10171018 'get_hostname' ).AndReturn (mock_client_1 )
10181019 self .mox .StubOutWithMock (modules .discovery , 'build' )
10191020 modules .discovery .build ('appengine' , 'v1' ).AndReturn (mock_client_2 )
10201021
1021- # Mock the helper functions
10221022 self .mox .StubOutWithMock (modules , '_get_project_id' )
10231023 modules ._get_project_id ().AndReturn ('project' )
10241024 self .mox .StubOutWithMock (modules , 'get_modules' )
@@ -1028,15 +1028,13 @@ def testGetHostname_Instance_Success(self):
10281028 self .mox .StubOutWithMock (modules , 'get_current_version_name' )
10291029 modules .get_current_version_name ().AndReturn ('v1' )
10301030
1031- # Set up expectations for the first client call
10321031 mock_apps_1 = self .mox .CreateMockAnything ()
10331032 mock_get_request = self .mox .CreateMockAnything ()
10341033 mock_client_1 .apps ().AndReturn (mock_apps_1 )
10351034 mock_apps_1 .get (appsId = 'project' ).AndReturn (mock_get_request )
10361035 mock_get_request .execute ().AndReturn (
10371036 {'defaultHostname' : 'project.appspot.com' })
10381037
1039- # Set up expectations for the second client call
10401038 mock_apps_2 = self .mox .CreateMockAnything ()
10411039 mock_services_2 = self .mox .CreateMockAnything ()
10421040 mock_versions_2 = self .mox .CreateMockAnything ()
0 commit comments