def test_pull_request_has_a_head_branch(): branch = Branch('test') pull = PullRequest(Mock(branch=branch), Mock()) assert pull.head_branch == branch
def test_pull_request_title_removes_underscores(): branch = Branch('PT123-test_this_works') pull = PullRequest(Mock(branch=branch), Mock()) assert pull.title == 'Test this works'
def test_pull_request_title_does_not_require_ticket_ids(): branch = Branch('test_this_works') pull = PullRequest(Mock(branch=branch), Mock()) assert pull.title == 'Test this works'
def test_pull_request_has_the_branch_point_as_its_base(): pull = PullRequest(None, Mock()) assert pull.base_branch == Branch(config.BRANCH_POINT)
def test_pull_request_has_a_title_taken_from_the_branch_ref(): branch = Branch('PT123-test-this-works') pull = PullRequest(Mock(branch=branch), Mock()) assert pull.title == 'Test this works'
def get_current(): current_branch_ref = branches.get_current_branch() return Branch(current_branch_ref)
def create_branch_from_id_and_title(id, title): ref = BRANCH_ID_PREFIX + id + BRANCH_PART_SEPARATOR + _sanitize(title) return Branch(ref)
def test_human_readable_does_not_include_ticket_id_or_prefix(): config.BRANCH_PART_SEPARATOR = '-' config.BRANCH_ID_PREFIX = 'PT' assert Branch('PT123-test').human_readable() == 'Test'
def test_branch_has_a_ref(): branch = Branch('test') assert branch.ref == 'test'
def test_human_readable_converts_underscores_to_spaces(): assert Branch('Test_branch').human_readable() == 'Test branch'
def test_human_readable_capitalises_first_letter(): assert Branch('test').human_readable() == 'Test'
def test_human_readable_converts_hyphens_to_spaces(): assert Branch('Test-branch').human_readable() == 'Test branch'
def test_ticket_id_is_returned_if_after_prefix_and_before_separator_in_ref(): config.BRANCH_PART_SEPARATOR = '-' config.BRANCH_ID_PREFIX = 'PT' assert Branch('PT123-test').ticket_id == '123'
def test_ticket_id_is_none_if_not_in_ref(): assert Branch('test').ticket_id is None
def test_equality_is_done_by_ref(): assert Branch('test') == Branch('test') assert Branch('test') != Branch('est')
def base_branch(self): return Branch(config.BRANCH_POINT)