Beispiel #1
0
def _marshall_group_response(group: DbFeedGroupMetadata):
    if not group:
        raise ValueError(group)

    g = FeedGroupMetadata()
    g.name = group.name
    g.last_sync = group.last_sync.isoformat() if group.last_sync else None
    g.created_at = group.created_at.isoformat() if group.created_at else None
    g.updated_at = group.last_update.isoformat() if group.last_update else None
    g.enabled = group.enabled
    g.record_count = group.count
    return g.to_json()
def test_groups():
    d1 = datetime.datetime.utcnow()
    d2 = datetime.datetime.utcnow() - datetime.timedelta(days=1)
    g = FeedGroupMetadata()
    g.name = 'group'
    g.enabled = True
    g.created_at = d2
    g.updated_at = d1
    g.last_sync = d1
    g.record_count = 0
    assert g.to_json() == {
        'name': 'group',
        'enabled': True,
        'created_at': d2.isoformat(timespec='microseconds') + UTC_OFFSET,
        'updated_at': d1.isoformat(timespec='microseconds') + UTC_OFFSET,
        'last_sync': d1.isoformat(timespec='microseconds') + UTC_OFFSET,
        'record_count': 0,
    }
Beispiel #3
0
def test_groups():
    d1 = datetime.datetime.utcnow()
    d2 = datetime.datetime.utcnow() - datetime.timedelta(days=1)
    g = FeedGroupMetadata()
    g.name = "group"
    g.enabled = True
    g.created_at = d2
    g.updated_at = d1
    g.last_sync = d1
    g.record_count = 0
    assert g.to_json() == {
        "name": "group",
        "enabled": True,
        "created_at": datetime_to_rfc3339(d2),
        "updated_at": datetime_to_rfc3339(d1),
        "last_sync": datetime_to_rfc3339(d1),
        "record_count": 0,
    }
Beispiel #4
0
def test_groups():
    d1 = datetime.datetime.utcnow()
    d2 = datetime.datetime.utcnow() - datetime.timedelta(days=1)
    g = FeedGroupMetadata()
    g.name = "group"
    g.enabled = True
    g.created_at = d2
    g.updated_at = d1
    g.last_sync = d1
    g.record_count = 0
    assert g.to_json() == {
        "name": "group",
        "enabled": True,
        "created_at": d2.isoformat(timespec="microseconds") + UTC_OFFSET,
        "updated_at": d1.isoformat(timespec="microseconds") + UTC_OFFSET,
        "last_sync": d1.isoformat(timespec="microseconds") + UTC_OFFSET,
        "record_count": 0,
    }