[commit] r1738 - in trunk: GME/XmlBackEnd Tests/GPyUnit Tests/GPyUnit/util
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Wed Dec 7 19:16:27 CST 2011
Author: ksmyth
Date: Wed Dec 7 19:16:27 2011
New Revision: 1738
Log:
Test MU + SVN
Modified:
trunk/GME/XmlBackEnd/CoreXmlFile.cpp
trunk/GME/XmlBackEnd/OperOptions.cpp
trunk/GME/XmlBackEnd/OperOptions.h
trunk/Tests/GPyUnit/test_parser.py
trunk/Tests/GPyUnit/test_registry.py
trunk/Tests/GPyUnit/util/__init__.py
Modified: trunk/GME/XmlBackEnd/CoreXmlFile.cpp
==============================================================================
--- trunk/GME/XmlBackEnd/CoreXmlFile.cpp Wed Dec 7 19:16:09 2011 (r1737)
+++ trunk/GME/XmlBackEnd/CoreXmlFile.cpp Wed Dec 7 19:16:27 2011 (r1738)
@@ -5276,7 +5276,9 @@
}
std::string comment;
CCommitDialog cDlg;
- if (cDlg.DoModal() == IDOK) {
+ if (m_userOpts.m_autoCommit) {
+ comment = "AutoCommit";
+ } else if (cDlg.DoModal() == IDOK) {
CT2CA comment_str(cDlg.m_comment);
comment = comment_str;
}
Modified: trunk/GME/XmlBackEnd/OperOptions.cpp
==============================================================================
--- trunk/GME/XmlBackEnd/OperOptions.cpp Wed Dec 7 19:16:09 2011 (r1737)
+++ trunk/GME/XmlBackEnd/OperOptions.cpp Wed Dec 7 19:16:27 2011 (r1738)
@@ -6,6 +6,7 @@
// OperatingOptions
OperatingOptions::OperatingOptions()
: m_defCheckInOnSave( false)
+, m_autoCommit(false)
, m_defCheckOutOnAction( false)
, m_alwaysFullLock( false)
, m_onDeleteAlwaysFullLock( false)
@@ -33,11 +34,17 @@
, m_prefUrl()
, m_prefAccessMethod()
{
+ const char* userprofile = getenv("USERPROFILE");
+ if (userprofile)
+ {
+ loadSettings(userprofile, "GME_MU_config.opt");
+ }
}
void OperatingOptions::reset()
{
m_defCheckInOnSave = false;
+ m_autoCommit = false;
m_defCheckOutOnAction = false;
m_alwaysFullLock = false;
m_onDeleteAlwaysFullLock= false;
@@ -69,6 +76,11 @@
void OperatingOptions::load( const std::string& p_folder)
{
reset();
+ const char* userprofile = getenv("USERPROFILE");
+ if (userprofile)
+ {
+ loadSettings(userprofile, "GME_MU_config.opt");
+ }
loadSettings( p_folder, m_sysConfName);
loadSettings( p_folder, m_usrConfName);
}
@@ -125,6 +137,10 @@
{
m_defCheckInOnSave = parseBool( line, "DefCheckInOnSave");//m_defCheckInOnSave = true;
}
+ else if( 0 == line.find("AutoCommit"))//=true"))
+ {
+ m_autoCommit = parseBool(line, "AutoCommit");
+ }
else if( 0 == line.find( "DefCheckOutOnAction"))//=true"))
{
m_defCheckOutOnAction = parseBool( line, "DefCheckOutOnAction"); //m_defCheckOutOnAction = true;
Modified: trunk/GME/XmlBackEnd/OperOptions.h
==============================================================================
--- trunk/GME/XmlBackEnd/OperOptions.h Wed Dec 7 19:16:09 2011 (r1737)
+++ trunk/GME/XmlBackEnd/OperOptions.h Wed Dec 7 19:16:27 2011 (r1738)
@@ -19,6 +19,7 @@
static const char * m_sysConfDefContentsSvn;
static const char * m_sysConfDefContentsPlain;
bool m_defCheckInOnSave;
+ bool m_autoCommit;
bool m_defCheckOutOnAction;
bool m_alwaysFullLock;
bool m_onDeleteAlwaysFullLock;
Modified: trunk/Tests/GPyUnit/test_parser.py
==============================================================================
--- trunk/Tests/GPyUnit/test_parser.py Wed Dec 7 19:16:09 2011 (r1737)
+++ trunk/Tests/GPyUnit/test_parser.py Wed Dec 7 19:16:27 2011 (r1738)
@@ -1,5 +1,10 @@
import unittest
import os
+import GPyUnit.util
+
+def _adjacent_file(file):
+ import os.path
+ return os.path.join(os.path.dirname(os.path.abspath(__file__)), file)
class TestParser(unittest.TestCase):
def test_ParseMetaGME(self):
@@ -10,12 +15,18 @@
(paradigm, parversion, parguid, basename, ver) = xme.GetXMLInfo(inputfile)
mga = win32com.client.DispatchEx("Mga.MgaProject")
- mga.Create("MGA=tmp.mga", paradigm)
+ mga.Create(self.connstr, paradigm)
xme.ParseProject(mga, inputfile)
mga.Save()
mga.Close()
del(mga)
del(xme)
+
+ @property
+ def connstr(self):
+ return "MGA=" + _adjacent_file("tmp.mga")
+
+GPyUnit.util.MUGenerator(globals(), TestParser)
if __name__ == "__main__":
unittest.main()
Modified: trunk/Tests/GPyUnit/test_registry.py
==============================================================================
--- trunk/Tests/GPyUnit/test_registry.py Wed Dec 7 19:16:09 2011 (r1737)
+++ trunk/Tests/GPyUnit/test_registry.py Wed Dec 7 19:16:27 2011 (r1738)
@@ -173,9 +173,7 @@
self.project.RootFolder.ChildFolders
import GPyUnit.util
-class TestMURegistry(GPyUnit.util.MUTestMixin, TestRegistry):
- def __init__(self, name, **kwds):
- super(TestMURegistry, self).__init__(name, **kwds)
+GPyUnit.util.MUGenerator(globals(), TestRegistry)
if __name__ == "__main__":
unittest.main()
Modified: trunk/Tests/GPyUnit/util/__init__.py
==============================================================================
--- trunk/Tests/GPyUnit/util/__init__.py Wed Dec 7 19:16:09 2011 (r1737)
+++ trunk/Tests/GPyUnit/util/__init__.py Wed Dec 7 19:16:27 2011 (r1738)
@@ -1,4 +1,6 @@
+import os
+import sys
import unittest
class disable_early_binding(object):
@@ -29,6 +31,26 @@
import gme
gme.register_if_not_registered(xmpfile)
+# From pathutils by Michael Foord: http://www.voidspace.org.uk/python/pathutils.html
+def onerror(func, path, exc_info):
+ """
+ Error handler for ``shutil.rmtree``.
+
+ If the error is due to an access error (read only file)
+ it attempts to add write permission and then retries.
+
+ If the error is for another reason it re-raises the error.
+
+ Usage : ``shutil.rmtree(path, onerror=onerror)``
+ """
+ import stat
+ if not os.access(path, os.W_OK):
+ # Is the error an access error ?
+ os.chmod(path, stat.S_IWUSR)
+ func(path)
+ else:
+ raise
+
class MUTestMixin(unittest.TestCase): # need to inherit from TestCase so __mro__ works, since TestCase.__init__ doesn't call super().__init__
def __init__(self, name, **kwds):
super(MUTestMixin, self).__init__(name, **kwds)
@@ -41,8 +63,39 @@
if os.path.isdir(self.mgxdir):
import shutil
assert len(self.mgxdir) > 10 # sanity check
- shutil.rmtree(self.mgxdir)
+ shutil.rmtree(self.mgxdir, onerror=onerror)
@property
def connstr(self):
return "MGX=\"" + self.mgxdir + "\""
+
+class MUSVNTestMixin(MUTestMixin):
+ def setUp(self):
+ super(MUSVNTestMixin, self).setUp()
+ svn_file = os.path.abspath(os.path.join(os.path.dirname(__file__), "MUTestRepo"))
+ self.svn_url = "file:///" + svn_file
+ if os.path.isdir(svn_file):
+ import shutil
+ assert len(svn_file) > 10 # sanity check
+ shutil.rmtree(svn_file, onerror=onerror)
+ import subprocess
+ subprocess.check_call(['svnadmin', 'create', svn_file])
+ with open(os.environ['USERPROFILE'] + '\\GME_MU_config.opt', 'w') as file:
+ file.write('''
+AutomaticLogin=true
+UseAccountInfo=true
+AutoCommit=true
+account=''' + os.environ['USERNAME'])
+
+ @property
+ def connstr(self):
+ print 'opts: ' + self.opts()
+ return "MGX=\"" + self.mgxdir + "\" svn=\"" + self.svn_url + "\"" + self.opts()
+
+def MUGenerator(module, test):
+ module[test.__name__ + "MU"] = type(test.__name__ + "MU", (MUTestMixin, test), {})
+ #return
+ def opts_f(opts):
+ return lambda self: opts
+ for name, opts in (('MUSVN', ''), ('MUSVNHashed', ' hash=\"true\" hval=\"256\"')):
+ module[test.__name__ + name] = type(test.__name__ + name, (MUSVNTestMixin, test), {'opts': opts_f(opts)})
More information about the gme-commit
mailing list