def test_harvest_raises(harvester): harvester.harvest.side_effect = KeyError("testing") with pytest.raises(KeyError) as e: tasks.harvest("test", "TIME") assert e.value.message == "testing"
def test_harvest_raises(harvester): harvester.harvest.side_effect = KeyError('testing') with pytest.raises(KeyError) as e: tasks.harvest('test', 'TIME') assert e.value.message == 'testing'
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'
def test_harvest_days_back(harvester): _, timestamps = tasks.harvest('test', 'TIME', days_back=10) keys = ['harvestFinished', 'harvestTaskCreated', 'harvestStarted'] for key in keys: assert key in timestamps.keys() assert harvester.harvest.called harvester.harvest.assert_called_once_with(days_back=10)
def test_harvest_days_back(harvester): start_date = date(2015, 03, 14) end_date = date(2015, 03, 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)
def test_harvest_days_back(harvester): start_date = date(2015, 03, 14) end_date = date(2015, 03, 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)
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)
def test_harvest_runs_harvest(harvester): tasks.harvest('test', 'TIME') assert harvester.harvest.called
def test_harvest_runs_harvest(harvester): tasks.harvest("test", "TIME") assert harvester.harvest.called