def _write_entity(cls, entity): """Writes an entity to the repository. :param PipelineScheduleEntity entity: """ PipelineScheduleRepository.write_record( PipelineScheduleMapper.to_record(entity), )
def _write_entity(cls, entity): """Writes an entity to the repository. :param PipelineScheduleEntity entity: """ PipelineScheduleRepository.write_record( PipelineScheduleMapper.to_record(entity), )
def test_write_record(self): """Test that we can write a record to the database.""" self.install_fixture("pipeline_schedule_interval") self.assertNotEquals(PipelineScheduleRepository.fetch_schedule_for_pipeline(self.pipeline.id).schedule, "150") record = self.pipeline_schedule_interval record.schedule = "150" PipelineScheduleRepository.write_record(record) self.assertEquals(PipelineScheduleRepository.fetch_schedule_for_pipeline(self.pipeline.id).schedule, "150")
def test_fetch_schedule_for_pipeline(self): """Test that a schedule can be fetched for a pipeline.""" self.install_fixture("pipeline_schedule_interval") self.assertEqual( PipelineScheduleRepository.fetch_schedule_for_pipeline(self.pipeline.id), self.pipeline_schedule_interval )
def test_fetch_schedules_later(self): """Test that schedules that do not need to run (next_run_at > now) are not returned.""" self.install_fixture( "pipeline_schedule_interval", overrides={"next_run_at": datetime.utcnow() + timedelta(hours=6)} ) self.assertEqual(PipelineScheduleRepository.fetch_schedules_to_run(), [])
def test_write_record(self): """Test that we can write a record to the database.""" self.install_fixture('pipeline_schedule_interval') self.assertNotEquals( PipelineScheduleRepository.fetch_schedule_for_pipeline(self.pipeline.id).schedule, '150', ) record = self.pipeline_schedule_interval record.schedule = '150' PipelineScheduleRepository.write_record(record) self.assertEquals( PipelineScheduleRepository.fetch_schedule_for_pipeline(self.pipeline.id).schedule, '150', )
def test_fetch_schedule_for_pipeline(self): """Test that a schedule can be fetched for a pipeline.""" self.install_fixture('pipeline_schedule_interval') self.assertEqual( PipelineScheduleRepository.fetch_schedule_for_pipeline(self.pipeline.id), self.pipeline_schedule_interval, )
def test_fetch_schedules_manual(self): """Test that manual schedules that do not need to run (next_run_at == null) are not returned.""" self.install_fixture('pipeline_schedule_manual') self.assertEqual( PipelineScheduleRepository.fetch_schedules_to_run(), [], )
def fetch_schedules_to_run(cls): """Return a list of PipelineScheduleEntities that need to run. :returns list: PipelineScheduleEntity """ return map( PipelineScheduleMapper.to_entity, PipelineScheduleRepository.fetch_schedules_to_run(), )
def fetch_schedules_to_run(cls): """Return a list of PipelineScheduleEntities that need to run. :returns list: PipelineScheduleEntity """ return map( PipelineScheduleMapper.to_entity, PipelineScheduleRepository.fetch_schedules_to_run(), )
def fetch_schedule_for_pipeline(cls, pipeline_id): """Returns a PipelineScheduleEntity for a pipeline_id. :param str pipeline_id: :returns PipelineScheduleEntity: :raises ResourceNotFoundException: if not found """ return PipelineScheduleMapper.to_entity( PipelineScheduleRepository.fetch_schedule_for_pipeline( pipeline_id, ), )
def test_fetch_schedules_later(self): """Test that schedules that do not need to run (next_run_at > now) are not returned.""" self.install_fixture('pipeline_schedule_interval', overrides={ 'next_run_at': datetime.utcnow() + timedelta(hours=6), }) self.assertEqual( PipelineScheduleRepository.fetch_schedules_to_run(), [], )
def test_fetch_schedules_to_run_locked(self): """Test that locked schedules are not returned.""" self.install_fixture('pipeline_schedule_interval', overrides={ 'locked': True, }) self.assertEqual( PipelineScheduleRepository.fetch_schedules_to_run(), [], )
def test_fetch_schedules_to_run(self): """Test that schedules that need to run (next_run_at <= now) are returned.""" self.install_fixture('pipeline_schedule_interval') self.assertEqual( PipelineScheduleRepository.fetch_schedules_to_run(), [ self.pipeline_schedule_interval, ] )
def fetch_schedule_for_pipeline(cls, pipeline_id): """Returns a PipelineScheduleEntity for a pipeline_id. :param str pipeline_id: :returns PipelineScheduleEntity: :raises ResourceNotFoundException: if not found """ return PipelineScheduleMapper.to_entity( PipelineScheduleRepository.fetch_schedule_for_pipeline( pipeline_id, ), )
def test_fetch_schedules_manual(self): """Test that manual schedules that do not need to run (next_run_at == null) are not returned.""" self.install_fixture("pipeline_schedule_manual") self.assertEqual(PipelineScheduleRepository.fetch_schedules_to_run(), [])
def test_fetch_schedules_to_run(self): """Test that schedules that need to run (next_run_at <= now) are returned.""" self.install_fixture("pipeline_schedule_interval") self.assertEqual(PipelineScheduleRepository.fetch_schedules_to_run(), [self.pipeline_schedule_interval])
def test_fetch_schedules_to_run_locked(self): """Test that locked schedules are not returned.""" self.install_fixture("pipeline_schedule_interval", overrides={"locked": True}) self.assertEqual(PipelineScheduleRepository.fetch_schedules_to_run(), [])