Пример #1
0
    def test_one_arg_timestamp(self):

        timestamp = 12345
        timestamp_dt = datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz.tzutc())

        assertEqual(api.get(timestamp), timestamp_dt)
        assertEqual(api.get(str(timestamp)), timestamp_dt)

        timestamp = 123.45
        timestamp_dt = datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz.tzutc())

        assertEqual(api.get(timestamp), timestamp_dt)
        assertEqual(api.get(str(timestamp)), timestamp_dt)
Пример #2
0
    def test_one_arg_timestamp(self):

        timestamp = 12345
        timestamp_dt = datetime.utcfromtimestamp(timestamp).replace(
            tzinfo=tz.tzutc())

        assertEqual(api.get(timestamp), timestamp_dt)
        assertEqual(api.get(str(timestamp)), timestamp_dt)

        timestamp = 123.45
        timestamp_dt = datetime.utcfromtimestamp(timestamp).replace(
            tzinfo=tz.tzutc())

        assertEqual(api.get(timestamp), timestamp_dt)
        assertEqual(api.get(str(timestamp)), timestamp_dt)
Пример #3
0
def date_after_before(base_date, format, direction, limit, needs_parse=True):
    if needs_parse:
        base_date = parse_dt(base_date)

    days = rand_int(0, abs(limit))
    return arrow_api.get(direction(base_date,
                                   timedelta(days=days))).format(format)
Пример #4
0
    def test_no_args(self):

        result = api.get()

        assertDtEqual(result, datetime.utcnow().replace(tzinfo=tz.tzutc()))
Пример #5
0
    def test_no_args(self):

        result = api.get()

        assertDtEqual(result, datetime.utcnow().replace(tzinfo=tz.tzutc()))
Пример #6
0
def date_after_before(base_date, format, direction, limit, needs_parse=True):
    if needs_parse:
        base_date = parse_dt(base_date)

    days=rand_int(0, abs(limit))
    return arrow_api.get(direction(base_date, timedelta(days=days))).format(format)
Пример #7
0
    def test_two_args_other(self):

        with assertRaises(TypeError):
            api.get(object(), object())
Пример #8
0
    def test_two_args_datetime_other(self):

        with assertRaises(TypeError):
            api.get(datetime.utcnow(), object())
Пример #9
0
    def test_one_arg_other(self):

        with assertRaises(TypeError):
            api.get(object())
Пример #10
0
    def test_two_args_datetime_other(self):

        with assertRaises(TypeError):
            api.get(datetime.utcnow(), object())
Пример #11
0
    def test_two_args_datetime_tz_str(self):

        result = api.get(datetime(2013, 1, 1), 'US/Pacific')

        assertEqual(result._datetime,
                    datetime(2013, 1, 1, tzinfo=tz.gettz('US/Pacific')))
Пример #12
0
    def test_one_arg_other(self):

        with assertRaises(TypeError):
            api.get(object())
Пример #13
0
    def test_one_arg_tz_str(self):

        expected = datetime.utcnow().replace(tzinfo=tz.tzutc()).astimezone(
            tz.gettz('US/Pacific'))

        assertDtEqual(api.get('US/Pacific'), expected)
Пример #14
0
    def test_one_arg_datetime(self):

        dt = datetime.utcnow().replace(tzinfo=tz.tzutc())

        assertEqual(api.get(dt), dt)
Пример #15
0
    def test_one_arg_datetime(self):

        dt = datetime.utcnow().replace(tzinfo=tz.tzutc())

        assertEqual(api.get(dt), dt)
Пример #16
0
    def test_one_arg_tz_str(self):

        expected = datetime.utcnow().replace(tzinfo=tz.tzutc()).astimezone(tz.gettz("US/Pacific"))

        assertDtEqual(api.get("US/Pacific"), expected)
Пример #17
0
    def test_two_args_str_str(self):

        result = api.get('2013-01-01', 'YYYY-MM-DD')

        assertEqual(result._datetime, datetime(2013, 1, 1, tzinfo=tz.tzutc()))
Пример #18
0
    def test_two_args_datetime_tz_str(self):

        result = api.get(datetime(2013, 1, 1), "US/Pacific")

        assertEqual(result._datetime, datetime(2013, 1, 1, tzinfo=tz.gettz("US/Pacific")))
Пример #19
0
    def test_two_args_other(self):

        with assertRaises(TypeError):
            api.get(object(), object())
Пример #20
0
    def test_two_args_str_str(self):

        result = api.get("2013-01-01", "YYYY-MM-DD")

        assertEqual(result._datetime, datetime(2013, 1, 1, tzinfo=tz.tzutc()))
Пример #21
0
    def test_three_args(self):

        assertEqual(api.get(2013, 1, 1), datetime(2013,
                                                  1,
                                                  1,
                                                  tzinfo=tz.tzutc()))
Пример #22
0
    def test_three_args(self):

        assertEqual(api.get(2013, 1, 1), datetime(2013, 1, 1, tzinfo=tz.tzutc()))
Пример #23
0
    def test_get_unicode(self):

        assertEqual(api.get('۱۳۹۳-۰۲-۱۰', 'YYYY-MM-DD'), '2014-05-00')
Пример #24
0
    def test_get(self):

        expect(api._factory.get).args(1, b=2).returns('result')

        assertEqual(api.get(1, b=2), 'result')
Пример #25
0
    def test_get(self):

        self.expect(api._factory.get).args(1, b=2).returns("result")

        self.assertEqual(api.get(1, b=2), "result")