def testGceFirewallRuleGenericError(self, mock_cmd):
     fake_rets = [('stdout', 'some random firewall error', 1)]
     with PatchCriticalObjects(fake_rets) as issue_command:
         with self.assertRaises(errors.VmUtil.IssueCommandError):
             fr = gce_network.GceFirewallRule('name', 'project', 'allow',
                                              'network_name')
             fr._Create()
         self.assertEqual(issue_command.call_count, 1)
 def testGceFirewallRuleSuccessfulAfterRateLimited(self, mock_cmd):
     fake_rets = [('stdout', 'Rate Limit Exceeded', 1),
                  ('stdout', 'some warning perhaps', 0)]
     with PatchCriticalObjects(fake_rets) as issue_command:
         fr = gce_network.GceFirewallRule('name', 'project', 'allow',
                                          'network_name')
         fr._Create()
         self.assertEqual(issue_command.call_count, 2)
 def testGceFirewallRuleAlreadyExistsAfterRateLimited(self, mock_cmd):
     fake_rets = [('stdout', 'Rate Limit Exceeded', 1),
                  ('stdout', 'Rate Limit Exceeded', 1),
                  ('stdout', 'firewall already exists', 1)]
     with PatchCriticalObjects(fake_rets) as issue_command:
         fr = gce_network.GceFirewallRule('name', 'project', 'allow',
                                          'network_name')
         fr._Create()
         self.assertEqual(issue_command.call_count, 3)