def test_signals_usage(self): """ Test signal handling. """ from invenio.base.scripts.database import main as db_main from invenio.base.signals import pre_command, post_command from invenio.base.manage import main, version as im_version def pre_handler_version(sender, *args, **kwargs): print('>>> pre_handler_version') def post_handler_version(sender, *args, **kwargs): print('>>> post_handler_version') # Bind only `inveniomanage version` command to pre/post handler. pre_command.connect(pre_handler_version, sender=im_version) post_command.connect(post_handler_version, sender=im_version) def pre_handler_general_test(sender, *args, **kwargs): print('>>> pre_handler_general') def post_handler_general_test(sender, *args, **kwargs): print('>>> post_handler_general') # Bind all commands to pre/post general handler. pre_command.connect(pre_handler_general_test) pre_command.connect(post_handler_general_test) # Expect both version and general handlers. out, dummy_exit_code = run('inveniomanage version', main) lines = out.split('\n') expected = ['>>> pre_handler_version', '>>> post_handler_version', '>>> pre_handler_general', '>>> post_handler_general'] for line in expected: self.assertTrue(line in lines, "%s was not found in output %s" % (line, lines)) # Expect only general handlers. out, dummy_exit_code = run('database uri', db_main) lines = out.split('\n') expected = ['>>> pre_handler_general', '>>> post_handler_general'] for line in expected: self.assertTrue(line in lines, "%s was not found in output %s" % (line, lines)) notexpected = ['>>> pre_handler_version', '>>> post_handler_version'] for line in notexpected: self.assertFalse(line in lines, "%s was not expected in output %s" % (line, lines))
def test_signals_usage(self): """ Test signal handling. """ from invenio.base.scripts.database import main as db_main from invenio.base.signals import pre_command, post_command from invenio.base.manage import main, version as im_version def pre_handler_version(sender, *args, **kwargs): print('>>> pre_handler_version') def post_handler_version(sender, *args, **kwargs): print('>>> post_handler_version') # Bind only `inveniomanage version` command to pre/post handler. pre_command.connect(pre_handler_version, sender=im_version) post_command.connect(post_handler_version, sender=im_version) def pre_handler_general_test(sender, *args, **kwargs): print('>>> pre_handler_general') def post_handler_general_test(sender, *args, **kwargs): print('>>> post_handler_general') # Bind all commands to pre/post general handler. pre_command.connect(pre_handler_general_test) pre_command.connect(post_handler_general_test) # Expect both version and general handlers. out, dummy_exit_code = run('inveniomanage version', main) lines = out.split('\n') expected = [ '>>> pre_handler_version', '>>> post_handler_version', '>>> pre_handler_general', '>>> post_handler_general' ] for line in expected: self.assertTrue(line in lines, "%s was not found in output %s" % (line, lines)) # Expect only general handlers. out, dummy_exit_code = run('database uri', db_main) lines = out.split('\n') expected = ['>>> pre_handler_general', '>>> post_handler_general'] for line in expected: self.assertTrue(line in lines, "%s was not found in output %s" % (line, lines)) notexpected = ['>>> pre_handler_version', '>>> post_handler_version'] for line in notexpected: self.assertFalse( line in lines, "%s was not expected in output %s" % (line, lines))
def test_signals_usage(self): """ Test signal handling. """ from invenio.base.scripts.database import main as db_main from invenio.base.signals import pre_command, post_command from invenio.base.manage import main, version as im_version def pre_handler_version(sender, *args, **kwargs): print(">>> pre_handler_version") def post_handler_version(sender, *args, **kwargs): print(">>> post_handler_version") # Bind only `inveniomanage version` command to pre/post handler. pre_command.connect(pre_handler_version, sender=im_version) post_command.connect(post_handler_version, sender=im_version) def pre_handler_general_test(sender, *args, **kwargs): print(">>> pre_handler_general") def post_handler_general_test(sender, *args, **kwargs): print(">>> post_handler_general") # Bind all commands to pre/post general handler. pre_command.connect(pre_handler_general_test) pre_command.connect(post_handler_general_test) # Expect both version and general handlers. out = run_py_func(main, "inveniomanage version").out lines = out.split("\n") expected = ( ">>> pre_handler_version", ">>> post_handler_version", ">>> pre_handler_general", ">>> post_handler_general", ) for line in expected: self.assertTrue(line in lines, "%s was not found in output %s" % (line, lines)) # Expect only general handlers. out = run_py_func(db_main, "database uri").out lines = out.split("\n") expected = (">>> pre_handler_general", ">>> post_handler_general") for line in expected: self.assertTrue(line in lines, "%s was not found in output %s" % (line, lines)) notexpected = (">>> pre_handler_version", ">>> post_handler_version") for line in notexpected: self.assertFalse(line in lines, "%s was not expected in output %s" % (line, lines))
# -*- coding: utf-8 -*- # ## This file is part of Invenio. ## Copyright (C) 2011, 2012, 2013 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02D111-1307, USA. from __future__ import absolute_import from .receivers import post_handler_demosite_populate from invenio.base.scripts.demosite import populate as demosite_populate from invenio.base.signals import post_command post_command.connect(post_handler_demosite_populate, sender=demosite_populate)
## CDS is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## CDS is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDS. If not, see <http://www.gnu.org/licenses/>. ## ## In applying this licence, CERN does not waive the privileges and immunities ## granted to it by virtue of its status as an Intergovernmental Organization ## or submit itself to any jurisdiction. from __future__ import absolute_import from .receivers import post_handler_demosite_populate, post_handler_database_create, clean_data_files from .manage import populate from invenio.base.scripts.database import create, recreate, drop, init from invenio.base.signals import post_command post_command.connect(post_handler_demosite_populate, sender=populate) post_command.connect(post_handler_database_create, sender=create) post_command.connect(post_handler_database_create, sender=recreate) post_command.connect(clean_data_files, sender=init) post_command.connect(clean_data_files, sender=drop)
# -*- coding: utf-8 -*- # ## This file is part of Invenio. ## Copyright (C) 2013, 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from .receivers import post_handler_database_create from invenio.base.scripts.database import create as database_create from invenio.base.scripts.demosite import populate as demosite_populate from invenio.base.signals import post_command post_command.connect(post_handler_database_create, sender=database_create) post_command.connect(post_handler_database_create, sender=demosite_populate)
# # This file is part of Lifewatch DAAP. # Copyright (C) 2015 Ana Yaiza Rodriguez Marrero. # # Lifewatch DAAP is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Lifewatch DAAP is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Lifewatch DAAP. If not, see <http://www.gnu.org/licenses/>. from __future__ import absolute_import from .receivers import post_handler_demosite_populate, \ post_handler_database_create, clean_data_files from invenio.base.scripts.demosite import populate from invenio.base.scripts.database import create, recreate, drop, init from invenio.base.signals import post_command post_command.connect(post_handler_demosite_populate, sender=populate) post_command.connect(post_handler_database_create, sender=create) post_command.connect(post_handler_database_create, sender=recreate) post_command.connect(clean_data_files, sender=init) post_command.connect(clean_data_files, sender=drop)
# -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2013, 2014 CERN. # # Invenio is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # Invenio is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Invenio; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from .receivers import post_handler_database_create from invenio.base.scripts.database import create as database_create from invenio.base.scripts.database import recreate as database_recreate from invenio.base.scripts.demosite import populate as demosite_populate from invenio.base.signals import post_command post_command.connect(post_handler_database_create, sender=database_create) post_command.connect(post_handler_database_create, sender=database_recreate) post_command.connect(post_handler_database_create, sender=demosite_populate)