def test_validate_credentials_file(self): # TODO(supertom): Only dealing with p12 here, check the other states # of this function module = FakeModule() with mock.patch("ansible.module_utils.gcp.open", mock.mock_open(read_data='foobar'), create=True): # pem condition, warning is suppressed with the return_value credentials_file = '/foopath/pem.pem' with self.assertRaises(ValueError): _validate_credentials_file(module, credentials_file=credentials_file, require_valid_json=False, check_libcloud=False)
def test_validate_credentials_file(self, mock_deprecated): # TODO(supertom): Only dealing with p12 here, check the other states # of this function module = mock.MagicMock() with mock.patch("ansible.module_utils.gcp.open", mock.mock_open(read_data='foobar'), create=True) as m: # pem condition, warning is surpressed with the return_value credentials_file = '/foopath/pem.pem' is_valid = _validate_credentials_file(module, credentials_file=credentials_file, require_valid_json=False, check_libcloud=False) self.assertTrue(is_valid)