# Path: dgitcore/api.py
# def api_call_action(func): 
#     def _inner(*args, **kwargs):
# def _reexport(mod):
# def initialize():
# 
# Path: dgitcore/helper.py
# class cd:
#     """Context manager for changing the current working directory"""
#     def __init__(self, newPath):
#         self.newPath = os.path.expanduser(newPath)
# 
#     def __enter__(self):
#         self.savedPath = os.getcwd()
#         os.chdir(self.newPath)
# 
#     def __exit__(self, etype, value, traceback):
#         os.chdir(self.savedPath)


import os, sys, shutil, tempfile, json, stat
from nose import with_setup
from nose.tools import assert_raises
from unittest import TestCase
from dgitcore.exceptions import *
from dgitcore import api
from dgitcore.helper import cd

def test_create_repo():
    """
    Init repo
    """

    for name in repo_configurations:

        #  This should fail
        with assert_raises(IncompleteParameters):
            repo = create_sample_repo_nooptions(*repo_configurations[name])

        #  This should be successful
        repo = create_sample_repo(*repo_configurations[name])
        assert repo is not None

        # Check if all the files have been created
        rootdir = repo.rootdir
        for suffix in ["", '.git', '.gitignore', 'datapackage.json']:
            path = os.path.join(rootdir, suffix)
            assert os.path.exists(path)


def test_sh_command():
    """
    Shell cmds
    """

    repo = basic_repo_lookup('simple1')


# Path: dgitcore/api.py
# def api_call_action(func): 
#     def _inner(*args, **kwargs):
# def _reexport(mod):
# def initialize():
# 
# Path: dgitcore/helper.py
# class cd:
#     """Context manager for changing the current working directory"""
#     def __init__(self, newPath):
#         self.newPath = os.path.expanduser(newPath)
# 
#     def __enter__(self):
#         self.savedPath = os.getcwd()
#         os.chdir(self.newPath)
# 
#     def __exit__(self, etype, value, traceback):
#         os.chdir(self.savedPath)


# Path: tests/test_api.py
import os, sys, shutil, tempfile, json, stat
from nose import with_setup
from nose.tools import assert_raises
from unittest import TestCase
from dgitcore.exceptions import *
from dgitcore import api
from dgitcore.helper import cd


def test_create_repo():
    """
    Init repo
    """

    for name in repo_configurations:

        #  This should fail
        with assert_raises(IncompleteParameters):
            repo = create_sample_repo_nooptions(*repo_configurations[name])

        #  This should be successful
        repo = create_sample_repo(*repo_configurations[name])
        assert repo is not None

        # Check if all the files have been created
        rootdir = repo.rootdir
        for suffix in ["", '.git', '.gitignore', 'datapackage.json']:
            path = os.path.join(rootdir, suffix)
            assert os.path.exists(path)


def test_sh_command():
    """
    Shell cmds
    """

    repo = basic_repo_lookup('simple1')


    output = api.shellcmd(repo, ['ls'])