Skip the git state tests if a dns lookup to github.com fails

This is the quickest clever thing I could think of while running the
unit tests offline in the car during a long road trip.
This commit is contained in:
Jeff Schroeder 2012-12-21 21:41:07 -06:00
parent 5b60edcfb6
commit 8b74360493

View File

@ -3,6 +3,7 @@ Tests for the Git state
'''
import os
import shutil
import socket
import integration
@ -11,6 +12,18 @@ class GitTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
Validate the git state
'''
def setUp(self):
super(GitTest, self).setUp()
self.__domain = 'github.com'
try:
if hasattr(socket, 'setdefaulttimeout'):
# 10 second dns timeout
socket.setdefaulttimeout(10)
socket.gethostbyname(self.__domain)
except socket.error:
msg = 'error resolving {0}, possible network issue?'
self.skipTest(msg.format(self.__domain))
def test_latest(self):
'''
git.latest
@ -19,7 +32,7 @@ class GitTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
try:
ret = self.run_state(
'git.latest',
name='https://github.com/saltstack/salt.git',
name='https://{0}/saltstack/salt.git'.format(self.__domain),
rev='develop',
target=name,
submodules=True
@ -57,7 +70,7 @@ class GitTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
try:
ret = self.run_state(
'git.latest',
name='https://github.com/saltstack/salt.git',
name='https://{0}/saltstack/salt.git'.format(self.__domain),
rev='develop',
target=name,
submodules=True
@ -75,7 +88,7 @@ class GitTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
try:
ret = self.run_state(
'git.latest',
name='https://github.com/mozilla/zamboni.git',
name='https://{0}/mozilla/zamboni.git'.format(self.__domain),
target=name,
submodules=True
)