From 5f3c3fb57f48223728548ba8eb46214af03c5299 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 22 Oct 2014 02:27:12 +0800 Subject: [PATCH] Behat can be initialised with Oracle --- mdk/commands/behat.py | 13 +++++++++++-- mdk/moodle.py | 13 ++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/mdk/commands/behat.py b/mdk/commands/behat.py index 8bf8c9f..b24f54c 100644 --- a/mdk/commands/behat.py +++ b/mdk/commands/behat.py @@ -29,7 +29,7 @@ import logging import gzip from time import sleep from ..command import Command -from ..tools import process, ProcessInThread, downloadProcessHook +from ..tools import process, ProcessInThread, downloadProcessHook, question class BehatCommand(Command): @@ -192,8 +192,17 @@ class BehatCommand(Command): # Run cli try: + + # If Oracle, ask the user for a Behat prefix, if not set. + prefix = M.get('behat_prefix') + if M.get('dbtype') == 'oci' and (not prefix or len(prefix) > 2): + while not prefix or len(prefix) > 2: + prefix = question('What prefix would you like to use? (Oracle, max 2 chars)') + else: + prefix = None + logging.info('Initialising Behat, please be patient!') - M.initBehat(switchcompletely=args.switchcompletely) + M.initBehat(switchcompletely=args.switchcompletely, prefix=prefix) logging.info('Behat ready!') # Preparing Behat command diff --git a/mdk/moodle.py b/mdk/moodle.py index b3a7a1d..45fa793 100644 --- a/mdk/moodle.py +++ b/mdk/moodle.py @@ -314,7 +314,7 @@ class Moodle(object): else: raise exception - def initBehat(self, switchcompletely=False): + def initBehat(self, switchcompletely=False, prefix=None): """Initialise the Behat environment""" if self.branch_compare(25, '<'): @@ -330,8 +330,15 @@ class Moodle(object): self.updateConfig('behat_dataroot', behat_dataroot) # Set Behat DB prefix - behat_prefix = 'zbehat_' - self.updateConfig('behat_prefix', behat_prefix) + currentPrefix = self.get('behat_prefix') + behat_prefix = prefix or 'zbehat_' + + if not currentPrefix: + self.updateConfig('behat_prefix', behat_prefix) + elif currentPrefix != behat_prefix and self.get('dbtype') != 'oci': + # Warn that a prefix is already set and we did not change it. + # No warning for Oracle as we need to set it to something else. + logging.warning('Behat prefix not changed, already set to \'%s\', expected \'%s\'.' % (currentPrefix, behat_prefix)) # Switch completely? if self.branch_compare(26, '<'): -- 2.11.0