Ejemplo n.º 1
0
    def _remove_entity(self, data_class, before_number):
        """
        Try to remove entity. Fail otherwise.
        """
        dts, count = get_filtered_datatypes(self.test_project.id, data_class)
        assert count == before_number
        for dt in dts:
            data_gid = dt[2]
            self.project_service.remove_datatype(self.test_project.id, data_gid)
            res = dao.get_datatype_by_gid(data_gid)
            assert res is None, "The entity was not deleted"

        _, count = get_filtered_datatypes(self.test_project.id, data_class)
        assert 0 == count
Ejemplo n.º 2
0
 def test_zip_import(self, prepare_importer_data):
     """
     This method tests import of TVB data in zip format (which imply multiple data types
     in the same zip file - exported from a group)
     """
     self._import(self.zip_file_path)
     _, count = get_filtered_datatypes(self.test_project.id, self.datatype.module + "." + self.datatype.type)
     assert 9, count == "9 datatypes should have been imported from group."
Ejemplo n.º 3
0
    def test_h5_import(self, prepare_importer_data):
        """
        This method tests import of TVB data in h5 format. Single data type / import
        """
        self._import(self.h5_file_path)

        data_types, count = get_filtered_datatypes(self.test_project.id,
                                                   self.datatype.module + "." + self.datatype.type)
        assert 1, len(data_types) == "Project should contain only one data type."
        assert 1, count == "Project should contain only one data type."

        data_type_entity = load_entity_by_gid(data_types[0][2])
        assert data_type_entity is not None, "Datatype should not be none"
        assert self.datatype.gid, data_type_entity.gid == "Imported datatype should have the same gid"
Ejemplo n.º 4
0
 def populate_option_values_for_dtype(self, project_id, type_name, filter_condition=None,
                                      category_key=None, complex_dt_attributes=None):
     '''
     Converts all datatypes that match the project_id, type_name and filter_condition
     to a {name: , value:} dict used to populate options in the input tree ui
     '''
     data_type_cls = get_class_by_name(type_name)
     #todo: send category instead of category_key to avoid redundant queries
     #NOTE these functions are coupled via data_list, _populate_values makes no sense without _get_available_datatypes
     data_list, total_count = get_filtered_datatypes(project_id, data_type_cls,
                                                     filter_condition)
     values = self._populate_values(data_list, data_type_cls,
                                    category_key, complex_dt_attributes)
     return values, total_count
Ejemplo n.º 5
0
    def build(test_user, test_project):
        view_model = BaseBCTModel()
        view_model.connectivity = get_filtered_datatypes(test_project.id, ConnectivityIndex, page_size=1)[0][0][2]

        adapter = ABCAdapter.build_adapter_from_class(TransitivityBinaryDirected)
        op = OperationService().fire_operation(adapter, test_user, test_project.id, view_model=view_model)
        # wait for the operation to finish
        tries = 5
        while not op.has_finished and tries > 0:
            sleep(5)
            tries = tries - 1
            op = dao.get_operation_by_id(op.id)

        value_wrapper = try_get_last_datatype(test_project.id, ValueWrapperIndex)
        count = dao.count_datatypes(test_project.id, ValueWrapperIndex)
        assert 1 == count
        return value_wrapper
Ejemplo n.º 6
0
 def populate_option_values_for_dtype(self, project_id, type_name, filter_condition=None,
                                      category_key=None):
     '''
     Converts all datatypes that match the project_id, type_name and filter_condition
     to a {name: , value:} dict used to populate options in the input tree ui
     '''
     # todo: normalize all itree[KEY_TYPE] to be a python type, not a str, not a None etc
     if isinstance(type_name, basestring):
         data_type_cls = get_class_by_name(type_name)
     else:
         data_type_cls = type_name
     #todo: send category instead of category_key to avoid redundant queries
     #NOTE these functions are coupled via data_list, _populate_values makes no sense without _get_available_datatypes
     data_list, total_count = get_filtered_datatypes(project_id, data_type_cls,
                                                     filter_condition)
     values = self._populate_values(data_list, data_type_cls, category_key)
     return values, total_count
Ejemplo n.º 7
0
        def build(project):
            count = dao.count_datatypes(project.id, DataTypeMatrix)
            assert count == 0

            op = operation_factory(test_project=project)
            conn = connectivity_index_factory(op=op)

            count = _create_measure(conn, op, project)
            assert count == 1

            count = _create_measure(conn, op, project)
            assert count == 2

            count = _create_measure(conn, op, project)
            assert count == 3

            return get_filtered_datatypes(project.id, DataTypeMatrix)[0]
Ejemplo n.º 8
0
 def populate_option_values_for_dtype(self,
                                      project_id,
                                      type_name,
                                      filter_condition=None,
                                      category_key=None,
                                      complex_dt_attributes=None):
     '''
     Converts all datatypes that match the project_id, type_name and filter_condition
     to a {name: , value:} dict used to populate options in the input tree ui
     '''
     data_type_cls = get_class_by_name(type_name)
     #todo: send category instead of category_key to avoid redundant queries
     #NOTE these functions are coupled via data_list, _populate_values makes no sense without _get_available_datatypes
     data_list, total_count = get_filtered_datatypes(
         project_id, data_type_cls, filter_condition)
     values = self._populate_values(data_list, data_type_cls, category_key,
                                    complex_dt_attributes)
     return values, total_count
        def build(project):
            count = dao.count_datatypes(project.id, DataTypeMatrix)
            assert count == 0

            op = operation_factory(test_project=project)
            conn = connectivity_index_factory(op=op)
            storage_path = FilesHelper().get_project_folder(
                op.project, str(op.id))

            count = _create_measure(conn, op, storage_path, project.id)
            assert count == 1

            count = _create_measure(conn, op, storage_path, project.id)
            assert count == 2

            count = _create_measure(conn, op, storage_path, project.id)
            assert count == 3

            return get_filtered_datatypes(project.id, DataTypeMatrix)[0]
Ejemplo n.º 10
0
 def get_available_datatypes(project_id, data_type_cls, filters=None):
     """
     Return all dataTypes that match a given name and some filters.
     :param data_type_cls: either a fully qualified class name or a class object
     """
     return get_filtered_datatypes(project_id, data_type_cls, filters)
Ejemplo n.º 11
0
 def get_available_datatypes(project_id, data_type_cls, filters=None):
     """
     Return all dataTypes that match a given name and some filters.
     :param data_type_cls: either a fully qualified class name or a class object
     """
     return get_filtered_datatypes(project_id, data_type_cls, filters)