def get_service(service_id: str = None) -> List[ServiceType]: if service_id: if ServiceTypeAdapter.exists_in_db(service_id): model_sql = ServiceTypeAdapter.find_by_id_name(service_id) model = ServiceTypeAdapter.model_sql_to_model(model_sql) return [model] else: return [] else: return ServiceTypeAdapter.get_all()
def test_sample_model_with_plans(self): self.assertIsInstance(self.test_model, ServiceType) model_sql = ServiceTypeAdapter.find_by_id_name(self.test_model.id) self.assertIsInstance(model_sql, ServiceTypeSQL) self.assertFalse(model_sql.plans.is_empty()) plans = PlanAdapter.plans_from_service_sql(model_sql) self.assertGreater(len(plans), 1) model = ServiceTypeAdapter.model_sql_to_model(model_sql) self.assertGreater(len(model.plans), 1)