コード例 #1
0
 def test_introspect(self):
     """
     Test that expected categories and groups are found in DB after introspection.
     We also check algorithms introspected during base_testcase.init_test_env
     """
     
     all_categories = dao.get_algorithm_categories()
     category_ids = [cat.id for cat in all_categories if cat.displayname == "AdaptersTest"]
     groups = dao.get_groups_by_categories(category_ids)
     self.assertEqual(12, len(groups), "Introspection failed!")
     nr_adapters_mod2 = 0
     nr_from_xml = 0
     for algorithm in groups:
         self.assertTrue(algorithm.module in ['tvb.tests.framework.adapters.testadapter1',
                                              'tvb.tests.framework.adapters.testadapter2',
                                              'tvb.tests.framework.adapters.testadapter3',
                                              'tvb.tests.framework.adapters.ndimensionarrayadapter',
                                              'tvb.tests.framework.adapters.testgroupadapter'],
                         "Unknown Adapter module:" + str(algorithm.module))
         self.assertTrue(algorithm.classname in ["TestAdapter1", "TestAdapterDatatypeInput",
                                                 "TestAdapter2", "TestAdapter22", "TestAdapterHugeMemoryRequired",
                                                 "TestAdapter3", "TestAdapterHDDRequired",
                                                 "NDimensionArrayAdapter", "TestGroupAdapter"
                                                 ],
                         "Unknown Adapter Class:" + str(algorithm.classname))
         if algorithm.module == 'tvb.tests.framework.adapters.testadapter2':
             nr_adapters_mod2 += 1
         if algorithm.module == 'tvb.tests.framework.adapters.testgroupadapter':
             nr_from_xml += 1
     self.assertEqual(nr_adapters_mod2, 2)
     self.assertEqual(nr_from_xml, 4)
コード例 #2
0
 def test_default_cancel(self):
     """
     On cancel we should get a redirect to the back page link.
     """
     cherrypy.request.method = "POST"
     categories = dao.get_algorithm_categories()
     algo_groups = dao.get_groups_by_categories([categories[0].id])
     self._expect_redirect('/project/viewoperations/%i' % self.test_project.id, self.flow_c.default,
                           categories[0].id, algo_groups[0].id, cancel=True, back_page='operations')
コード例 #3
0
 def test_default_cancel(self):
     """
     On cancel we should get a redirect to the back page link.
     """
     cherrypy.request.method = "POST"
     categories = dao.get_algorithm_categories()
     algo_groups = dao.get_groups_by_categories([categories[0].id])
     self._expect_redirect('/project/viewoperations/%i'%(self.test_project.id), 
                           self.flow_c.default, categories[0].id, algo_groups[0].id, 
                           cancel=True, back_page='operations')
コード例 #4
0
 def test_default(self):
     """
     Test default method from step controllers. Check that the submit link is ok, that a mainContent
     is present in result dict and that the isAdapter flag is set to true.
     """
     cherrypy.request.method = "GET"
     categories = dao.get_algorithm_categories()
     for categ in categories:
         algo_groups = dao.get_groups_by_categories([categ.id])
         for algo in algo_groups:
             result_dict = self.flow_c.default(categ.id, algo.id)
             self.assertEqual(result_dict[common.KEY_SUBMIT_LINK], '/flow/%i/%i' % (categ.id, algo.id))
             self.assertTrue('mainContent' in result_dict)
             self.assertTrue(result_dict['isAdapter'])
コード例 #5
0
 def test_default(self):
     """
     Test default method from step controllers. Check that the submit link is ok, that a mainContent
     is present in result dict and that the isAdapter flag is set to true.
     """
     cherrypy.request.method = "GET"
     categories = dao.get_algorithm_categories()
     for categ in categories:
         algo_groups = dao.get_groups_by_categories([categ.id])
         for algo in algo_groups:
             result_dict = self.flow_c.default(categ.id, algo.id)
             self.assertEqual(result_dict[b_c.KEY_SUBMIT_LINK], '/flow/%i/%i'%(categ.id, algo.id))
             self.assertTrue('mainContent' in result_dict)
             self.assertTrue(result_dict['isAdapter'])
コード例 #6
0
 def __update_references_last_check_timestamp(current_groups, category_key):
     """
     For all the algorithms found in the db for category given by category_key, update their
     'last_introspection_check' timestamp if they are part of current_groups.
     
     :param current_groups: a list of algorithm groups that recently passed our validations
         from the introspection and are still valid
     :param category_key: the algorithm group category for which we match the algorithms found
         in the db with those we recently validated on introspection
     """
     db_groups = dao.get_groups_by_categories([category_key])
     for group in db_groups:
         for curr_group in current_groups:
             if group.module == curr_group.module and group.classname == curr_group.classname:
                 group.last_introspection_check = datetime.datetime.now()
                 dao.store_entity(group)
                 break
コード例 #7
0
 def __update_references_last_check_timestamp(current_groups, category_key):
     """
     For all the algorithms found in the db for category given by category_key, update their
     'last_introspection_check' timestamp if they are part of current_groups.
     
     :param current_groups: a list of algorithm groups that recently passed our validations
         from the introspection and are still valid
     :param category_key: the algorithm group category for which we match the algorithms found
         in the db with those we recently validated on introspection
     """
     db_groups = dao.get_groups_by_categories([category_key], filter_removed=False)
     for group in db_groups:
         for curr_group in current_groups:
             if group.module == curr_group.module and group.classname == curr_group.classname:
                 group.last_introspection_check = datetime.datetime.now()
                 dao.store_entity(group)
                 break
コード例 #8
0
    def test_introspect(self):
        """
        Test the actual introspect module on a test structure created in:
        tvb_test.dummy_adapters and tvb_test.dummy_datatypes
        """
        self.introspector.introspect(True)
        initialize_storage()

        all_categories = dao.get_algorithm_categories()
        category_ids = [
            cat.id for cat in all_categories
            if cat.displayname == "AdaptersTest"
        ]
        groups = dao.get_groups_by_categories(category_ids)
        self.assertEqual(len(groups), 11, "Introspection failed!")
        nr_adapters_mod2 = 0
        for algorithm in groups:
            self.assertTrue(
                algorithm.module in [
                    'tvb_test.adapters.testadapter1',
                    'tvb_test.adapters.testadapter2',
                    'tvb_test.adapters.testadapter3',
                    'tvb_test.adapters.ndimensionarrayadapter',
                    "tvb.adapters.analyzers.group_python_adapter",
                    "tvb_test.adapters.testgroupadapter"
                ], "Unknown Adapter:" + str(algorithm.module))
            self.assertTrue(
                algorithm.classname in [
                    "TestAdapter1", "TestAdapterDatatypeInput", "TestAdapter2",
                    "TestAdapter22", "TestAdapter3", "NDimensionArrayAdapter",
                    "PythonAdapter", "TestAdapterHDDRequired",
                    "TestAdapterHugeMemoryRequired",
                    "TestAdapterNoMemoryImplemented", "TestGroupAdapter"
                ], "Unknown Adapter Class:" + str(algorithm.classname))
            if algorithm.module == 'tvb_test.adapters.testadapter2':
                nr_adapters_mod2 = nr_adapters_mod2 + 1
        self.assertEqual(
            nr_adapters_mod2, 2,
            "Two adapters should have been loaded from module tvb_test.adapters2!"
        )
コード例 #9
0
ファイル: flowservice.py プロジェクト: wvangeit/framework_tvb
 def get_groups_for_categories(categories):
     """
     Retrieve the list of all Adapters names from a  given Category
     """
     categories_ids = [categ.id for categ in categories]
     return dao.get_groups_by_categories(categories_ids)
コード例 #10
0
 def get_groups_for_categories(categories):
     """
     Retrieve the list of all Adapters names from a  given Category
     """
     categories_ids = [categ.id for categ in categories]
     return dao.get_groups_by_categories(categories_ids)