Esempio n. 1
0
 def resolve_histories(parent: 'ReadHaystack',
                       info: ResolveInfo,
                       ids: Optional[List[str]] = None,
                       dates_range: Optional[str] = None,
                       version: Union[str, datetime, date, None] = None):
     if version:
         version = HSDateTime.parse_value(version)
     log.debug(
         "resolve_histories(parent,info,ids=%s, range=%s, version=%s)", ids,
         dates_range, version)
     envs = cast(Dict[str, str], os.environ)
     provider = get_singleton_provider(envs)
     grid_date_range = parse_date_range(dates_range, provider.get_tz())
     return [
         ReadHaystack._conv_history(
             provider.his_read(Ref(ReadHaystack._filter_id(entity_id)),
                               grid_date_range, version), info)
         for entity_id in ids
     ]
Esempio n. 2
0
def test_date_range_datetime():
    date_min, date_max = parse_date_range("2020-12-24T00:00:00+00:00",
                                          _TZ_PARIS)
    assert date_min == datetime(2020, 12, 24, tzinfo=pytz.UTC)
    assert date_max == _DATETIME_MAX_TZ
Esempio n. 3
0
def test_date_range_empty():
    date_min, date_max = parse_date_range("", _TZ_PARIS)
    assert date_min == datetime.min.replace(tzinfo=pytz.UTC)
    assert date_max == datetime.max.replace(tzinfo=pytz.UTC)
Esempio n. 4
0
def test_date_range_date_date():
    date_min, date_max = parse_date_range("2020-12-24,2020-12-25", _TZ_PARIS)
    assert date_min == datetime(2020, 12, 24, tzinfo=_TZ_PARIS)
    assert date_max == datetime.combine(datetime(
        2020, 12, 25), datetime.max.time()).replace(tzinfo=_TZ_PARIS)
Esempio n. 5
0
def test_date_range_comma_date():
    date_min, date_max = parse_date_range(",2100-12-24", _TZ_PARIS)
    assert date_min == _DATETIME_MIN_TZ
    assert date_max == datetime.combine(datetime(
        2100, 12, 24), datetime.max.time()).replace(tzinfo=_TZ_PARIS)
Esempio n. 6
0
def test_date_range_date_comma():
    date_min, date_max = parse_date_range("2020-12-24,", _TZ_PARIS)
    assert date_min == datetime(2020, 12, 24, tzinfo=_TZ_PARIS)
    assert date_max == _DATETIME_MAX_TZ
Esempio n. 7
0
def test_date_range_date():
    date_min, date_max = parse_date_range("2020-12-24", _TZ_PARIS)
    assert date_min == datetime(2020, 12, 24, tzinfo=_TZ_PARIS)
    assert date_max == datetime(2020, 12, 25, tzinfo=_TZ_PARIS)
Esempio n. 8
0
def test_date_range_yesterday_today():
    date_min, date_max = parse_date_range("yesterday,today", _TZ_PARIS)
    assert date_min == datetime.combine(date.today() - timedelta(days=1), datetime.min.time()) \
        .replace(tzinfo=_TZ_PARIS)
    assert date_max == datetime.combine(date.today(), datetime.min.time()) \
        .replace(tzinfo=_TZ_PARIS) + timedelta(days=1)
Esempio n. 9
0
def test_date_range_date_yesterday():
    date_min, date_max = parse_date_range("2021-01-01,yesterday", _TZ_PARIS)
    assert date_min == datetime.combine(date(
        2021, 1, 1), datetime.min.time()).replace(tzinfo=_TZ_PARIS)
    assert date_max == datetime.combine(
        date.today(), datetime.min.time()).replace(tzinfo=_TZ_PARIS)
Esempio n. 10
0
def test_date_range_today_date():
    date_min, date_max = parse_date_range("today,2100-01-01", _TZ_PARIS)
    assert date_min == datetime.combine(date.today(), datetime.min.time()) \
        .replace(tzinfo=_TZ_PARIS)
    assert date_max == datetime.combine(datetime(
        2100, 1, 1), datetime.min.time()).replace(tzinfo=_TZ_PARIS)
Esempio n. 11
0
def test_date_range_date_limit():
    date_min, date_max = parse_date_range("0001-01-01,9999-12-31", _TZ_PARIS)
    assert date_min == _DATETIME_MIN_TZ
    assert date_max == _DATETIME_MAX_TZ
Esempio n. 12
0
def test_date_range_comma_datetime():
    date_min, date_max = parse_date_range(",2100-12-24T00:00:00+00:00",
                                          _TZ_PARIS)
    assert date_min == _DATETIME_MIN_TZ
    assert date_max == datetime(2100, 12, 24, tzinfo=pytz.UTC)