Ejemplo n.º 1
0
 def setUp(self):
     self.datastore = create_datastore()
     self.instance = create_instance()
     self.manager = BaseManager(self.datastore)
     patcher = patch('dtrove.datastores.base.run')
     self.mock_run = patcher.start()
     self.addCleanup(patcher.stop)
Ejemplo n.º 2
0
class BaseDatastoreTests(DtroveTest):

    def setUp(self):
        self.datastore = create_datastore()
        self.instance = create_instance()
        self.manager = BaseManager(self.datastore)
        patcher = patch('dtrove.datastores.base.run')
        self.mock_run = patcher.start()
        self.addCleanup(patcher.stop)

    def test_backup(self):
        self.assertRaises(NotImplementedError, self.manager.backup, None)

    def test_prepare(self):
        self.assertRaises(NotImplementedError, self.manager.prepare, None)

    def test_render_config_file(self):
        template = self.manager.render_config_file(self.instance)
        self.assertTemplateUsed(template, 'mysql/config')

    def test_config_not_found(self):
        ds = create_datastore(manager='dtrove.datastores.base.BaseManager')
        manager = BaseManager(ds)
        self.assertRaises(TemplateDoesNotExist,
                          manager.render_config_file,
                          self.instance)

    def test_start(self):
        self.manager.start()
        self.mock_run.assert_called_with('service None start')

    def test_restart(self):
        self.manager.restart()
        self.mock_run.assert_called_with('service None restart')

    def test_stop(self):
        self.manager.stop()
        self.mock_run.assert_called_with('service None stop')

    def test_packages_blanks(self):
        ds_spacey = create_datastore(packages='  \n  curl  \n  ssh')
        manager = BaseManager(ds_spacey)
        self.assertEqual(['curl', 'ssh'], manager.packages)

    def test_packages_empty(self):
        ds_spacey = create_datastore(packages='        \n')
        manager = BaseManager(ds_spacey)
        self.assertEqual([], manager.packages)