def test_remove_failure(self, exists_mock, sudo_mock):
     exists_mock.return_value = False
     fabric.api.env.host = 'localhost'
     out = _AttributeString()
     out.succeeded = False
     sudo_mock.return_value = out
     connector.remove('tpch')
     self.assertEqual('\nWarning: [localhost] Failed to remove connector '
                      'tpch.\n\t\n\n',
                      self.test_stderr.getvalue())
 def test_remove_no_such_file(self, exists_mock, sudo_mock):
     exists_mock.return_value = False
     fabric.api.env.host = 'localhost'
     error_msg = ('Could not remove connector tpch: No such file '
                  '/etc/opt/prestoadmin/connectors/tpch.properties')
     out = _AttributeString(error_msg)
     out.succeeded = True
     sudo_mock.return_value = out
     connector.remove('tpch')
     self.assertEqual('\nWarning: [localhost] %s\n\n' % error_msg,
                      self.test_stderr.getvalue())
 def test_remove(self, local_rm_mock, exists_mock, sudo_mock):
     script = ('if [ -f /etc/presto/catalog/tpch.properties ] ; '
               'then rm /etc/presto/catalog/tpch.properties ; '
               'else echo "Could not remove connector \'tpch\'. '
               'No such file \'/etc/presto/catalog/tpch.properties\'"; fi')
     exists_mock.return_value = True
     fabric.api.env.host = 'localhost'
     connector.remove('tpch')
     sudo_mock.assert_called_with(script)
     local_rm_mock.assert_called_with(constants.CONNECTORS_DIR +
                                      '/tpch.properties')
示例#4
0
 def test_remove(self, local_rm_mock, exists_mock, sudo_mock):
     script = ('if [ -f /etc/presto/catalog/tpch.properties ] ; '
               'then rm /etc/presto/catalog/tpch.properties ; '
               'else echo "Could not remove connector \'tpch\'. '
               'No such file \'/etc/presto/catalog/tpch.properties\'"; fi')
     exists_mock.return_value = True
     fabric.api.env.host = 'localhost'
     connector.remove('tpch')
     sudo_mock.assert_called_with(script)
     local_rm_mock.assert_called_with(constants.CONNECTORS_DIR +
                                      '/tpch.properties')