Пример #1
0
    def test_seq4_delete(self):
        step = "------ step 1: create tan ------"
        self.info(step)

        count_implem_init = ImplementationDao.objects.count()
        count_profile_item_init = ProfileItemDao.objects.count()

        self.info("Before created: ImplementationDao count = %s" %
                  count_implem_init)
        self.info("Before created: ProfileItemDao count = %s" %
                  count_profile_item_init)

        created_tan = ImplementationDao.create(
            TestImplementationDaoCRUD.my_tan)

        self.info("  - Original tan oper: %s" %
                  str(TestImplementationDaoCRUD.my_tan))
        self.info("  - Created tan oper: %s" % str(created_tan))

        step = "------ step 2: simple case of delete ------"
        self.info(step)

        ImplementationDao.delete_resource(created_tan)

        count_implem_post = ImplementationDao.objects.count()
        count_profile_item_post = ProfileItemDao.objects.count()

        self.info("Once deleted: ImplementationDao count = %s" %
                  count_implem_post)
        self.info("Once deleted: ProfileItemDao count = %s" %
                  count_profile_item_post)

        self.assertEqual(count_implem_init, count_implem_post)
        self.assertEqual(count_profile_item_init, count_profile_item_post)
Пример #2
0
    def test_seq6_delete(self):
        fam_count_before = FunctionalFamilyDao.objects.count()
        algo_count_before = AlgorithmDao.objects.count()
        impl_count_before = ImplementationDao.objects.count()
        prof_count_before = ProfileItemDao.objects.count()

        self.info("Pre-condition: FunctionalFamilyDao count = %s" %
                  fam_count_before)
        self.info("Pre-condition: AlgorithmDao count = %s" % algo_count_before)
        self.info("Pre-condition: ImplementationDao count = %s" %
                  impl_count_before)
        self.info("Pre-condition: ProfileItemDao count = %s" %
                  prof_count_before)

        step = "------ step 1: create tan Tri ------"
        self.info(step)

        family = FunctionalFamilyDao.create(
            FunctionalFamily(name="TU family",
                             description="TU family for tan Tri"))
        algo = AlgorithmDao.create(
            Algorithm(name="TU algo",
                      description="desc TU algo",
                      label="label",
                      family=family))

        self.info("  - family: %s" % str(family))
        self.info("  - algo: %s" % str(algo))

        fam_count_step1 = FunctionalFamilyDao.objects.count()
        algo_count_step1 = AlgorithmDao.objects.count()
        self.info("Parent family created: FunctionalFamilyDao count = %s" %
                  fam_count_step1)
        self.info("Parent algo created: AlgorithmDao count = %s" %
                  algo_count_step1)

        tan_tri = Implementation(
            "TU ORM Python Standard tan TRI", "Python tan TRI from math::tan",
            "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
            "math::tan", [TestImplementationDaoCRUD.arg_one],
            [TestImplementationDaoCRUD.res_three])

        tan_tri.algo = algo

        created_tan = ImplementationDao.create(tan_tri)

        impl_count_step1 = ImplementationDao.objects.count()
        prof_count_step1 = ProfileItemDao.objects.count()

        self.info("Once tan Tri created: ImplementationDao count = %s" %
                  impl_count_step1)
        self.info("Once tan Tri created: ProfileItemDao count = %s" %
                  prof_count_step1)

        self.info("  - Original tan Tri oper: %s" % str(tan_tri))
        self.info("  - Created tan Tri oper: %s" % str(created_tan))

        step = "------ step 2:  delete oper tan Tri with parent algo ------"
        self.info(step)

        ImplementationDao.delete_resource(created_tan)

        fam_count_step2 = FunctionalFamilyDao.objects.count()
        algo_count_step2 = AlgorithmDao.objects.count()
        impl_count_step2 = ImplementationDao.objects.count()
        prof_count_step2 = ProfileItemDao.objects.count()

        self.info(
            "Step2: once tan Tri deleted: FunctionalFamilyDao count = %s" %
            fam_count_step2)
        self.info("Step2: once tan Tri deleted: AlgorithmDao count = %s" %
                  algo_count_step2)
        self.info("Step2: once tan Tri deleted: ImplementationDao count = %s" %
                  impl_count_step2)
        self.info("Step2: once tan Tri deleted: ProfileItemDao count = %s" %
                  prof_count_step2)

        self.assertEqual(
            fam_count_step2, fam_count_step1,
            "After  delete: family count unchanged: fam_count_step2 == fam_count_step1"
        )
        self.assertEqual(
            algo_count_step2, algo_count_step1,
            "After delete: algo count unchanged: algo_count_step2 == algo_count_step1"
        )
        self.assertEqual(
            impl_count_step2, impl_count_before,
            "After  delete: impl_count_step2 == impl_count_before")
        self.assertEqual(
            prof_count_step2, prof_count_before,
            "After second delete: prof_count_step2 == prof_count_before")

        self.assertTrue(impl_count_step2 < impl_count_step1)
        self.assertTrue(prof_count_step2 < prof_count_step1)
Пример #3
0
    def test_seq5_delete(self):
        impl_count_before = ImplementationDao.objects.count()
        prof_count_before = ProfileItemDao.objects.count()

        self.info("Pre-condition: ImplementationDao count = %s" %
                  impl_count_before)
        self.info("Pre-condition: ProfileItemDao count = %s" %
                  prof_count_before)

        step = "------ step 1: create tan + tan Bis ------"
        self.info(step)

        created_tan = ImplementationDao.create(
            TestImplementationDaoCRUD.my_tan)

        impl_count_step1_1 = ImplementationDao.objects.count()
        prof_count_step1_1 = ProfileItemDao.objects.count()

        self.info("Once tan created: ImplementationDao count = %s" %
                  impl_count_step1_1)
        self.info("Once tan created: ProfileItemDao count = %s" %
                  prof_count_step1_1)
        self.info("  created input: " + str(created_tan.input_profile[0]))
        self.info(" created output: " + str(created_tan.output_profile[0]))

        tan_bis = Implementation(
            "TU ORM Python Standard tan BIS", "Python tan BIS from math::tan",
            "apps.algo.execute.models.business.python_local_exec_engine::PythonLocalExecEngine",
            "math::tan", [created_tan.input_profile[0]],
            [created_tan.output_profile[0]])

        created_tan_bis = ImplementationDao.create(tan_bis)

        impl_count_step1_2 = ImplementationDao.objects.count()
        prof_count_step1_2 = ProfileItemDao.objects.count()

        self.info("Once tan Bis created: ImplementationDao count = %s" %
                  impl_count_step1_2)
        self.info("Once tan Bis created: ProfileItemDao count = %s" %
                  prof_count_step1_2)

        self.info("  - Original tan oper: %s" %
                  str(TestImplementationDaoCRUD.my_tan))
        self.info("  - Created tan oper: %s" % str(created_tan))
        self.info("  - Created tan BIS oper: %s" % str(created_tan_bis))

        step = "------ step 2:  delete oper tan with shared Profile_Items ------"
        self.info(step)

        ImplementationDao.delete_resource(created_tan)

        impl_count_step2 = ImplementationDao.objects.count()
        prof_count_step2 = ProfileItemDao.objects.count()

        self.info("Once tan deleted: ImplementationDao count = %s" %
                  impl_count_step2)
        self.info("Once tan deleted: ProfileItemDao count = %s" %
                  prof_count_step2)

        self.assertEqual(
            impl_count_step1_2, impl_count_step2 + 1,
            "After first delete: impl_count_step2 == impl_count_step2 +1")
        self.assertEqual(
            prof_count_step1_2, prof_count_step2,
            "After first delete: no orphan profile_item: prof_count_step1_2 == prof_count_step2"
        )

        step = "------ step 3:  delete oper tan BIS with no more shared Profile_Items ------"
        self.info(step)

        ImplementationDao.delete_resource(created_tan_bis)

        impl_count_step3 = ImplementationDao.objects.count()
        prof_count_step3 = ProfileItemDao.objects.count()

        self.info("Once tan Bis deleted: ImplementationDao count = %s" %
                  impl_count_step3)
        self.info("Once tan Bis deleted: ProfileItemDao count = %s" %
                  prof_count_step3)

        self.assertEqual(
            impl_count_step3, impl_count_before,
            "After second delete: impl_count_step3 == impl_count_before")
        self.assertEqual(
            prof_count_step3, prof_count_before,
            "After second delete: prof_count_step3 == prof_count_before")