def setUp(self):
     self.settings = {}
     self.manager = SettingsManager()
     self.manager.bind(self.settings)
class TestSettingsManager(TestCase):

    def setUp(self):
        self.settings = {}
        self.manager = SettingsManager()
        self.manager.bind(self.settings)

    def test_binding(self):
        self.assertEqual(self.manager.is_bound, True)
        self.manager.unbind()
        self.assertEqual(self.manager.is_bound, False)
        with self.assertRaises(AttributeError):
            self.manager.unbind()
        with self.assertRaises(AttributeError):
            self.manager.add_action('load', ['this'])
        with self.assertRaises(AttributeError):
            self.manager.set_source_name('FOO', 'bar')

    def test_create_action_context(self):
        with mock.patch.object(self.manager, 'actions') as action_manager:
            self.manager.create_action_context('test')
            action_manager.create_context_layer.assert_called_with('test')

    def test_add_action(self):
        with mock.patch.object(self.manager, 'actions') as action_manager:
            self.manager.add_action('load', modules=['this', 'that'])
            action_manager.add_action.assert_called_with(
                'load', modules=['this', 'that']
            )

    def test_get_current_actions(self):
        with mock.patch.object(self.manager, 'actions') as action_manager:
            value = self.manager.get_current_actions('load')
            action_manager.consume_actions.assert_called_with('load')
            self.assertEqual(value, action_manager.consume_actions.return_value)

    def test_get_all_actions(self):
        with mock.patch.object(self.manager, 'actions') as action_manager:
            value = self.manager.get_all_actions('load')
            action_manager.consume_all_actions.assert_called_with('load')
            self.assertEqual(value, action_manager.consume_all_actions.return_value)