Пример #1
0
 def test_update_manifest(self):
     repo_name = self.items['francis/fr_ulb']['repo_name']
     user_name = self.items['francis/fr_ulb']['user_name']
     tx_manifest = TxManifest.get(repo_name=repo_name, user_name=user_name)
     # Update by setting fields and calling update()
     tx_manifest.resource_id = 'udb'
     tx_manifest.title = 'Unlocked Dynamic Bible'
     tx_manifest.update()
     manifest_from_db = TxManifest.get(repo_name=repo_name, user_name=user_name)
     self.assertEqual(manifest_from_db.title, tx_manifest.title)
     # Update by giving a dict to update()
     tx_manifest.views = 5
     tx_manifest.update()
     manifest_from_db = TxManifest.get(repo_name=repo_name, user_name=user_name)
     self.assertEqual(manifest_from_db.views, 5)
     AppSettings.db_close()
Пример #2
0
 def test_setup_db_with_connection_string_parts(self):
     AppSettings(db_protocol='sqlite',
                 db_user=None,
                 db_pass=None,
                 db_end_point=None,
                 db_port=None,
                 db_name=':memory:',
                 db_connection_string_params=None)
     AppSettings.db_create_tables([User.__table__])
     user = User(name='ed',
                 fullname='Edward Scissorhands',
                 password='******')
     user.insert()
     user_from_db = User.get(name='ed')
     self.assertIsNotNone(user_from_db)
     self.assertEqual(user_from_db.password, '12345')
     AppSettings.db_close()
Пример #3
0
    def do_post_processing(self) -> Dict[str, Any]:
        AppSettings.logger.debug(f"ClientLinterCallback.do_post_processing()…")
        if not self.identifier:
            error = 'No identifier found'
            AppSettings.logger.error(error)
            raise Exception(error)

        # if not self.s3_results_key:
        #     error = f"No s3_results_key found for identifier = {self.identifier}"
        #     AppSettings.logger.error(error)
        #     raise Exception(error)

        id_parts = self.identifier.split('/')
        self.multipart = len(id_parts) > 3
        if self.multipart:
            raise Exception("Unsupported")
            # NOTE: Disabled 4Mar2019 coz unused
            # part_count, part_id, book = id_parts[1:4]
            # AppSettings.logger.debug('Multiple project, part {0} of {1}, linted book {2}'.
            #                  format(part_id, part_count, book))
            # s3__master_results_key = '/'.join(self.s3_results_key.split('/')[:-1])
        else:
            AppSettings.logger.debug('Single project')
            # NOTE: Disabled 4Mar2019 coz unused
            # s3__master_results_key = self.s3_results_key

        build_log = {
            'identifier': self.identifier,
            'success': self.success,
            'multipart_project': self.multipart,
            'log': self.log,
            'warnings': self.warnings,
            'errors': self.errors,
            # 's3_commit_key': self.s3_results_key
        }

        if not self.success:
            msg = "Linter failed for identifier: " + self.identifier
            build_log['warnings'].append(msg)
            AppSettings.logger.error(msg)
        else:
            AppSettings.logger.debug(
                f"Linter {self.identifier} had success with"
                f" {len(self.warnings)} warnings: {', '.join(self.warnings[:5])} …"
            )

        has_warnings = len(build_log['warnings']) > 0
        if has_warnings:
            msg = f"Linter {self.identifier} has Warnings!"
            build_log['log'].append(msg)
        else:
            msg = f"Linter {self.identifier} completed with no warnings"
            build_log['log'].append(msg)

        # NOTE: Do we need this -- disabled 25Feb2019
        # ClientLinterCallback.upload_build_log(build_log, 'lint_log.json', self.temp_dir, self.s3_results_key)

        # NOTE: Do we need this -- disabled 4Mar2019 since linting is always done first
        # results = ClientLinterCallback.deploy_if_conversion_finished(s3__master_results_key, self.identifier)
        # if results:
        #     self.all_parts_completed = True
        #     build_log = results

        # if prefix and debug_mode_flag:
        #     AppSettings.logger.debug(f"Temp folder '{self.temp_dir}' has been left on disk for debugging!")
        # else:
        #     remove_tree(self.temp_dir)  # cleanup
        AppSettings.db_close()
        return build_log

    # end of do_post_processing()


# end of ClientLinterCallback class