示例#1
0
    def get_test_folder(self, module_path):
        """
        This function will get the appropriate test folder based on
        server version and their existence.

        :param module_path: Path of the module to be tested.
        :return:
        """
        # Join the application path, module path and tests folder
        tests_folder_path = os.path.join(self.apppath, module_path, 'tests')

        # A folder name matching the Server Type (pg, ppas) takes priority so
        # check whether that exists or not. If so, than check the version
        # folder in it, else look directly in the 'tests' folder.
        absolute_path = os.path.join(tests_folder_path, self.server['type'])
        if not os.path.exists(absolute_path):
            absolute_path = tests_folder_path

        # Iterate the version mapping directories.
        for version_mapping in get_version_mapping_directories(
                self.server['type']):
            if version_mapping['number'] > \
                    self.server_information['server_version']:
                continue

            complete_path = os.path.join(absolute_path,
                                         version_mapping['name'])

            if os.path.exists(complete_path):
                return True, complete_path

        return False, None
    def get_template_file(self, version, file_path, filename):
        """
        This function check the specified file in the server mapping directory
        and if file exists then return that path.
        :param version:
        :param file_path:
        :param filename:
        :return:
        """
        # Iterate all the mapping directories and check the file is exist
        # in the specified folder. If it exists then return the path.
        for directory in get_version_mapping_directories(self.server['type']):
            if directory['number'] > version:
                continue

            template_path = '/'.join([file_path, directory['name'], filename])

            if os.path.exists(template_path):
                return template_path
示例#3
0
    def get_expected_sql(self):
        sql_base_path = path.join(path.dirname(path.realpath(__file__)), 'sql')

        # Iterate the version mapping directories.
        for version_mapping in \
                get_version_mapping_directories(self.server['type']):
            if version_mapping['number'] > \
                    self.server_information['server_version']:
                continue

            complete_path = path.join(sql_base_path, version_mapping['name'])

            if not path.exists(complete_path):
                complete_path = path.join(sql_base_path, 'default')
            break

        data_sql = ''
        with open(path.join(complete_path, 'test_sql_output.sql')) as fp:
            data_sql = fp.read()

        return data_sql
示例#4
0
    def get_test_folder(self, module_path):
        """
        This function will get the appropriate test folder based on
        server version and their existence.

        :param module_path: Path of the module to be tested.
        :return:
        """
        # Join the application path and the module path
        absolute_path = os.path.join(self.apppath, module_path)
        # Iterate the version mapping directories.
        for version_mapping in get_version_mapping_directories(
                self.server['type']):
            if version_mapping['number'] > \
                    self.server_information['server_version']:
                continue

            complete_path = os.path.join(absolute_path, 'tests',
                                         version_mapping['name'])

            if os.path.exists(complete_path):
                return True, complete_path

        return False, None