# Path: nappingcat/contrib/git/operations.py
# def fork_repository(git, stdin, stdout, stderr, from_directory, to_directory):
# def create_repository(git, stdin, stdout, stderr, directory, template_dir=None, bare=True):
# def git_shell(git, stdin, stdout, stderr, action, directory):
# 
# Path: nappingcat/contrib/git/exceptions.py
# class KittyGitRepoExists(NappingCatRejected):
#     def __init__(self, which):
#         super(KittyGitRepoExists, self).__init__("""
#             There's already a repo in %s. Whoops!
#         """.strip() % which)
# 
# Path: nappingcat/exceptions.py
# class NappingCatException(Exception):
#     pass


from unittest import TestCase
from nappingcat.contrib.git import operations
from nappingcat.contrib.git.exceptions import KittyGitRepoExists
from nappingcat.exceptions import NappingCatException
import time
import os
import random
import mox
import shutil
import sys
            self.assertRaises(KittyGitRepoExists, operations.fork_repository, output, output, output, doesnt_matter, directory, directory) 
        shutil.rmtree(directory)

    def test_actually_forks_repository(self):
        from_dir, to_dir = ".%d" % random.randint(1,100), ".o%d" % random.randint(1,100)
        self.cleanup_dirs = [from_dir, to_dir]
        git = 'git'
        with open('/dev/null','w') as output:
            operations.create_repository(git, output, output, output, from_dir)
            result = operations.fork_repository(git, output, output, output, from_dir, to_dir)
            self.assertTrue(isinstance(result, bool))
            self.assertTrue(result)
            self.assertTrue(os.path.exists('/'.join([to_dir, 'config']))) 

class TestOfCreateRepository(TestCase):
    def setUp(self):
        self.mox = mox.Mox()
        self.cleanup_dirs = []

    def tearDown(self):
        self.mox.UnsetStubs()
        if self.cleanup_dirs:
            for dir in self.cleanup_dirs:
                shutil.rmtree(dir)

    def test_repo_already_exists(self):
        from_dir = ".%d" % random.randint(1,100)
        self.cleanup_dirs = [from_dir,]
        git = 'git'
        with open('/dev/null','w') as output:

# Path: nappingcat/contrib/git/operations.py
# def fork_repository(git, stdin, stdout, stderr, from_directory, to_directory):
# def create_repository(git, stdin, stdout, stderr, directory, template_dir=None, bare=True):
# def git_shell(git, stdin, stdout, stderr, action, directory):
# 
# Path: nappingcat/contrib/git/exceptions.py
# class KittyGitRepoExists(NappingCatRejected):
#     def __init__(self, which):
#         super(KittyGitRepoExists, self).__init__("""
#             There's already a repo in %s. Whoops!
#         """.strip() % which)
# 
# Path: nappingcat/exceptions.py
# class NappingCatException(Exception):
#     pass


# Path: tests/gittests/operations.py
from unittest import TestCase
from nappingcat.contrib.git import operations
from nappingcat.contrib.git.exceptions import KittyGitRepoExists
from nappingcat.exceptions import NappingCatException
import time
import os
import random
import mox
import shutil
import sys

            self.assertRaises(KittyGitRepoExists, operations.fork_repository, output, output, output, doesnt_matter, directory, directory) 
        shutil.rmtree(directory)

    def test_actually_forks_repository(self):
        from_dir, to_dir = ".%d" % random.randint(1,100), ".o%d" % random.randint(1,100)
        self.cleanup_dirs = [from_dir, to_dir]
        git = 'git'
        with open('/dev/null','w') as output:
            operations.create_repository(git, output, output, output, from_dir)
            result = operations.fork_repository(git, output, output, output, from_dir, to_dir)
            self.assertTrue(isinstance(result, bool))
            self.assertTrue(result)
            self.assertTrue(os.path.exists('/'.join([to_dir, 'config']))) 

class TestOfCreateRepository(TestCase):
    def setUp(self):
        self.mox = mox.Mox()
        self.cleanup_dirs = []

    def tearDown(self):
        self.mox.UnsetStubs()
        if self.cleanup_dirs:
            for dir in self.cleanup_dirs:
                shutil.rmtree(dir)

    def test_repo_already_exists(self):
        from_dir = ".%d" % random.randint(1,100)
        self.cleanup_dirs = [from_dir,]
        git = 'git'
        with open('/dev/null','w') as output:

            operations.create_repository(git, output, output, output, from_dir)