コード例 #1
0
    def test05_json_file_validate(self):
        test_class = FileValidator.FileValidator('test')

        returned = test_class.file_to_validate('tests/ut_data/test_data.json')
        self.assertEqual(returned, app_defs.NOERROR)

        for i in range(2):
            self.assertListEqual(self.returned_data[i],
                                 test_class.get_values()[i].tolist())
コード例 #2
0
    def test08_json_file_with_header_validate(self):
        test_class = FileValidator.FileValidator('test')

        returned = test_class.file_to_validate(
            'tests/ut_data/test_data_with_header.json')
        self.assertEqual(returned, app_defs.NOERROR)
        self.assertListEqual(self.headers,
                             test_class.get_values().columns.tolist())

        for i in range(2):
            self.assertListEqual(
                self.returned_data[i],
                test_class.get_values()[self.headers[i]].tolist())
コード例 #3
0
    def open_file_window(self):
        self.set_status('Open file')
        ret = app_defs.NO_ACTION
        file_to_open, _ = QFileDialog.getOpenFileName(
            self,
            'Open file',
            filter='TextFile (*.txt);;CSV (*.csv);;JSON (*.json)')
        self.log.write_log(app_defs.INFO_MSG,
                           'Selected file: ' + str(file_to_open))
        if file_to_open:
            file_points = FileValidator.FileValidator('Main',
                                                      append=self.re_write_log)
            ret = file_points.file_to_validate(file_to_open)

        if ret != app_defs.NOERROR:
            if ret == app_defs.UNKNOWN_FILE_TYPE:
                self.log.write_log(
                    app_defs.WARNING_MSG,
                    'Unknown file type! File: %s' % file_to_open)
                _ = QMessageBox.information(
                    self, 'Unknown file type',
                    'File: %s cannot be open. File type unknown.' %
                    file_to_open, QMessageBox.Ok, QMessageBox.Ok)
            elif ret == app_defs.UNABLE_TO_OPEN_FILE:
                self.log.write_log(
                    app_defs.ERROR_MSG,
                    'Unable to open file! File: %s' % file_to_open)
                _ = QMessageBox.warning(
                    self, 'Unknown file type',
                    'File: %s unable to open. Please see log file!' %
                    file_to_open, QMessageBox.Ok, QMessageBox.Ok)
        elif ret == app_defs.NOERROR:
            self.log.write_log(
                app_defs.INFO_MSG,
                'File validated successfully, proceed to load and plot data.')
            self.data_viewer.set_data(file_points.get_values())
            self.load_data()

        if not self.re_write_log:
            self.re_write_log = True
コード例 #4
0
    def test02_wrong_file_to_validate(self):
        test_class = FileValidator.FileValidator('test')

        returned = test_class.file_to_validate('testowy.source')

        self.assertEqual(returned, app_defs.UNKNOWN_FILE_TYPE)
コード例 #5
0
    def test01_init(self):
        test_class = FileValidator.FileValidator('test')

        self.assertEqual(test_class.entry_point, 'test')