# Path: blackbelt/git.py
# def get_remote_repo_info(github_repo_info):
#     match = re.match(r".*github.com(:|\/)(?P<owner>[a-zA-Z\_\-]+)/{1}(?P<name>[a-zA-Z\-\_]+)\.git$", github_repo_info)
#     if not match:
#         raise ValueError("Cannot parse repo info. Bad remote?")
#     return match.groupdict()
# 
# def get_current_branch():
#     return subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip().decode('utf-8')


from nose.tools import assert_equal, assert_raises
from mock import patch
from sys import version_info
from blackbelt.git import get_remote_repo_info, get_current_branch


class TestGithubRepoGitAddressParsing(object):

    github_repo = 'git@github.com:apiaryio/apiary-test.git'

    def setUp(self):
        self.parsed = get_remote_repo_info(self.github_repo)

    def test_repo_owner(self):
        assert_equal('apiaryio', self.parsed['owner'])

    def test_repo_name(self):
        assert_equal('apiary-test', self.parsed['name'])


class TestGithubRepoHttpsAddressParsing(object):

    github_repo = 'https://github.com/apiaryio/apiary-test.git'

    def setUp(self):

# Path: blackbelt/git.py
# def get_remote_repo_info(github_repo_info):
#     match = re.match(r".*github.com(:|\/)(?P<owner>[a-zA-Z\_\-]+)/{1}(?P<name>[a-zA-Z\-\_]+)\.git$", github_repo_info)
#     if not match:
#         raise ValueError("Cannot parse repo info. Bad remote?")
#     return match.groupdict()
# 
# def get_current_branch():
#     return subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip().decode('utf-8')


# Path: test/test_git.py
from nose.tools import assert_equal, assert_raises
from mock import patch
from sys import version_info
from blackbelt.git import get_remote_repo_info, get_current_branch



class TestGithubRepoGitAddressParsing(object):

    github_repo = 'git@github.com:apiaryio/apiary-test.git'

    def setUp(self):
        self.parsed = get_remote_repo_info(self.github_repo)

    def test_repo_owner(self):
        assert_equal('apiaryio', self.parsed['owner'])

    def test_repo_name(self):
        assert_equal('apiary-test', self.parsed['name'])


class TestGithubRepoHttpsAddressParsing(object):

    github_repo = 'https://github.com/apiaryio/apiary-test.git'

    def setUp(self):

        self.parsed = get_remote_repo_info(self.github_repo)