# Path: blackbelt/handle_trello.py
# def infer_branch_name(url):
#     return '-'.join(url.split('/')[~0].split('-')[1:])
# 
# def get_next_sunday():
#     diff = datetime.date.today().weekday()
#     # On sunday, add week instead
#     if diff == 6:
#         diff = -1
# 
#     return datetime.date.today() + datetime.timedelta(
#         days=6 - diff
#     )


import mock
import datetime
import blackbelt
from mock import patch
from nose.tools import assert_equal
from blackbelt.handle_trello import infer_branch_name, get_next_sunday

    def test_simple_url(self):
        assert_equal('bb-t-next', infer_branch_name(
            'https://trello.com/c/7b4Z3V8o/1803-bb-t-next'
        ))


class TestNextSunday(object):

    def setUp(self):
        self.mocked_datetime = datetime_patcher.start()

    def tearDown(self):
        datetime_patcher.stop()

    def test_middle_week(self):
        self.mocked_datetime.today.return_value = datetime.datetime(2015, 4, 1) # April's Fools! In fact, Wednesday

        sun = get_next_sunday()
        assert_equal(sun, datetime.date(2015, 4, 5))

    def test_monday(self):
        self.mocked_datetime.today.return_value = datetime.datetime(2015, 4, 6)

        sun = get_next_sunday()
        assert_equal(sun, datetime.date(2015, 4, 12))

    def test_sunday_yields_next_sunday(self):
        self.mocked_datetime.today.return_value = datetime.datetime(2015, 4, 5)


# Path: blackbelt/handle_trello.py
# def infer_branch_name(url):
#     return '-'.join(url.split('/')[~0].split('-')[1:])
# 
# def get_next_sunday():
#     diff = datetime.date.today().weekday()
#     # On sunday, add week instead
#     if diff == 6:
#         diff = -1
# 
#     return datetime.date.today() + datetime.timedelta(
#         days=6 - diff
#     )


# Path: test/test_trello.py
import mock
import datetime
import blackbelt
from mock import patch
from nose.tools import assert_equal
from blackbelt.handle_trello import infer_branch_name, get_next_sunday


    def test_simple_url(self):
        assert_equal('bb-t-next', infer_branch_name(
            'https://trello.com/c/7b4Z3V8o/1803-bb-t-next'
        ))


class TestNextSunday(object):

    def setUp(self):
        self.mocked_datetime = datetime_patcher.start()

    def tearDown(self):
        datetime_patcher.stop()

    def test_middle_week(self):
        self.mocked_datetime.today.return_value = datetime.datetime(2015, 4, 1) # April's Fools! In fact, Wednesday

        sun = get_next_sunday()
        assert_equal(sun, datetime.date(2015, 4, 5))

    def test_monday(self):
        self.mocked_datetime.today.return_value = datetime.datetime(2015, 4, 6)

        sun = get_next_sunday()
        assert_equal(sun, datetime.date(2015, 4, 12))

    def test_sunday_yields_next_sunday(self):
        self.mocked_datetime.today.return_value = datetime.datetime(2015, 4, 5)


        sun = get_next_sunday()