def setUp(self):
     """
     Create the UI and setup necessary options
     """
     self.build_settings()
     self.setup_application()
     Registry.create()
     with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
         if os.path.exists(TEST_DB):
             os.unlink(TEST_DB)
         mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB
         self.projectordb = ProjectorDB()
         if not hasattr(self, 'projector_manager'):
             self.projector_manager = ProjectorManager(
                 projectordb=self.projectordb)
Esempio n. 2
0
 def setUp(self):
     """
     Create the UI and setup necessary options
     """
     self.build_settings()
     self.setup_application()
     Registry.create()
     if not hasattr(self, 'projector_manager'):
         with patch('openlp.core.lib.projector.db.init_url'
                    ) as mocked_init_url:
             mocked_init_url.start()
             mocked_init_url.return_value = 'sqlite:///%s' % tmpfile
             self.projectordb = ProjectorDB()
             if not hasattr(self, 'projector_manager'):
                 self.projector_manager = ProjectorManager(
                     projectordb=self.projectordb)
 def setUp(self):
     """
     Create the UI and setup necessary options
     """
     self.build_settings()
     self.setup_application()
     Registry.create()
     if not hasattr(self, 'projector_manager'):
         with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
             mocked_init_url.start()
             mocked_init_url.return_value = 'sqlite:///%s' % tmpfile
             self.projectordb = ProjectorDB()
             if not hasattr(self, 'projector_manager'):
                 self.projector_manager = ProjectorManager(projectordb=self.projectordb)
Esempio n. 4
0
 def setUp(self):
     """
     Create the UI and setup necessary options
     """
     self.build_settings()
     self.setup_application()
     Registry.create()
     with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
         if os.path.exists(TEST_DB):
             os.unlink(TEST_DB)
         mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB
         self.projectordb = ProjectorDB()
         if not hasattr(self, 'projector_manager'):
             self.projector_manager = ProjectorManager(projectordb=self.projectordb)
class TestProjectorManager(TestCase, TestMixin):
    """
    Test the functions in the ProjectorManager module
    """
    def setUp(self):
        """
        Create the UI and setup necessary options
        """
        self.build_settings()
        self.setup_application()
        Registry.create()
        if not hasattr(self, 'projector_manager'):
            with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
                mocked_init_url.start()
                mocked_init_url.return_value = 'sqlite:///%s' % tmpfile
                self.projectordb = ProjectorDB()
                if not hasattr(self, 'projector_manager'):
                    self.projector_manager = ProjectorManager(projectordb=self.projectordb)

    def tearDown(self):
        """
        Remove test database.
        Delete all the C++ objects at the end so that we don't have a segfault.
        """
        self.projectordb.session.close()
        self.destroy_settings()
        del self.projector_manager

    def bootstrap_initialise_test(self):
        """
        Test initialize calls correct startup functions
        """
        # WHEN: we call bootstrap_initialise
        self.projector_manager.bootstrap_initialise()
        # THEN: ProjectorDB is setup
        self.assertEqual(type(self.projector_manager.projectordb), ProjectorDB,
                         'Initialization should have created a ProjectorDB() instance')

    def bootstrap_post_set_up_test(self):
        """
        Test post-initialize calls proper setups
        """
        # GIVEN: setup mocks
        self.projector_manager._load_projectors = MagicMock()

        # WHEN: Call to initialize is run
        self.projector_manager.bootstrap_initialise()
        self.projector_manager.bootstrap_post_set_up()

        # THEN: verify calls to retrieve saved projectors and edit page initialized
        self.assertEqual(1, self.projector_manager._load_projectors.call_count,
                         'Initialization should have called load_projectors()')
        self.assertEqual(type(self.projector_manager.projector_form), ProjectorEditForm,
                         'Initialization should have created a Projector Edit Form')
        self.assertIs(self.projector_manager.projectordb,
                      self.projector_manager.projector_form.projectordb,
                      'ProjectorEditForm should be using same ProjectorDB() instance as ProjectorManager')
class TestProjectorManager(TestCase, TestMixin):
    """
    Test the functions in the ProjectorManager module
    """
    def setUp(self):
        """
        Create the UI and setup necessary options
        """
        self.build_settings()
        self.setup_application()
        Registry.create()
        with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
            if os.path.exists(TEST_DB):
                os.unlink(TEST_DB)
            mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB
            self.projectordb = ProjectorDB()
            if not hasattr(self, 'projector_manager'):
                self.projector_manager = ProjectorManager(
                    projectordb=self.projectordb)

    def tearDown(self):
        """
        Remove test database.
        Delete all the C++ objects at the end so that we don't have a segfault.
        """
        self.projectordb.session.close()
        self.destroy_settings()
        del self.projector_manager

    def test_bootstrap_initialise(self):
        """
        Test initialize calls correct startup functions
        """
        # WHEN: we call bootstrap_initialise
        self.projector_manager.bootstrap_initialise()
        # THEN: ProjectorDB is setup
        self.assertEqual(
            type(self.projector_manager.projectordb), ProjectorDB,
            'Initialization should have created a ProjectorDB() instance')

    def test_bootstrap_post_set_up(self):
        """
        Test post-initialize calls proper setups
        """
        # GIVEN: setup mocks
        self.projector_manager._load_projectors = MagicMock()

        # WHEN: Call to initialize is run
        self.projector_manager.bootstrap_initialise()
        self.projector_manager.bootstrap_post_set_up()

        # THEN: verify calls to retrieve saved projectors and edit page initialized
        self.assertEqual(
            1, self.projector_manager._load_projectors.call_count,
            'Initialization should have called load_projectors()')
        self.assertEqual(
            type(self.projector_manager.projector_form), ProjectorEditForm,
            'Initialization should have created a Projector Edit Form')
        self.assertIs(
            self.projector_manager.projectordb,
            self.projector_manager.projector_form.projectordb,
            'ProjectorEditForm should be using same ProjectorDB() instance as ProjectorManager'
        )