def test__retrieve_paged_ids_query_no_result():
    db = create_mockdb()

    response = Mock()
    response.buffer = StringIO("""<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
  <head>
    <variable name="entity_uri"/>
    <variable name="source_id_type"/>
    <variable name="source_id"/>
    <variable name="last_modified"/>
  </head>
  <results>
  </results>
</sparql>
""")

    db.query.return_value = make_future(response)

    result = yield asset.retrieve_paged_assets(
        db,
        datetime(2016, 1, 1, 0, 0, 0),
        datetime(2016, 1, 2, 0, 0, 0),
        10,
        2000)

    assert result[0] == []
def test__retrieve_paged_ids_query_contains_no_offset():
    db = create_mockdb()

    response = Mock()
    response.buffer = StringIO("""<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#"><results></results>
</sparql>""")
    db.query.return_value = make_future(response)

    yield asset.retrieve_paged_assets(
        db,
        datetime(2016, 1, 1, 0, 0, 0),
        datetime(2016, 1, 2, 0, 0, 0),
        page=1,
        page_size=1000)
    assert db.query.call_args[0][0].find('OFFSET 0') >= 0