示例#1
0
    def test_sample_model_with_plans(self):
        self.assertIsInstance(self.test_model, Manifest)

        model_sql = ManifestAdapter.find_by_id_name(self.test_model.id)
        self.assertIsInstance(model_sql, ManifestSQL)

        ''' query associated service '''
        service = model_sql.service
        self.assertIsInstance(service, ServiceTypeSQL)

        ''' verify relations '''
        plans = service.plans
        plan = model_sql.plan
        self.assertTrue(plan in plans)

        ''' manifest also deleted '''
        PlanAdapter.delete(plan.id_name)
        self.assertFalse(ManifestAdapter.exists_in_db(model_sql.id_name))

        ''' service updated (has to be re-query-ed) '''
        ''' this is not correct! >> service = model_sql.service '''
        service = ServiceTypeAdapter.find_by_id_name(service.id_name)
        plans = service.plans
        ''' verify plans reduced '''
        self.assertEqual(len(plans), 1)
        ''' verify service has no manifest now '''
        self.assertTrue(service.manifests.is_empty())
示例#2
0
 def test_adapter_delete(self):
     with self.assertRaises(Exception):
         PlanAdapter.delete(id_name='')
示例#3
0
 def tearDown(self):
     if PlanAdapter.exists_in_db(self.test_model.id):
         PlanAdapter.delete(self.test_model.id)