def add_manifest(manifest) -> tuple: if ManifestAdapter.exists_in_db(manifest.id): return 'The Manifest already exists in the catalog.', 409 ''' Attempt to Create Table ''' PlanAdapter.create_table() ServiceTypeAdapter.create_table() if ServiceTypeAdapter.exists_in_db( manifest.service_id) and PlanAdapter.exists_in_db( manifest.plan_id): ManifestAdapter.save(manifest) else: return 'Could not save the Manifest in the DB, Plan and Service don\'t exist', 500 if ManifestAdapter.exists_in_db(manifest.id): return 'Manifest added successfully', 200 else: return 'Could not save the Manifest in the DB', 500
def test_adapter_save_to_update(self): self.test_model.name = 'new-name' model_sql = PlanAdapter.save(self.test_model) exists = PlanAdapter.exists_in_db(model_sql.id_name) self.assertTrue(exists)
def tearDown(self): if PlanAdapter.exists_in_db(self.test_model.id): PlanAdapter.delete(self.test_model.id)