<commit_before>from __future__ import unicode_literals

import unittest

import mock

import mopidy_alarmclock.http

class HttpTest(unittest.TestCase):

    def test_SetAlarmRequestHandler(self):
        config = mock.Mock()
        core = mock.Mock()
        alarm_manager = mock.Mock()
        msg_store = mock.Mock()

        handler = http.SetAlarmRequestHandler()
        handler.initialize(config, core, alarm_manager, msg_store)
        handler.get_argument = mock.Mock()
        handler.get_argument.side_effect = lambda v: {'playlist': 'Playlist URI', 'time': '8:00', 'random': '1', 'volume': '81', 'incsec': '23'}[v]
        handler.post()

        self.assertEqual(alarm_manager.set_alarm.call_count, 1)
        self.assertEqual(alarm_manager.set_alarm.call_args[0][1], core.playlists.lookup('Playlist URI').get())
        self.assertEqual(alarm_manager.set_alarm.call_args[0][2], True)
        self.assertEqual(alarm_manager.set_alarm.call_args[0][3], 81)
        self.assertEqual(alarm_manager.set_alarm.call_args[0][4], 23)

    # TODO Use Tornado unit testing
    # TODO Write more (granular + comprehensive) tests
<commit_msg>http tests: implementing<commit_after>from __future__ import unicode_literals

import unittest

import mock

from mopidy_alarmclock import http


class HttpTest(unittest.TestCase):

    @mock.patch('http.tornado')
    def test_SetAlarmRequestHandler(self):
        config = mock.Mock()
        core = mock.Mock()
        alarm_manager = mock.Mock()
        msg_store = mock.Mock()

        handler = http.SetAlarmRequestHandler()
        handler.initialize(config, core, alarm_manager, msg_store)
        handler.get_argument = mock.Mock()
        handler.get_argument.side_effect = lambda v: {'playlist': 'Playlist URI', 'time': '8:00', 'random': '1', 'volume': '81', 'incsec': '23'}[v]
        handler.post()

        self.assertEqual(alarm_manager.set_alarm.call_count, 1)
        self.assertEqual(alarm_manager.set_alarm.call_args[0][1], core.playlists.lookup('Playlist URI').get())
        self.assertEqual(alarm_manager.set_alarm.call_args[0][2], True)
        self.assertEqual(alarm_manager.set_alarm.call_args[0][3], 81)
        self.assertEqual(alarm_manager.set_alarm.call_args[0][4], 23)

    # TODO Use Tornado unit testing
    # TODO Write more (granular + comprehensive) tests

{'fraction_non_alphanumeric': 0.12558936990998715, 'fraction_numerical': 0.018002571795970854, 'mean_word_length': 3.7439024390243905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7205019', 'n_tokens_mistral': 768, 'n_tokens_neox': 740, 'n_words': 139}