Пример #1
0
    def test_runIndexCreatePrograms(self):
        self.logger.info("Index Create Programs Test")
        for d in self.directory_list:
            result = plugins.directoryValidAndImport(
                os.path.join(TEST_DIRECTORY_PATH, d["directory_name"]))
            if result["code"] == 0:
                result = plugins.directoryAnalysisProgram(
                    os.path.join(TEST_DIRECTORY_PATH, d["directory_name"]))
                if result["code"] == 0:
                    result = plugins.makeAlgorithmConfigFiles()
                    if result["code"] == 0:
                        result = plugins.runIndexCreateProgram()
                        # log_info = "{} - {} - {}".format(result["code"], d["directory_return_code"], result["message"])
                        # self.logger.info(log_info)
                        '''
						print "{} - {} - {}".format(result["code"], d["directory_return_code"], result["message"])
						'''
                        if result["code"] == 0:
                            config_query_set = AlgorithmConfigInfo.objects.all(
                            )
                            total = len(config_query_set)
                            finished = len(
                                config_query_set.filter(config_flag=1))
                            while finished < total:
                                self.logger.info("index creating...")
                                time.sleep(10)
                                finished = AlgorithmConfigInfo.objects.filter(
                                    config_flag=1)
                            else:
                                log_info = "{} - {} - {}".format(
                                    result["code"], d["directory_return_code"],
                                    result["message"])
                                self.logger.info(log_info)
                        self.assertEqual(result["code"],
                                         d["directory_return_code"])
Пример #2
0
    def test_directoryValidAndImport(self):
        self.logger.info("Directory Valid And Import Test")
        for d in self.directory_list:
            result = plugins.directoryValidAndImport(
                os.path.join(TEST_DIRECTORY_PATH, d["directory_name"]))
            log_info = "{} - {} - {}".format(result["code"],
                                             d["directory_return_code"],
                                             result["message"])
            self.logger.info(log_info)
            '''
			if result["code"]==d["directory_return_code"]:
				print "{} - {} - {}".format(result["code"], d["directory_return_code"], result["message"])
			else:
				print "{} - {} - {}".format(result["code"], d["directory_return_code"], result["message"])
			'''
            self.assertEqual(result["code"], d["directory_return_code"])
Пример #3
0
    def test_makeAlgorithmConfigFiles(self):
        self.logger.info("Algorithm Config Files make Test")
        for d in self.directory_list:
            result = plugins.directoryValidAndImport(
                os.path.join(TEST_DIRECTORY_PATH, d["directory_name"]))
            if result["code"] == 0:
                result = plugins.directoryAnalysisProgram(
                    os.path.join(TEST_DIRECTORY_PATH, d["directory_name"]))
                if result["code"] == 0:
                    result = plugins.makeAlgorithmConfigFiles()
                    log_info = "{} - {} - {}".format(
                        result["code"], d["directory_return_code"],
                        result["message"])
                    self.logger.info(log_info)
                    '''
					print "{} - {} - {}".format(result["code"], d["directory_return_code"], result["message"])
					'''
                    self.assertEqual(result["code"],
                                     d["directory_return_code"])
Пример #4
0
    def test_directoryAnalysisProgram(self):
        # self.test_directoryValidAndImport()
        # directory_query_set = DirectoryInfo.objects.all()
        # print directory_query_set
        self.logger.info("Directory Analysis Program Test")
        for d in self.directory_list:
            result = plugins.directoryValidAndImport(
                os.path.join(TEST_DIRECTORY_PATH, d["directory_name"]))
            if result["code"] == 0:
                result = plugins.directoryAnalysisProgram(
                    os.path.join(TEST_DIRECTORY_PATH, d["directory_name"]))
                log_info = "{} - {} - {}".format(result["code"],
                                                 d["directory_return_code"],
                                                 result["message"])
                self.logger.info(log_info)
                '''
				print "{} - {} - {}".format(result["code"], d["directory_return_code"], result["message"])
				'''
                self.assertEqual(result["code"], d["directory_return_code"])
Пример #5
0
def directoryAddition(request):
    directory_string = request.POST.get('directory', '')
    result = plugins.directoryValidAndImport(directory_string)
    if result["code"] == 0:
        result = plugins.directoryAnalysisProgram(directory_string)
        if result["code"] == 0:
            result = plugins.makeAlgorithmConfigFiles()
            if result["code"] == 0:
                result = plugins.runIndexCreateProgram()
                if result["code"] == 0:
                    return HttpResponseRedirect('/dashboard/')
                    #return HttpResponse(json.dumps(result), content_type="application/json")
                else:
                    #return HttpResponse(json.dumps(result), content_type="application/json")
                    return HttpResponseRedirect('/dashboard/')
            else:
                #return HttpResponse(json.dumps(result), content_type="application/json")
                return HttpResponseRedirect('/dashboard/')
        else:
            #return HttpResponse(json.dumps(result), content_type="application/json")
            return HttpResponseRedirect('/dashboard/')
    else:
        #return HttpResponse(json.dumps(result), content_type="application/json")
        return HttpResponseRedirect('/dashboard/')