示例#1
0
def _marshall_group_response(group: DbFeedGroupMetadata) -> FeedGroupMetadata:
    if not group:
        raise ValueError(group)

    g = FeedGroupMetadata()
    g.name = group.name
    g.last_sync = group.last_sync
    g.created_at = group.created_at
    g.updated_at = group.last_update
    g.enabled = group.enabled
    g.record_count = group.count
    return g
示例#2
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,
    }
示例#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": datetime_to_rfc3339(d2),
        "updated_at": datetime_to_rfc3339(d1),
        "last_sync": datetime_to_rfc3339(d1),
        "record_count": 0,
    }
示例#5
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,
    }
def test_feeds():
    f = FeedMetadata()
    f.name = 'feed1'
    d1 = datetime.datetime.utcnow()
    f.updated_at = d1
    assert f.to_json() == {
        'name': 'feed1',
        'updated_at': d1.isoformat(timespec='microseconds') + UTC_OFFSET,
        'groups': None,
        'enabled': None,
        'last_full_sync': None
    }

    f.groups = []
    g = FeedGroupMetadata()
    g.name = 'group1'
    g.record_count = 10
    g.enabled = True
    f.groups.append(g)

    assert f.to_json() == {
        'name':
        'feed1',
        'updated_at':
        d1.isoformat(timespec='microseconds') + UTC_OFFSET,
        'enabled':
        None,
        'last_full_sync':
        None,
        'groups': [{
            'name': 'group1',
            'enabled': True,
            'record_count': 10,
            'created_at': None,
            'updated_at': None,
            'last_sync': None
        }]
    }
示例#7
0
def test_feeds():
    f = FeedMetadata()
    f.name = "feed1"
    d1 = datetime.datetime.utcnow()
    f.updated_at = d1
    assert f.to_json() == {
        "name": "feed1",
        "updated_at": datetime_to_rfc3339(d1),
        "groups": None,
        "enabled": None,
        "last_full_sync": None,
    }

    f.groups = []
    g = FeedGroupMetadata()
    g.name = "group1"
    g.record_count = 10
    g.enabled = True
    f.groups.append(g)

    assert f.to_json() == {
        "name":
        "feed1",
        "updated_at":
        datetime_to_rfc3339(d1),
        "enabled":
        None,
        "last_full_sync":
        None,
        "groups": [{
            "name": "group1",
            "enabled": True,
            "record_count": 10,
            "created_at": None,
            "updated_at": None,
            "last_sync": None,
        }],
    }
示例#8
0
def test_feeds():
    f = FeedMetadata()
    f.name = "feed1"
    d1 = datetime.datetime.utcnow()
    f.updated_at = d1
    assert f.to_json() == {
        "name": "feed1",
        "updated_at": d1.isoformat(timespec="microseconds") + UTC_OFFSET,
        "groups": None,
        "enabled": None,
        "last_full_sync": None,
    }

    f.groups = []
    g = FeedGroupMetadata()
    g.name = "group1"
    g.record_count = 10
    g.enabled = True
    f.groups.append(g)

    assert f.to_json() == {
        "name":
        "feed1",
        "updated_at":
        d1.isoformat(timespec="microseconds") + UTC_OFFSET,
        "enabled":
        None,
        "last_full_sync":
        None,
        "groups": [{
            "name": "group1",
            "enabled": True,
            "record_count": 10,
            "created_at": None,
            "updated_at": None,
            "last_sync": None,
        }],
    }