コード例 #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
ファイル: test_zulu.py プロジェクト: dgilland/zulu
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
ファイル: test_zulu.py プロジェクト: dgilland/zulu
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
ファイル: test_zulu.py プロジェクト: dgilland/zulu
def test_zulu_copy():
    dt = Zulu(2000, 1, 1)
    copy = dt.copy()

    assert copy is not dt
    assert copy == dt
コード例 #19
0
ファイル: test_zulu.py プロジェクト: dgilland/zulu
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
ファイル: test_zulu.py プロジェクト: dgilland/zulu
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
ファイル: test_zulu.py プロジェクト: dgilland/zulu
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
ファイル: test_zulu.py プロジェクト: dgilland/zulu
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
ファイル: test_zulu.py プロジェクト: dgilland/zulu
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
ファイル: test_zulu.py プロジェクト: dgilland/zulu
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
ファイル: test_zulu.py プロジェクト: dgilland/zulu
def test_zulu_span_range_error(frame, start, end):
    with pytest.raises(ParseError):
        list(Zulu.span_range(frame, start, end))
コード例 #60
0
ファイル: criteria.py プロジェクト: Jackatoa/Projet---5
            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()