Ejemplo n.º 1
0
    def test_is_next(self):
        now = datetime.now()
        two_minutes_from_now = now + timedelta(minutes=1)
        two_hours_from_now = now + timedelta(hours=2)

        assert CampMe.is_next(
            self._create_session_timeslot(two_minutes_from_now))

        assert not CampMe.is_next(self._create_session_timeslot(now))

        assert not CampMe.is_next(
            self._create_session_timeslot(two_hours_from_now))
Ejemplo n.º 2
0
    def test_is_by_speaker(self):
        cases = [
            (['bob'], True),
            (['BoB'], True),
            (['bob', 'bobbernaugh'], True),
            (['bob', 'jones'], True),
            (['bobbernaugh'], True),
            (['bobbernaugh', 'the great'], True),
            (['ogg'], False),
        ]

        for name_parts, expected in cases:
            r = CampMe.build_regex(name_parts)
            assert expected == CampMe.is_by_speaker(
                {
                    'SpeakerFirstName': 'Bob',
                    'SpeakerLastName': 'Bobbernaugh'
                }, r)
Ejemplo n.º 3
0
    def test_is_at_time(self):
        clock = datetime(2018, 11, 10)
        stated_time = '14:15'
        cases = {
            '2018-11-10T14:15:00': True,
            '2018-11-07T14:15:00': False,  # wrong day wrt clock
            '2018-11-10T08:30:00': False,  # wrong time wrt start_time
        }

        for start, expected in cases.iteritems():
            assert CampMe.is_at_time({'SessionStart': start}, stated_time,
                                     clock) == expected
Ejemplo n.º 4
0
 def test_create_slack_response_zero_results(self):
     actual = CampMe.create_slack_response([], 'something')
     assert actual[0] == 'Server returned no data ¯\\_(ツ)_/¯'
Ejemplo n.º 5
0
 def test_create_slack_response_populates_attachment(self):
     actual = CampMe.create_slack_response(SAMPLE_API_RESPONSE, 'something')
     for entry in ('title', 'text', 'author_link', 'author_name'):
         assert actual[1][0][entry]
Ejemplo n.º 6
0
def get_target():
    return CampMe()
Ejemplo n.º 7
0
    def test_filter_items_speaker(self):
        actual = CampMe.filter_items(SAMPLE_API_RESPONSE,
                                     ('speaker', 'Dwain', 'Bobberson'))[0]

        assert actual['SpeakerLastName'] == 'Bobberson'
Ejemplo n.º 8
0
 def test_format_when_by_speaker(self):
     assert CampMe.format_text(SAMPLE_API_RESPONSE, True).startswith(
         '*  Bob Bobberson: Awesome Code!  @ SLH 102 Sun 11:15')
Ejemplo n.º 9
0
 def test_format_when_items(self):
     assert CampMe.format_text(SAMPLE_API_RESPONSE,
                               False).startswith('Sun 11:15 - Sun 11:15')
Ejemplo n.º 10
0
 def test_format_text_when_no_items(self):
     assert CampMe.format_text([]) == CampMe.NO_MATCHES_FOUND
Ejemplo n.º 11
0
 def test_nice(self):
     assert CampMe.nice('2000-01-01T13:45:00') == 'Sat 13:45'
Ejemplo n.º 12
0
 def test_is_now(self):
     assert CampMe.is_now({
         'SessionStart': '2000-01-01T00:00:00',
         'SessionEnd': '2222-01-01T00:00:00'
     })
Ejemplo n.º 13
0
 def test_build_regex(self):
     t = CampMe.build_regex(['alpha', 'beta'])
     assert t.pattern == "(\\balpha\\b|\\bbeta\\b)"