scrapi.tasks.harvest

Here are the examples of the python api scrapi.tasks.harvest taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

Example 1

Project: scrapi
Source File: test_tasks.py
View license
@pytest.mark.usefixtures('harvester')
def test_harvest_days_back(harvester):
    start_date = date(2015, 3, 14)
    end_date = date(2015, 3, 16)

    _, timestamps = tasks.harvest('test', 'TIME', start_date=start_date, end_date=end_date)

    keys = ['harvestFinished', 'harvestTaskCreated', 'harvestStarted']

    for key in keys:
        assert key in timestamps.keys()

    assert harvester.harvest.called
    harvester.harvest.assert_called_once_with(start_date=start_date, end_date=end_date)

Example 2

Project: scrapi
Source File: test_tasks.py
View license
@pytest.mark.usefixtures('harvester')
def test_harvest_raises(harvester):
    harvester.harvest.side_effect = KeyError('testing')

    with pytest.raises(KeyError) as e:
        tasks.harvest('test', 'TIME')

    # no .message in Python3
    assert e.value.args[0] == 'testing'

Example 3

Project: scrapi
Source File: test_tasks.py
View license
@pytest.mark.usefixtures('harvester')
def test_harvest_runs_harvest(harvester):
    tasks.harvest('test', 'TIME')

    assert harvester.harvest.called