Пример #1
0
# -*- coding: utf-8 -*-

from lazbot.test import TestBase, TestBot, setup, with_data
from lazbot.utils import merge

app = setup(bot=TestBot())
from plugins import ext

TEST_CHANNELS = [
    {"id": "C123", "name": "test_channel"},
    {"id": "C456", "name": "another"},
]
TEST_IMS = [
    {"id": "I123", "user": "******"},
]
TEST_GROUPS = [
    {"id": "G123", "name": "test_group", "is_group": True},
]
TEST_USERS = [
    {"id": "U999", "name": "tester"},
]


class ExtTest(TestBase):
    def setUp(self):
        TestBase.setUp(self)
        self.bot.login_data = merge(self.bot.login_data, users=TEST_USERS)
        self.ext = reload(ext)

    @with_data(channels=TEST_CHANNELS, ims=TEST_IMS, groups=TEST_GROUPS)
    def test_channel_fixing(self):
Пример #2
0
import unittest
from freezegun import freeze_time
from lazbot.test import setup
import datetime as dt
from dateutil.tz import tzutc

app = setup()

from lazbot.schedule import ScheduledTask


class ScheduleTest(unittest.TestCase):
    def setUp(self):
        self.called = False

        def action(**kwargs):
            self.called = True

        self.action = action

    @freeze_time("2015-10-01 12:00:01")
    def test_relative_time(self):
        ''' Verify that relative offsets schedule correctly
        Using the ``delta`` param for relative offsets, make sure that the
        resolved time for execution is correct.
        '''
        task = ScheduledTask(action=self.action, delta=dt.timedelta(hours=1))
        self.assertEqual(task.next, dt.datetime(2015, 10, 1, 13, 0, 1,
                                                tzinfo=tzutc()))

    def test_absolute_datetime(self):