def test_load_app_cached(self, import_patch):
     """
     Tests that the cache is hit since import is only called once.
     """
     initial_data_updater = InitialDataUpdater()
     initial_data_updater.load_app('fake')
     initial_data_updater.load_app('fake')
     initial_data_updater.load_app('fake')
     self.assertEquals(import_patch.call_count, 1)
Beispiel #2
0
 def test_load_app_cached(self, import_patch):
     """
     Tests that the cache is hit since import is only called once.
     """
     initial_data_updater = InitialDataUpdater()
     initial_data_updater.load_app('fake')
     initial_data_updater.load_app('fake')
     initial_data_updater.load_app('fake')
     self.assertEquals(import_patch.call_count, 1)
    def test_load_app(self):
        """
        Tests the load_app method
        """
        with patch('dynamic_initial_data.base.import_string') as import_patch:
            import_patch.return_value = MockInitialData
            initial_data_manager = InitialDataUpdater()
            self.assertEqual(MockInitialData, initial_data_manager.load_app('fake'))

            # try to load an app that doesn't exist
            initial_data_manager = InitialDataUpdater()
            import_patch.return_value = MockClass
            self.assertIsNone(initial_data_manager.load_app('fake'))
    def test_load_app(self):
        """
        Tests the load_app method
        """
        with patch('dynamic_initial_data.base.import_string') as import_patch:
            import_patch.return_value = MockInitialData
            initial_data_manager = InitialDataUpdater()
            self.assertEqual(MockInitialData,
                             initial_data_manager.load_app('fake'))

            # try to load an app that doesn't exist
            initial_data_manager = InitialDataUpdater()
            import_patch.return_value = MockClass
            self.assertIsNone(initial_data_manager.load_app('fake'))