def test_get_technology_by_id(session): """Verify that the get_technology_by_id() returns description provided the id is given.""" techs = [ Technologies(id=123123, description='123 Tech'), Technologies(id=567123, description='567 Tech'), Technologies(id=890123, description='890 Tech') ] session.bulk_save_objects(techs) session.commit() assert Technologies.get_technology_by_id(123123) == '123 Tech' assert Technologies.get_technology_by_id(567123) == '567 Tech' assert Technologies.get_technology_by_id(890123) == '890 Tech' assert Technologies.get_technology_by_id(283802818388) is None
def serialize_data(self, data): """Serializes/transforms data before dumping.""" technologies_list = [] if data.device_technologies: technologies = DeviceTechnology.get_device_technologies(data.id) for tech in technologies: tech_type = Technologies.get_technology_by_id(tech.technology_id) technologies_list.append(tech_type) data.technologies = technologies_list if data.device_types_id: device_type = DeviceType.get_device_type_by_id(data.device_types_id) data.device_type = device_type