Пример #1
0
def test_zulu_span_frame_error():
    frame = "temp"
    dt = Zulu(2015, 4, 4, 12, 30)

    with pytest.raises(ValueError) as exc:
        dt.span(frame)

    assert "Time frame must be one of" in str(exc.value)
    assert "not '{0}'".format(frame)
Пример #2
0
def test_datetime_span_frame_error():
    frame = 'temp'
    dt = Zulu(2015, 4, 4, 12, 30)

    with pytest.raises(ValueError) as exc:
        dt.span(frame)

    assert 'Time frame must be one of' in str(exc.value)
    assert "not '{0}'".format(frame)
Пример #3
0
def test_datetime_now_is_utcnow(factory):
    dt = Zulu.now()
    expected = factory()

    # NOTE: Intentionally skip comparison to microsecond since they will almost
    # always be different.
    assert dt.year == expected.year
    assert dt.month == expected.month
    assert dt.day == expected.day
    assert dt.hour == expected.hour
    assert dt.minute == expected.minute
    assert dt.second == expected.second
Пример #4
0
def test_zulu_now_is_utcnow(factory):
    dt = Zulu.now()
    expected = factory()

    # NOTE: Intentionally skip comparison to microsecond since they will almost
    # always be different.
    assert dt.year == expected.year
    assert dt.month == expected.month
    assert dt.day == expected.day
    assert dt.hour == expected.hour
    assert dt.minute == expected.minute
    assert dt.second == expected.second
Пример #5
0
def test_zulu_fromordinal():
    assert Zulu.fromordinal(730120) == Zulu(2000, 1, 1)
Пример #6
0
                                              tzinfo=UTC)),
        (
            {
                "year": 2000,
                "month": 1,
                "day": 1,
                "hour": 12,
                "minute": 0,
                "second": 0,
                "tzinfo": "UTC+2359",
            },
            datetime(1999, 12, 31, 12, 1, tzinfo=UTC),
        ),
        (0, datetime(1970, 1, 1, tzinfo=UTC)),
        (datetime(2000, 1, 1, tzinfo=UTC), datetime(2000, 1, 1, tzinfo=UTC)),
        (Zulu(2000, 1, 1), datetime(2000, 1, 1, tzinfo=UTC)),
    ],
)
def test_zulu_parse(obj, expected):
    assert Zulu.parse(obj) == expected


@parametrize(
    "string,kargs,exception",
    [
        ("2000/01/01", {}, ParseError),
        ("01/01/2000", {}, ParseError),
        ("01-01-2000", {}, ParseError),
        ("2000-01-01X00:00:00", {}, ParseError),
        ("2000-01-01T00,00,00", {}, ParseError),
        ("2000-01-01T00:00:00+2400", {}, ParseError),
Пример #7
0
def test_datetime_parse(string, expected):
    assert Zulu.parse(string) == expected
Пример #8
0
def test_datetime_fromlocaltime():
    now = localtime()
    assert Zulu.fromlocaltime(now).timestamp() == mktime(now)
Пример #9
0
def test_datetime_strptime(string, fmt, expected):
    assert Zulu.strptime(string, fmt) == expected
Пример #10
0
def test_datetime_range_error(frame, start, end):
    with pytest.raises(ParseError):
        list(Zulu.range(frame, start, end))
Пример #11
0
def test_zulu_time_to_now():
    assert Zulu.now().shift(minutes=1).time_to_now() == '1 minute ago'
    assert Zulu.now().shift(minutes=-1).time_to_now() == 'in 1 minute'
Пример #12
0
def test_zulu_defaults():
    assert Zulu() == Zulu.fromtimestamp(0)
    assert create() == Zulu()
Пример #13
0
def test_zulu_parse_invalid(string, kargs, exception):
    with pytest.raises(exception):
        Zulu.parse(string, **kargs)
Пример #14
0
def test_zulu_pickle():
    dt = Zulu()
    unpickled = pickle.loads(pickle.dumps(dt))

    assert isinstance(unpickled, Zulu)
    assert unpickled == dt
Пример #15
0
def test_zulu_is_leap_year(year, expected):
    assert Zulu(year).is_leap_year() == expected
Пример #16
0
def test_zulu_range_error(frame, start, end):
    with pytest.raises(ParseError):
        list(Zulu.range(frame, start, end))
Пример #17
0
def test_zulu_range(frame, start, end, expected):
    time_range = list(Zulu.range(frame, start, end))

    assert time_range == expected
Пример #18
0
def test_zulu_copy():
    dt = Zulu(2000, 1, 1)
    copy = dt.copy()

    assert copy is not dt
    assert copy == dt
Пример #19
0
def test_zulu_as_int():
    tm = 1498672470.4801
    dt = Zulu.fromtimestamp(tm)
    assert int(dt) == int(tm)
Пример #20
0
def test_zulu_parse_format(string, kargs, expected):
    assert Zulu.parse(string, **kargs) == expected
Пример #21
0
def test_datetime_span_range(frame, start, end, expected):
    span_range = []
    for time_span in Zulu.span_range(frame, start, end):
        span_range.append(time_span)

    assert span_range == expected
Пример #22
0
def test_zulu_parse_pattern_mapping(string, pattern):
    pat_dt = Zulu.parse(string, DATE_PATTERN_TO_DIRECTIVE[pattern])
    dt = Zulu.parse(string, pattern)

    assert pat_dt == dt
Пример #23
0
def test_datetime_defaults():
    assert Zulu() == Zulu.fromtimestamp(0)
    assert create() == Zulu()
Пример #24
0
def test_zulu_strptime(string, fmt, expected):
    assert Zulu.strptime(string, fmt) == expected
Пример #25
0
def test_datetime_fromgmtime(struct, expected):
    assert Zulu.fromgmtime(struct) == expected
Пример #26
0
def test_zulu_fromdatetime(dt, expected):
    assert Zulu.fromdatetime(dt) == expected
Пример #27
0
def test_zulu_parse(obj, expected):
    assert Zulu.parse(obj) == expected
Пример #28
0
def test_zulu_fromgmtime(struct, expected):
    assert Zulu.fromgmtime(struct) == expected
Пример #29
0
def test_datetime_parse_invalid(string, kargs, exception):
    with pytest.raises(exception):
        Zulu.parse(string, **kargs)
Пример #30
0
def test_zulu_fromordinal():
    assert Zulu.fromordinal(730120) == Zulu(2000, 1, 1)
Пример #31
0
def test_zulu_fromgmtime(struct, expected):
    assert Zulu.fromgmtime(struct) == expected
Пример #32
0
def test_zulu_fromlocaltime():
    now = localtime()
    assert Zulu.fromlocaltime(now).timestamp() == mktime(now)
Пример #33
0
def test_zulu_fold(dt, timezone, expected_fold):
    zoned = dt.astimezone(timezone)
    assert zoned.fold == expected_fold
    assert dt == Zulu.fromdatetime(zoned)
Пример #34
0
def test_zulu_combine(date, time, expected):
    dt = Zulu.combine(date, time)
    assert dt == expected
Пример #35
0
def test_zulu_as_float():
    tm = 1498672470.4801
    dt = Zulu.fromtimestamp(tm)
    assert '{:.4f}'.format(float(dt)) == '{:.4f}'.format(tm)
Пример #36
0
def test_zulu_fold(dt, timezone, expected_fold):
    zoned = dt.astimezone(timezone)
    assert zoned.fold == expected_fold
    assert dt == Zulu.fromdatetime(zoned)
Пример #37
0
def test_zulu_datetuple():
    dt = Zulu(2000, 1, 2, 3, 4, 5, 6, UTC)
    dtt = dt.datetuple()
    assert dtt == (2000, 1, 2)
Пример #38
0
def test_zulu_copy():
    dt = Zulu(2000, 1, 1)
    copy = dt.copy()

    assert copy is not dt
    assert copy == dt
Пример #39
0
def test_zulu_parse(obj, expected):
    assert Zulu.parse(obj) == expected
Пример #40
0
def test_zulu_as_string():
    dt = Zulu(2000, 1, 1)
    assert str(dt) == dt.isoformat()
Пример #41
0
def test_datetime_range(frame, start, end, expected):
    time_range = list(Zulu.range(frame, start, end))

    assert time_range == expected
Пример #42
0
def test_zulu_as_float():
    tm = 1498672470.4801
    dt = Zulu.fromtimestamp(tm)
    assert "{:.4f}".format(float(dt)) == "{:.4f}".format(tm)
Пример #43
0
def test_datetime_parse_format(string, kargs, expected):
    assert Zulu.parse(string, **kargs) == expected
Пример #44
0
def test_zulu_as_int():
    tm = 1498672470.4801
    dt = Zulu.fromtimestamp(tm)
    assert int(dt) == int(tm)
Пример #45
0
def test_datetime_parse_pattern_mapping(string, pattern):
    pat_dt = Zulu.parse(string, DATE_PATTERN_TO_DIRECTIVE[pattern])
    dt = Zulu.parse(string, pattern)

    assert pat_dt == dt
Пример #46
0
def test_zulu_datetuple():
    dt = Zulu(2000, 1, 2, 3, 4, 5, 6, UTC)
    dtt = dt.datetuple()
    assert dtt == (2000, 1, 2)
Пример #47
0
def test_datetime_fromdatetime(dt, expected):
    assert Zulu.fromdatetime(dt) == expected
Пример #48
0
def test_datetime_combine(date, time, expected):
    dt = Zulu.combine(date, time)
    assert dt == expected
Пример #49
0
def test_datetime_fromordinal():
    assert Zulu.fromordinal(730120) == Zulu(2000, 1, 1)
Пример #50
0
def test_datetime_as_string():
    dt = Zulu(2000, 1, 1)
    assert str(dt) == dt.isoformat()
Пример #51
0
def test_zulu_string_format():
    dt = Zulu(2000, 1, 1)
    assert "{0}".format(dt) == dt.isoformat()
    assert "{0:%Y-%m-%dT%H:%M:%S}".format(dt) == dt.format("%Y-%m-%dT%H:%M:%S")
Пример #52
0
def test_zulu_span_range(frame, start, end, expected):
    span_range = []
    for time_span in Zulu.span_range(frame, start, end):
        span_range.append(time_span)

    assert span_range == expected
Пример #53
0
def test_datetime_copy():
    dt = Zulu(2000, 1, 1)
    copy = dt.copy()

    assert copy is not dt
    assert copy == dt
Пример #54
0
def test_zulu_addition_invalid_type():
    with pytest.raises(TypeError):
        Zulu() + "string"
Пример #55
0
def test_datetime_string_format():
    dt = Zulu(2000, 1, 1)
    assert '{0}'.format(dt) == dt.isoformat()
    assert '{0:%Y-%m-%dT%H:%M:%S}'.format(dt) == dt.format('%Y-%m-%dT%H:%M:%S')
Пример #56
0
def test_zulu_time_from_now():
    assert Zulu.now().shift(minutes=1).time_from_now() == "in 1 minute"
    assert Zulu.now().shift(minutes=-1).time_from_now() == "1 minute ago"
Пример #57
0
def test_datetime_time_from_now():
    assert Zulu.now().shift(minutes=1).time_from_now() == 'in 1 minute'
    assert Zulu.now().shift(minutes=-1).time_from_now() == '1 minute ago'
Пример #58
0
def test_zulu_hash():
    dt = Zulu(2000, 1, 1)
    assert hash(dt) == hash(datetime(2000, 1, 1, tzinfo=UTC))
Пример #59
0
def test_zulu_span_range_error(frame, start, end):
    with pytest.raises(ParseError):
        list(Zulu.span_range(frame, start, end))
Пример #60
0
            print(foodobject.score[0])
            c.choosing_criteria(foodobject, food)

    def get_substitued_aliments(self):
        """Print all substituted aliments"""
        substitutelst = S.get_substitued()
        newsubstitutelst = []
        for x in substitutelst:
            newsubstitutelst.append(list(x))
        i = 0
        while i < len(newsubstitutelst):
            print("Vous avez remplacé {0} par {1} \nUrl du produit original : "
                  "{2}\nUrl du nouveau produit : {3}".format(
                newsubstitutelst[i][0],
                newsubstitutelst[i][2],
                c.get_url_cleaned(newsubstitutelst[i][1]),
                c.get_url_cleaned(newsubstitutelst[i][3])
            )
            )
            i += 1

    def get_url_cleaned(self, url):
        producturl = url.replace("api/v0/", "")
        return producturl


c = Criteria()
z = Zulu()
S = Sqlfunc()
su = Submenu()