# 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

class TestOfForkRepository(TestCase):
    def setUp(self):
        self.cleanup_dirs = []

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

    def test_bad_from_dir_raises_exception(self):
        fake_directory = '%d/%d/%d' % (random.randint(1,10), random.randint(1,10), random.randint(1,10))
        doesnt_matter = str(random.randint(1,100))
        with open('/dev/null','w') as output:
            self.assertRaises(NappingCatException, operations.fork_repository, doesnt_matter, output, output, output, fake_directory, doesnt_matter)

    def test_existing_target_directory_raises_exception(self):

# 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


class TestOfForkRepository(TestCase):
    def setUp(self):
        self.cleanup_dirs = []

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

    def test_bad_from_dir_raises_exception(self):
        fake_directory = '%d/%d/%d' % (random.randint(1,10), random.randint(1,10), random.randint(1,10))
        doesnt_matter = str(random.randint(1,100))
        with open('/dev/null','w') as output:
            self.assertRaises(NappingCatException, operations.fork_repository, doesnt_matter, output, output, output, fake_directory, doesnt_matter)

    def test_existing_target_directory_raises_exception(self):

        doesnt_matter = random.randint(1,100)