Example #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)
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)
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
Example #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
Example #5
0
def test_zulu_fromordinal():
    assert Zulu.fromordinal(730120) == Zulu(2000, 1, 1)
Example #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),
def test_datetime_parse(string, expected):
    assert Zulu.parse(string) == expected
def test_datetime_fromlocaltime():
    now = localtime()
    assert Zulu.fromlocaltime(now).timestamp() == mktime(now)
def test_datetime_strptime(string, fmt, expected):
    assert Zulu.strptime(string, fmt) == expected
Example #10
0
def test_datetime_range_error(frame, start, end):
    with pytest.raises(ParseError):
        list(Zulu.range(frame, start, end))
Example #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'
Example #12
0
def test_zulu_defaults():
    assert Zulu() == Zulu.fromtimestamp(0)
    assert create() == Zulu()
Example #13
0
def test_zulu_parse_invalid(string, kargs, exception):
    with pytest.raises(exception):
        Zulu.parse(string, **kargs)
Example #14
0
def test_zulu_pickle():
    dt = Zulu()
    unpickled = pickle.loads(pickle.dumps(dt))

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

    assert time_range == expected
Example #18
0
def test_zulu_copy():
    dt = Zulu(2000, 1, 1)
    copy = dt.copy()

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

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

    assert time_range == expected
Example #42
0
def test_zulu_as_float():
    tm = 1498672470.4801
    dt = Zulu.fromtimestamp(tm)
    assert "{:.4f}".format(float(dt)) == "{:.4f}".format(tm)
Example #43
0
def test_datetime_parse_format(string, kargs, expected):
    assert Zulu.parse(string, **kargs) == expected
Example #44
0
def test_zulu_as_int():
    tm = 1498672470.4801
    dt = Zulu.fromtimestamp(tm)
    assert int(dt) == int(tm)
Example #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
Example #46
0
def test_zulu_datetuple():
    dt = Zulu(2000, 1, 2, 3, 4, 5, 6, UTC)
    dtt = dt.datetuple()
    assert dtt == (2000, 1, 2)
Example #47
0
def test_datetime_fromdatetime(dt, expected):
    assert Zulu.fromdatetime(dt) == expected
Example #48
0
def test_datetime_combine(date, time, expected):
    dt = Zulu.combine(date, time)
    assert dt == expected
Example #49
0
def test_datetime_fromordinal():
    assert Zulu.fromordinal(730120) == Zulu(2000, 1, 1)
Example #50
0
def test_datetime_as_string():
    dt = Zulu(2000, 1, 1)
    assert str(dt) == dt.isoformat()
Example #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")
Example #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
Example #53
0
def test_datetime_copy():
    dt = Zulu(2000, 1, 1)
    copy = dt.copy()

    assert copy is not dt
    assert copy == dt
Example #54
0
def test_zulu_addition_invalid_type():
    with pytest.raises(TypeError):
        Zulu() + "string"
Example #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')
Example #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"
Example #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'
Example #58
0
def test_zulu_hash():
    dt = Zulu(2000, 1, 1)
    assert hash(dt) == hash(datetime(2000, 1, 1, tzinfo=UTC))
Example #59
0
def test_zulu_span_range_error(frame, start, end):
    with pytest.raises(ParseError):
        list(Zulu.span_range(frame, start, end))
Example #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()