# -*- coding: utf-8 -*-
"""
Copyright (c) 2015 Red Hat, Inc
All rights reserved.

This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.
"""

from __future__ import unicode_literals, absolute_import

import pytest
import requests
import uuid

from six import string_types


def uuid_value():
    return uuid.uuid4().hex


def is_string_type(obj):
    """
    Test whether obj is a string type

    :param obj: object to test
    :return: bool, whether obj is a string type
    """

    return any(isinstance(obj, strtype)
               for strtype in string_types)


def has_connection():
    try:
        requests.get("https://github.com/")
        return True
    except requests.ConnectionError:
        return False


# In case we run tests in an environment without internet connection.
requires_internet = pytest.mark.skipif(not has_connection(), reason="requires internet connection")

# -*- coding: utf-8 -*-
"""
Copyright (c) 2015 Red Hat, Inc
All rights reserved.

This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.
"""

from __future__ import unicode_literals, absolute_import

import pytest
import requests
import uuid

from six import string_types


def uuid_value():
    return uuid.uuid4().hex


def is_string_type(obj):
    """
    Test whether obj is a string type

    :param obj: object to test
    :return: bool, whether obj is a string type
    """

    return any(isinstance(obj, strtype)
               for strtype in string_types)


def has_connection():
    try:
        requests.head("http://github.com/")
        return True
    except requests.ConnectionError:
        return False


# In case we run tests in an environment without internet connection.
requires_internet = pytest.mark.skipif(not has_connection(), reason="requires internet connection")

Make Internet connection check a little faster
Make Internet connection check a little faster

Testing whether Internet connect is available only cares about if the
remote server is able to response something, but not the concrete
content returned. So, when remote server responses 301, it's enough, no
need to wait for a 200 response with the real content from redirected
URL.

Signed-off-by: Chenxiong Qi <7a7314576eb0408cef5766c0268b5ff02ad3cfb6@redhat.com>
