Ejemplo n.º 1
0
def test_less_than_true():
    d1 = pendulum.datetime(2000, 1, 1)
    d2 = pendulum.datetime(2000, 1, 2)
    d3 = datetime(2000, 1, 2, tzinfo=pendulum.UTC)

    assert d1 < d2
    assert d1 < d3
Ejemplo n.º 2
0
def test_less_than_or_equal_with_timezone_false():
    d1 = pendulum.datetime(2000, 1, 1, 9, 0, 1, tz="America/Vancouver")
    d2 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
    d3 = pytz.timezone("America/Toronto").localize(datetime(2000, 1, 1, 12, 0, 0))

    assert not d1 <= d2
    assert not d1 <= d3
Ejemplo n.º 3
0
def test_not_contains():
    dt1 = pendulum.datetime(2000, 1, 1, 12, 45, 37)
    dt2 = pendulum.datetime(2000, 1, 31, 12, 45, 37)

    p = pendulum.period(dt1, dt2)
    dt = pendulum.datetime(2000, 1, 1, 11, 45, 37)
    assert dt not in p
Ejemplo n.º 4
0
def test_contains_with_datetime():
    dt1 = pendulum.datetime(2000, 1, 1, 12, 45, 37)
    dt2 = pendulum.datetime(2000, 1, 31, 12, 45, 37)

    p = pendulum.period(dt1, dt2)
    dt = pendulum.datetime(2000, 1, 7)
    assert dt in p
Ejemplo n.º 5
0
def test_add_time_to_new_transition_repeated():
    dt = pendulum.datetime(2013, 10, 27, 1, 59, 59, 999999, tz="Europe/Paris")
    dt = dt.add(hours=1)

    assert_datetime(dt, 2013, 10, 27, 2, 59, 59, 999999)
    assert dt.timezone_name == "Europe/Paris"
    assert dt.offset == 7200
    assert dt.is_dst()

    dt = dt.add(microseconds=1)

    assert_datetime(dt, 2013, 10, 27, 2, 0, 0, 0)
    assert dt.timezone_name == "Europe/Paris"
    assert dt.offset == 3600
    assert not dt.is_dst()

    dt = pendulum.datetime(2013, 11, 3, 0, 59, 59, 999999, tz="America/New_York")
    print(dt)
    dt = dt.add(hours=1)
    print(dt)

    assert_datetime(dt, 2013, 11, 3, 1, 59, 59, 999999)
    assert dt.timezone_name == "America/New_York"
    assert dt.offset == -4 * 3600
    assert dt.is_dst()

    dt = dt.add(microseconds=1)

    assert_datetime(dt, 2013, 11, 3, 1, 0, 0, 0)
    assert dt.timezone_name == "America/New_York"
    assert dt.offset == -5 * 3600
    assert not dt.is_dst()
Ejemplo n.º 6
0
def test_comparison_to_timedelta():
    dt1 = pendulum.datetime(2016, 11, 18)
    dt2 = pendulum.datetime(2016, 11, 20)

    period = dt2 - dt1

    assert period < timedelta(days=4)
Ejemplo n.º 7
0
def test_pickle():
    dt1 = pendulum.datetime(2016, 11, 18)
    dt2 = pendulum.datetime(2016, 11, 20)

    p = pendulum.period(dt1, dt2)
    s = pickle.dumps(p)
    p2 = pickle.loads(s)

    assert p.start == p2.start
    assert p.end == p2.end
    assert p.invert == p2.invert

    p = pendulum.period(dt2, dt1)
    s = pickle.dumps(p)
    p2 = pickle.loads(s)

    assert p.start == p2.start
    assert p.end == p2.end
    assert p.invert == p2.invert

    p = pendulum.period(dt2, dt1, True)
    s = pickle.dumps(p)
    p2 = pickle.loads(s)

    assert p.start == p2.start
    assert p.end == p2.end
    assert p.invert == p2.invert
Ejemplo n.º 8
0
def test_fractional_second():
    f = Formatter()
    d = pendulum.datetime(2016, 8, 28, 7, 3, 6, 123456)
    assert f.format(d, "S") == "1"
    assert f.format(d, "SS") == "12"
    assert f.format(d, "SSS") == "123"
    assert f.format(d, "SSSS") == "1234"
    assert f.format(d, "SSSSS") == "12345"
    assert f.format(d, "SSSSSS") == "123456"

    d = pendulum.datetime(2016, 8, 28, 7, 3, 6, 0)
    assert f.format(d, "S") == "0"
    assert f.format(d, "SS") == "00"
    assert f.format(d, "SSS") == "000"
    assert f.format(d, "SSSS") == "0000"
    assert f.format(d, "SSSSS") == "00000"
    assert f.format(d, "SSSSSS") == "000000"

    d = pendulum.datetime(2016, 8, 28, 7, 3, 6, 123)
    assert f.format(d, "S") == "0"
    assert f.format(d, "SS") == "00"
    assert f.format(d, "SSS") == "000"
    assert f.format(d, "SSSS") == "0001"
    assert f.format(d, "SSSSS") == "00012"
    assert f.format(d, "SSSSSS") == "000123"
Ejemplo n.º 9
0
def test_less_than_or_equal_false():
    d1 = pendulum.datetime(2000, 1, 2)
    d2 = pendulum.datetime(2000, 1, 1)
    d3 = datetime(2000, 1, 1, tzinfo=pendulum.UTC)

    assert not d1 <= d2
    assert not d1 <= d3
Ejemplo n.º 10
0
def test_greater_than_true():
    d1 = pendulum.datetime(2000, 1, 1)
    d2 = pendulum.datetime(1999, 12, 31)
    d3 = datetime(1999, 12, 31, tzinfo=pendulum.UTC)

    assert d1 > d2
    assert d1 > d3
Ejemplo n.º 11
0
def test_not_equal_with_timezone_true():
    d1 = pendulum.datetime(2000, 1, 1, tz="America/Toronto")
    d2 = pendulum.datetime(2000, 1, 1, tz="America/Vancouver")
    d3 = datetime(2000, 1, 1, tzinfo=pendulum.timezone("America/Toronto"))

    assert d2 != d1
    assert d3 == d1
Ejemplo n.º 12
0
def test_less_than_or_equal_true_equal():
    d1 = pendulum.datetime(2000, 1, 1)
    d2 = pendulum.datetime(2000, 1, 1)
    d3 = datetime(2000, 1, 1, tzinfo=pendulum.UTC)

    assert d1 <= d2
    assert d1 <= d3
Ejemplo n.º 13
0
def test_equal_to_true():
    d1 = pendulum.datetime(2000, 1, 1, 1, 2, 3)
    d2 = pendulum.datetime(2000, 1, 1, 1, 2, 3)
    d3 = datetime(2000, 1, 1, 1, 2, 3, tzinfo=pendulum.UTC)

    assert d2 == d1
    assert d3 == d1
Ejemplo n.º 14
0
def test_greater_than_false():
    d1 = pendulum.datetime(2000, 1, 1)
    d2 = pendulum.datetime(2000, 1, 2)
    d3 = datetime(2000, 1, 2, tzinfo=pendulum.UTC)

    assert not d1 > d2
    assert not d1 > d3
Ejemplo n.º 15
0
def test_greater_than_with_timezone_true():
    d1 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
    d2 = pendulum.datetime(2000, 1, 1, 8, 59, 59, tz="America/Vancouver")
    d3 = pytz.timezone("America/Vancouver").localize(datetime(2000, 1, 1, 8, 59, 59))

    assert d1 > d2
    assert d1 > d3
Ejemplo n.º 16
0
def test_timezone():
    f = Formatter()
    d = pendulum.datetime(2016, 8, 28, 7, 3, 6, 123456, tz="Europe/Paris")
    assert f.format(d, "zz") == "CEST"
    assert f.format(d, "z") == "Europe/Paris"

    d = pendulum.datetime(2016, 1, 28, 7, 3, 6, 123456, tz="Europe/Paris")
    assert f.format(d, "zz") == "CET"
    assert f.format(d, "z") == "Europe/Paris"
Ejemplo n.º 17
0
def test_hour():
    f = Formatter()
    d = pendulum.datetime(2016, 8, 28, 7)
    assert f.format(d, "H") == "7"
    assert f.format(d, "HH") == "07"

    d = pendulum.datetime(2016, 8, 28, 0)
    assert f.format(d, "h") == "12"
    assert f.format(d, "hh") == "12"
Ejemplo n.º 18
0
def test_in_timezone():
    d = pendulum.datetime(2015, 1, 15, 18, 15, 34)
    now = pendulum.datetime(2015, 1, 15, 18, 15, 34)
    assert d.timezone_name == "UTC"
    assert_datetime(d, now.year, now.month, now.day, now.hour, now.minute)

    d = d.in_timezone("Europe/Paris")
    assert d.timezone_name == "Europe/Paris"
    assert_datetime(d, now.year, now.month, now.day, now.hour + 1, now.minute)
Ejemplo n.º 19
0
def test_range():
    dt1 = pendulum.datetime(2000, 1, 1, 12, 45, 37)
    dt2 = pendulum.datetime(2000, 1, 31, 12, 45, 37)

    p = Period(dt1, dt2)
    r = list(p.range("days"))

    assert len(r) == 31
    assert_datetime(r[0], 2000, 1, 1, 12, 45, 37)
    assert_datetime(r[-1], 2000, 1, 31, 12, 45, 37)
Ejemplo n.º 20
0
def test_repr():
    d = pendulum.datetime(1975, 12, 25, 14, 15, 16, tz="local")
    expected = "DateTime(1975, 12, 25, 14, 15, 16, tzinfo={})".format(repr(d.tzinfo))
    assert repr(d) == expected

    d = pendulum.datetime(1975, 12, 25, 14, 15, 16, 123456, tz="local")
    expected = "DateTime(1975, 12, 25, 14, 15, 16, 123456, tzinfo={})".format(
        repr(d.tzinfo)
    )
    assert repr(d) == expected
Ejemplo n.º 21
0
def test_iter():
    dt1 = pendulum.datetime(2000, 1, 1, 12, 45, 37)
    dt2 = pendulum.datetime(2000, 1, 31, 12, 45, 37)

    p = Period(dt1, dt2)
    i = 0
    for dt in p:
        assert isinstance(dt, pendulum.DateTime)
        i += 1

    assert i == 31
Ejemplo n.º 22
0
def test_is_same_day():
    dt1 = pendulum.datetime(2015, 5, 28, 12, 0, 0)
    dt2 = pendulum.datetime(2015, 5, 29, 12, 0, 0)
    dt3 = pendulum.datetime(2015, 5, 28, 12, 0, 0)
    dt4 = datetime(2015, 5, 28, 12, 0, 0, tzinfo=pendulum.UTC)
    dt5 = datetime(2015, 5, 29, 12, 0, 0, tzinfo=pendulum.UTC)

    assert not dt1.is_same_day(dt2)
    assert dt1.is_same_day(dt3)
    assert dt1.is_same_day(dt4)
    assert not dt1.is_same_day(dt5)
Ejemplo n.º 23
0
def test_pendulum_create_repeated_with_error():
    with pytest.raises(AmbiguousTime):
        pendulum.datetime(
            2013,
            10,
            27,
            2,
            30,
            45,
            123456,
            tz="Europe/Paris",
            dst_rule=pendulum.TRANSITION_ERROR,
        )
Ejemplo n.º 24
0
def test_pendulum_create_skipped_with_error():
    with pytest.raises(NonExistingTime):
        pendulum.datetime(
            2013,
            3,
            31,
            2,
            30,
            45,
            123456,
            tz="Europe/Paris",
            dst_rule=pendulum.TRANSITION_ERROR,
        )
Ejemplo n.º 25
0
def test_timezone_offset():
    f = Formatter()
    d = pendulum.datetime(2016, 8, 28, 7, 3, 6, 123456, tz="Europe/Paris")
    assert f.format(d, "ZZ") == "+0200"
    assert f.format(d, "Z") == "+02:00"

    d = pendulum.datetime(2016, 1, 28, 7, 3, 6, 123456, tz="Europe/Paris")
    assert f.format(d, "ZZ") == "+0100"
    assert f.format(d, "Z") == "+01:00"

    d = pendulum.datetime(2016, 1, 28, 7, 3, 6, 123456, tz="America/Guayaquil")
    assert f.format(d, "ZZ") == "-0500"
    assert f.format(d, "Z") == "-05:00"
Ejemplo n.º 26
0
def test_farthest_with_equals():
    instance = pendulum.datetime(2015, 5, 28, 12, 0, 0)
    dt1 = pendulum.datetime(2015, 5, 28, 12, 0, 0)
    dt2 = pendulum.datetime(2015, 5, 28, 14, 0, 0)
    farthest = instance.farthest(dt1, dt2)
    assert farthest == dt2

    dts = [
        pendulum.datetime(2015, 5, 28, 16, 0, 0) + pendulum.duration(hours=x)
        for x in range(4)
    ]
    farthest = instance.farthest(dt1, dt2, *dts)
    assert farthest == dts[-1]
Ejemplo n.º 27
0
def test_closest_with_datetime():
    instance = pendulum.datetime(2015, 5, 28, 12, 0, 0)
    dt1 = datetime(2015, 5, 28, 11, 0, 0)
    dt2 = datetime(2015, 5, 28, 14, 0, 0)
    closest = instance.closest(dt1, dt2)
    assert_datetime(closest, 2015, 5, 28, 11, 0, 0)

    dts = [
        pendulum.datetime(2015, 5, 28, 16, 0, 0) + pendulum.duration(hours=x)
        for x in range(4)
    ]
    closest = instance.closest(dt1, dt2, *dts)

    assert_datetime(closest, 2015, 5, 28, 11, 0, 0)
Ejemplo n.º 28
0
def test_farthest_with_datetime():
    instance = pendulum.datetime(2015, 5, 28, 12, 0, 0)
    dt1 = datetime(2015, 5, 28, 11, 0, 0, tzinfo=pendulum.UTC)
    dt2 = datetime(2015, 5, 28, 14, 0, 0, tzinfo=pendulum.UTC)
    farthest = instance.farthest(dt1, dt2)
    assert_datetime(farthest, 2015, 5, 28, 14, 0, 0)

    dts = [
        pendulum.datetime(2015, 5, 28, 16, 0, 0) + pendulum.duration(hours=x)
        for x in range(4)
    ]
    farthest = instance.farthest(dt1, dt2, *dts)

    assert_datetime(farthest, 2015, 5, 28, 19, 0, 0)
Ejemplo n.º 29
0
def test_is_birthday():
    with pendulum.test(pendulum.now()):
        d = pendulum.now()
        a_birthday = d.subtract(years=1)
        assert a_birthday.is_birthday()
        not_a_birthday = d.subtract(days=1)
        assert not not_a_birthday.is_birthday()
        also_not_a_birthday = d.add(days=2)
        assert not also_not_a_birthday.is_birthday()

    d1 = pendulum.datetime(1987, 4, 23)
    d2 = pendulum.datetime(2014, 9, 26)
    d3 = pendulum.datetime(2014, 4, 23)
    assert not d2.is_birthday(d1)
    assert d3.is_birthday(d1)
Ejemplo n.º 30
0
    def set(
        self,
        year=None,
        month=None,
        day=None,
        hour=None,
        minute=None,
        second=None,
        microsecond=None,
        tz=None,
    ):
        if year is None:
            year = self.year
        if month is None:
            month = self.month
        if day is None:
            day = self.day
        if hour is None:
            hour = self.hour
        if minute is None:
            minute = self.minute
        if second is None:
            second = self.second
        if microsecond is None:
            microsecond = self.microsecond
        if tz is None:
            tz = self.tz

        return pendulum.datetime(
            year, month, day, hour, minute, second, microsecond, tz=tz
        )
Ejemplo n.º 31
0
def test_sub_days_zero():
    assert pendulum.datetime(1975, 5, 31).subtract(days=0).day == 31
Ejemplo n.º 32
0
    def post(self, request, format=None):
        """
        Return a list of all users.
        """
        new_pairs = []
        day_of_week = request.POST["day_of_week"]
        cohort_id = request.POST["cohort_id"]
        print("day_of_week", day_of_week)
        print("cohort_id", cohort_id)
        day_of_week_list = day_of_week.split("-")
        print("day_of_week_list", day_of_week_list)

        pendulum_date = pendulum.datetime(int(str(day_of_week_list[0])),
                                          int(str(day_of_week_list[1])),
                                          int(str(day_of_week_list[2])))
        start_date = pendulum_date.start_of('week')
        end_date = pendulum_date.end_of('week')
        formated_start_date = str(start_date)[0:10]
        formated_end_date = str(end_date)[0:10]
        print("start_date", formated_start_date)
        print("end_date", formated_end_date)
        retrived_cohort = Cohort.objects.get(id=cohort_id)
        if StudentPair.objects.filter(cohort=retrived_cohort,
                                      start_date=formated_start_date).exists():
            response = {"ERROR": 'Pairs for that week already exists'}
            return Response(response)
        students_cohort = Account.objects.filter(is_student=True,
                                                 cohort=retrived_cohort)

        Weeks = StudentPair.objects.order_by('start_date').distinct(
            'start_date')
        print('WEEKS', Weeks)
        weeks_list = []
        for week in Weeks:
            weeks_list.append(week.start_date)
        print('WEEKS_LIST', weeks_list)
        pairing_history = []
        for each_week in weeks_list:
            one_week_history = []
            weekly_pairs = StudentPair.objects.filter(start_date=each_week)
            for week_pair in weekly_pairs:
                print('WEEK PAIR', each_week, week_pair)
                pair = []
                if week_pair.third_student == None:
                    first = week_pair.first_student_id
                    second = week_pair.second_student_id
                    pair.append(first)
                    pair.append(second)
                else:
                    first = week_pair.first_student_id
                    second = week_pair.second_student_id
                    third = week_pair.third_student_id
                    pair.append(first)
                    pair.append(second)
                    pair.append(third)

                one_week_history.append(pair)
                print('ONE_WEEK_HIST', one_week_history)

            pairing_history.append(one_week_history)
            print('PAIRNG_WEEK_HIST', pairing_history)

        all_students = []
        for student in students_cohort:
            student_id = student.id
            all_students.append(student_id)
        print('student id', all_students)
        all_students_copy = copy.deepcopy(all_students)
        pairing_history_copy = copy.deepcopy(pairing_history)
        new_pairs = pairup(all_students_copy, pairing_history_copy)
        print('new pairs', new_pairs)
        for pair in new_pairs:
            new_student_pair = StudentPair()
            new_student_pair.start_date = formated_start_date
            new_student_pair.end_date = formated_end_date
            new_student_pair.cohort = retrived_cohort

            if len(pair) == 2:
                student1_id = pair[0]
                student2_id = pair[1]
                new_student_pair.first_student_id = student1_id
                new_student_pair.second_student_id = student2_id
            if len(pair) == 3:
                student1_id = pair[0]
                student2_id = pair[1]
                student3_id = pair[2]
                new_student_pair.first_student_id = student1_id
                new_student_pair.second_student_id = student2_id
                new_student_pair.third_student_id = student3_id
            new_student_pair.save()
        response = {'message': 'Successfully Created Pairs'}
        print("All students", all_students)
        return Response(response)
Ejemplo n.º 33
0
# 2、转字符串
print(pendulum.now().to_datetime_string())
# 2019-12-12 15:51:22

print(pendulum.now().to_date_string())
# 2019-12-12

print(pendulum.now().to_time_string())
# 22:25:05

print(pendulum.now().format('%Y-%m-%d'))
# 2019-12-12

# 3、类型测试
from datetime import datetime
dt = pendulum.datetime(2015, 2, 5)
print(isinstance(dt, datetime))
#True

print("####" * 30)

# 4、解析规范的时间
print(pendulum.from_format('2019-12-12', '%Y-%m-%d'))
# 2019-12-12T00:00:00+00:00

print(pendulum.parse('2019-12-12'))
# 2019-12-12T00:00:00+00:00

# 6、属性
now = pendulum.now()
print(now.year)
Ejemplo n.º 34
0
def test_start_of_decade_from_last_day():
    d = pendulum.datetime(2009, 12, 31, 23, 59, 59)
    new = d.start_of('decade')
    assert_datetime(new, 2000, 1, 1, 0, 0, 0, 0)
Ejemplo n.º 35
0
def test_end_of_year_from_last_day():
    d = pendulum.datetime(2000, 12, 31, 23, 59, 59, 999999)
    new = d.end_of('year')
    assert_datetime(new, 2000, 12, 31, 23, 59, 59, 999999)
Ejemplo n.º 36
0
def test_end_of_century_from_last_day():
    d = pendulum.datetime(2100, 12, 31, 23, 59, 59, 999999)
    new = d.end_of('century')
    assert_datetime(new, 2100, 12, 31, 23, 59, 59, 999999)
Ejemplo n.º 37
0
def test_start_of_century_from_first_day():
    d = pendulum.datetime(2001, 1, 1, 1, 1, 1)
    new = d.start_of('century')
    assert_datetime(new, 2001, 1, 1, 0, 0, 0, 0)
Ejemplo n.º 38
0
 def get_stream_data(self, response_data) -> List[dict]:
     bans = response_data["ip_address"] + response_data["visitor"]
     bans = sorted(bans, key=lambda x: pendulum.parse(x["created_at"]) if x["created_at"] else pendulum.datetime(1970, 1, 1))
     return bans
Ejemplo n.º 39
0
# Parsec Cloud (https://parsec.cloud) Copyright (c) AGPLv3 2016-2021 Scille SAS

import pytest
import pendulum

from parsec.api.data import EntryName

from tests.common import freeze_time

day0 = pendulum.datetime(1999, 12, 31)
day1 = pendulum.datetime(2000, 1, 1)
day2 = pendulum.datetime(2000, 1, 2)
day3 = pendulum.datetime(2000, 1, 3)
day4 = pendulum.datetime(2000, 1, 4)
day5 = pendulum.datetime(2000, 1, 5)
day6 = pendulum.datetime(2000, 1, 6)
day7 = pendulum.datetime(2000, 1, 7)
day8 = pendulum.datetime(2000, 1, 8)
day9 = pendulum.datetime(2000, 1, 9)
day10 = pendulum.datetime(2000, 1, 10)
day11 = pendulum.datetime(2000, 1, 11)
day12 = pendulum.datetime(2000, 1, 12)
day13 = pendulum.datetime(2000, 1, 13)
day14 = pendulum.datetime(2000, 1, 14)


@pytest.fixture
@pytest.mark.trio
async def alice_workspace(alice_user_fs, running_backend):
    with freeze_time(day0):
        wid = await alice_user_fs.workspace_create(EntryName("w"))
Ejemplo n.º 40
0
def test_sub_years_negative():
    assert pendulum.datetime(1975, 1, 1).subtract(years=-1).year == 1976
Ejemplo n.º 41
0
def test_sub_years_zero():
    assert pendulum.datetime(1975, 1, 1).subtract(years=0).year == 1975
Ejemplo n.º 42
0
def test_sub_months_zero():
    assert pendulum.datetime(1975, 12, 1).subtract(months=0).month == 12
Ejemplo n.º 43
0
def test_sub_months_negative():
    assert pendulum.datetime(1975, 12, 1).subtract(months=-1).month == 1
Ejemplo n.º 44
0
def test_sub_days_positive():
    assert pendulum.datetime(1975, 5, 31).subtract(days=1).day == 30
Ejemplo n.º 45
0
def test_average_from_lower():
    d1 = pendulum.datetime(2009, 12, 31, 23, 59, 59, tz='local')
    d2 = pendulum.datetime(2000, 1, 1, 1, 1, 1, tz='local').average(d1)
    assert_datetime(d2, 2004, 12, 31, 12, 30, 30)
Ejemplo n.º 46
0
async def test_new_reencryption_trigger_event(alice_core, bob_core,
                                              running_backend):
    with freeze_time("2000-01-02"):
        wid = await create_shared_workspace("w", alice_core, bob_core)

    with alice_core.event_bus.listen() as aspy, bob_core.event_bus.listen(
    ) as bspy:
        with freeze_time("2000-01-03"):
            await alice_core.user_fs.workspace_start_reencryption(wid)

        # Each workspace participant should get the message
        await aspy.wait_with_timeout(
            CoreEvent.SHARING_UPDATED,
            {
                "new_entry":
                WorkspaceEntry(
                    name="w",
                    id=wid,
                    key=ANY,
                    encryption_revision=2,
                    encrypted_on=datetime(2000, 1, 3),
                    role_cached_on=ANY,
                    role=WorkspaceRole.OWNER,
                ),
                "previous_entry":
                WorkspaceEntry(
                    name="w",
                    id=wid,
                    key=ANY,
                    encryption_revision=1,
                    encrypted_on=datetime(2000, 1, 2),
                    role_cached_on=ANY,
                    role=WorkspaceRole.OWNER,
                ),
            },
        )
        await bspy.wait_with_timeout(
            CoreEvent.SHARING_UPDATED,
            {
                "new_entry":
                WorkspaceEntry(
                    name="w",
                    id=wid,
                    key=ANY,
                    encryption_revision=2,
                    encrypted_on=datetime(2000, 1, 3),
                    role_cached_on=ANY,
                    role=WorkspaceRole.MANAGER,
                ),
                "previous_entry":
                WorkspaceEntry(
                    name="w",
                    id=wid,
                    key=ANY,
                    encryption_revision=1,
                    encrypted_on=datetime(2000, 1, 2),
                    role_cached_on=ANY,
                    role=WorkspaceRole.MANAGER,
                ),
            },
        )
Ejemplo n.º 47
0
def test_average_from_same():
    d1 = pendulum.datetime(2000, 1, 31, 2, 3, 4)
    d2 = pendulum.datetime(2000, 1, 31, 2, 3, 4).average(d1)
    assert_datetime(d2, 2000, 1, 31, 2, 3, 4)
Ejemplo n.º 48
0
def test_diff_for_humans():
    with pendulum.test(pendulum.datetime(2016, 8, 29)):
        diff_for_humans()
Ejemplo n.º 49
0
def test_start_of_century_from_last_day():
    d = pendulum.datetime(2100, 12, 31, 23, 59, 59)
    new = d.start_of('century')
    assert_datetime(new, 2001, 1, 1, 0, 0, 0, 0)
Ejemplo n.º 50
0
def test_start_of_year_from_last_day():
    d = pendulum.datetime(2000, 12, 31, 23, 59, 59)
    new = d.start_of('year')
    assert_datetime(new, 2000, 1, 1, 0, 0, 0, 0)
Ejemplo n.º 51
0
def test_end_of_decade_from_last_day():
    d = pendulum.datetime(2009, 12, 31, 23, 59, 59, 999999)
    new = d.end_of('decade')
    assert_datetime(new, 2009, 12, 31, 23, 59, 59, 999999)
Ejemplo n.º 52
0
def test_start_of_year_from_first_day():
    d = pendulum.datetime(2000, 1, 1, 1, 1, 1)
    new = d.start_of('year')
    assert_datetime(new, 2000, 1, 1, 0, 0, 0, 0)
Ejemplo n.º 53
0
def test_start_of_decade_from_first_day():
    d = pendulum.datetime(2000, 1, 1, 1, 1, 1)
    new = d.start_of('decade')
    assert_datetime(new, 2000, 1, 1, 0, 0, 0, 0)
Ejemplo n.º 54
0
def test_start_of_month_from_last_day():
    d = pendulum.datetime(2000, 1, 31, 2, 3, 4)
    new = d.start_of('month')
    assert_datetime(new, 2000, 1, 1, 0, 0, 0, 0)
Ejemplo n.º 55
0
def test_end_of_month_from_last_day():
    d = pendulum.datetime(2000, 1, 31, 2, 3, 4)
    new = d.end_of('month')
    assert_datetime(new, 2000, 1, 31, 23, 59, 59)
Ejemplo n.º 56
0
def test_end_of_with_transition():
    d = pendulum.datetime(2013, 3, 31, tz='Europe/Paris')
    assert d.offset == 3600
    assert d.end_of('month').offset == 7200
    assert d.end_of('day').offset == 7200
    assert d.end_of('year').offset == 3600
Ejemplo n.º 57
0
def fixed_day() -> pendulum.DateTime:
    day_of_test = pendulum.datetime(2020, 1, 2, tz=config.tz)
    return day_of_test
Ejemplo n.º 58
0
def test_start_of_with_transition():
    d = pendulum.datetime(2013, 10, 27, 23, 59, 59, tz='Europe/Paris')
    assert d.offset == 3600
    assert d.start_of('month').offset == 7200
    assert d.start_of('day').offset == 7200
    assert d.start_of('year').offset == 3600
Ejemplo n.º 59
0
def test_sub_days_negative():
    assert pendulum.datetime(1975, 5, 31).subtract(days=-1).day == 1
Ejemplo n.º 60
0
from moc_data_flow import tsx_imb_fl

# prefect
# cloud_agent_token = "xyz"
project_name = "market-on-close"

# aws
# aws_ecr_repo_name = dckr_image_name
aws_region = "us-east-2"

############## Schedule when to run the script ##############
schedule = Schedule(
    # fire every day
    clocks=[
        clocks.IntervalClock(start_date=pendulum.datetime(
            2020, 4, 22, 17, 30, tz="America/Toronto"),
                             interval=timedelta(days=1))
    ],
    # but only on weekdays
    filters=[filters.is_weekday],

    # and not in January TODO: Add TSX Holidays
    not_filters=[filters.between_dates(1, 1, 1, 31)])

#tsx_imb_fl.schedule = schedule

############## Storage ecr docker flow ##############
dkr_ecr_scrt = PrefectSecret("docker_ecr_login").run()

get_ecr_auth_token = ShellTask(helper_script="cd ~")
ecr_auth_token = get_ecr_auth_token.run(command=dkr_ecr_scrt)