예제 #1
0
    def test_get_seconds_since_midnight(self):
        self.assertEqual(43,
                         get_sec_since_midnight(datetime(year=2014,
                                                         month=1,
                                                         day=1,
                                                         second=43)))

        self.assertEqual(0,
                         get_sec_since_midnight(datetime(year=2014,
                                                         month=1,
                                                         day=1)))

        self.assertEqual(3600,
                         get_sec_since_midnight(datetime(year=2014,
                                                         month=1,
                                                         day=1,
                                                         hour=1)))

        self.assertEqual(56508,
                         get_sec_since_midnight(datetime(year=2014,
                                                         month=1,
                                                         day=1,
                                                         hour=15,
                                                         minute=41,
                                                         second=48)))

        self.assertEqual((16 * 3600) + (23 * 60) + 17,
                         get_sec_since_midnight(datetime(year=2014,
                                                         month=1,
                                                         day=1,
                                                         hour=16,
                                                         minute=23,
                                                         second=17)))
예제 #2
0
    def test_get_seconds_since_midnight(self):
        self.assertEqual(
            43,
            get_sec_since_midnight(
                datetime(year=2014, month=1, day=1, second=43)))

        self.assertEqual(
            0, get_sec_since_midnight(datetime(year=2014, month=1, day=1)))

        self.assertEqual(
            3600,
            get_sec_since_midnight(datetime(year=2014, month=1, day=1,
                                            hour=1)))

        self.assertEqual(
            56508,
            get_sec_since_midnight(
                datetime(year=2014,
                         month=1,
                         day=1,
                         hour=15,
                         minute=41,
                         second=48)))

        self.assertEqual((16 * 3600) + (23 * 60) + 17,
                         get_sec_since_midnight(
                             datetime(year=2014,
                                      month=1,
                                      day=1,
                                      hour=16,
                                      minute=23,
                                      second=17)))
예제 #3
0
def Response(apps_list, protocol='3.0', date=None, server='prod'):
    elapsed_seconds = get_sec_since_midnight(date or datetime.utcnow())
    resp = E.response(
        dict(protocol=protocol, server=server),
        E.daystart(elapsed_seconds=str(elapsed_seconds)),
    )
    list(map(resp.append, apps_list))
    return resp
예제 #4
0
def Response(apps_list, protocol='3.0', date=None, server='prod'):
    date = date or datetime.utcnow()
    elapsed_seconds = get_sec_since_midnight(date)
    elapsed_days = get_days_since_20070101(date)
    resp = E.response(
        dict(protocol=protocol, server=server),
        E.daystart(elapsed_seconds=str(elapsed_seconds), elapsed_days=str(elapsed_days)),
    )
    list(map(resp.append, apps_list))
    return resp
예제 #5
0
    def test_response(self):
        now = datetime.utcnow()
        elapsed_seconds = get_sec_since_midnight(now)
        root = Response(
            date=now,
            apps_list=[App(updatecheck=Updatecheck_negative(), **self.app_attr)])

        self.assertXmlNode(root, tag='response', text=None)
        self.assertXpathsExist(root, ('./daystart',))
        self.assertXpathsExist(root, ('./app',))
        self.assertXpathsExist(root, ('./daystart[@elapsed_seconds="%s"]' % elapsed_seconds,))
예제 #6
0
def Response(apps_list, protocol="3.0", date=None, server="prod"):
    elapsed_seconds = get_sec_since_midnight(date or datetime.utcnow())
    resp = E.response(dict(protocol=protocol, server=server), E.daystart(elapsed_seconds=str(elapsed_seconds)))
    list(map(resp.append, apps_list))
    return resp