예제 #1
0
    def test_to_record(self):
        """Test that an entity can be converted into a record."""
        entity = PipelineMapper.to_entity(self.pipeline)
        record = PipelineMapper.to_record(entity)

        for c in record.__table__.columns:
            self.assertEquals(
                getattr(record, c.name),
                getattr(self.pipeline, c.name),
            )
예제 #2
0
    def test_write_record_new(self):
        """Test that we can create a new record."""
        entity = PipelineEntity.get_mock_object()

        PipelineRepository.write_record(PipelineMapper.to_record(entity))

        pipeline = PipelineRepository.fetch_pipeline_by_id(entity.id)
        self.assertEquals(pipeline.name, entity.name)
예제 #3
0
파일: pipeline.py 프로젝트: minglecm/ocelot
    def fetch_pipeline_by_id(cls, id):
        """Returns PipelineEntity by id.

        :param str id:
        :returns PipelineEntity:
        """
        return PipelineMapper.to_entity(
            PipelineRepository.fetch_pipeline_by_id(id),
        )
예제 #4
0
 def test_to_entity(self):
     """Test that a record can be converted into an entity."""
     self.assertEquals(
         PipelineMapper.to_entity(self.pipeline).to_native(),
         {
             'id': self.pipeline.id,
             'name': self.pipeline.name,
         }
     )
예제 #5
0
파일: pipeline.py 프로젝트: minglecm/ocelot
    def write_pipeline(cls, pipeline_entity):
        """Writes a PipelineEntity to the database.

        :param PipelineEntity pipeline_entity:
        """
        pipeline_entity.validate()

        PipelineRepository.write_record(
            PipelineMapper.to_record(pipeline_entity)
        )
예제 #6
0
    def test_write_record_new(self):
        """Test that we can create a new record."""
        entity = PipelineEntity.get_mock_object()

        PipelineRepository.write_record(
            PipelineMapper.to_record(entity)
        )

        pipeline = PipelineRepository.fetch_pipeline_by_id(entity.id)
        self.assertEquals(pipeline.name, entity.name)