# Path: hornet/common/helpers.py
# def get_random_item(collection):
#     if isinstance(collection, dict):
#         all_keys = list(collection.keys())
#         r = random.choice(all_keys)
#         return collection[r]
#     elif isinstance(collection, list):
#         return random.choice(collection)


import gevent.monkey
import os
import shutil
import unittest
import tempfile
import hornet
from hornet.common.helpers import get_random_item
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


gevent.monkey.patch_all()




class HornetTests(unittest.TestCase):

    def setUp(self):
        self.working_dir = tempfile.mkdtemp()
        test_config = os.path.join(os.path.dirname(hornet.__file__), 'data', 'default_config.json')
        shutil.copyfile(test_config, os.path.join(self.working_dir, 'config.json'))

    def tearDown(self):
        shutil.rmtree(self.working_dir)

    def test_random_choice_dict(self):
        test_dict = {
            'a': 1,
            'b': 2,
            'c': 3,
            'd': 4
        }

# Path: hornet/common/helpers.py
# def get_random_item(collection):
#     if isinstance(collection, dict):
#         all_keys = list(collection.keys())
#         r = random.choice(all_keys)
#         return collection[r]
#     elif isinstance(collection, list):
#         return random.choice(collection)


# Path: hornet/tests/test_helpers.py
import gevent.monkey
import os
import shutil
import unittest
import tempfile
import hornet
from hornet.common.helpers import get_random_item

# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


gevent.monkey.patch_all()




class HornetTests(unittest.TestCase):

    def setUp(self):
        self.working_dir = tempfile.mkdtemp()
        test_config = os.path.join(os.path.dirname(hornet.__file__), 'data', 'default_config.json')
        shutil.copyfile(test_config, os.path.join(self.working_dir, 'config.json'))

    def tearDown(self):
        shutil.rmtree(self.working_dir)

    def test_random_choice_dict(self):
        test_dict = {
            'a': 1,
            'b': 2,
            'c': 3,
            'd': 4
        }

        x = get_random_item(test_dict)