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

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

    assert time_range == expected
Ejemplo n.º 18
0
def test_zulu_copy():
    dt = Zulu(2000, 1, 1)
    copy = dt.copy()

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

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

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

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