Created
June 24, 2011 00:55
-
-
Save masaki/1044009 to your computer and use it in GitHub Desktop.
Trac-0.12 and Python-2.4 patch for "Test Manager plugin for Trac"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- testman4trac/trunk/testmanager/api.py.orig 2011-06-18 23:16:34.000000000 +0900 | |
+++ testman4trac/trunk/testmanager/api.py 2011-06-23 18:55:13.000000000 +0900 | |
@@ -85,8 +85,10 @@ | |
if row[0] == 'default': | |
self.default_outcome = row[1].lower() | |
else: | |
- color = row[0].partition('.')[0] | |
- outcome = row[0].partition('.')[2].lower() | |
+ color = row[0].split('.')[0] | |
+ outcome = '' | |
+ if row[0].count('.') > 0: | |
+ outcome = row[0].split('.')[1].lower() | |
caption = row[1] | |
if color not in self.outcomes_by_color: | |
@@ -310,8 +312,10 @@ | |
elif type == 'testplan': | |
req.perm.require('TEST_PLAN_ADMIN') | |
- | |
- catid = path.rpartition('_TT')[2] | |
+ | |
+ catid = '-1' | |
+ if path.count('_TT') > 0: | |
+ catid = path.rsplit('_TT')[1] | |
try: | |
# Add the new test plan in the database | |
@@ -345,13 +349,17 @@ | |
tcIdsList = [tcId] | |
try: | |
- catid = path.rpartition('_TT')[2] | |
+ catid = '-1' | |
+ if path.count('_TT') > 0: | |
+ catid = path.rsplit('_TT')[1] | |
tcat = TestCatalog(self.env, catid) | |
for tcId in tcIdsList: | |
if tcId is not None and tcId != '': | |
old_pagename = tcId | |
- tc_id = tcId.rpartition('_TC')[2] | |
+ tc_id = '-1' | |
+ if tcId.count('_TC') > 0: | |
+ tc_id = tcId.rsplit('_TC')[1] | |
tc = TestCase(self.env, tc_id, tcId) | |
tc.author = author | |
@@ -375,11 +383,13 @@ | |
req.redirect(req.href.wiki(pagename)) | |
# Redirect to test catalog, forcing a page refresh by means of a random request parameter | |
- req.redirect(req.href.wiki(pagename.rpartition('_TC')[0], random=str(datetime.now(utc).microsecond))) | |
+ req.redirect(req.href.wiki(pagename.rsplit('_TC')[0], random=str(datetime.now(utc).microsecond))) | |
elif duplicate and duplicate != '': | |
# Duplicate test case | |
- old_id = tcId.rpartition('_TC')[2] | |
+ old_id = '-1' | |
+ if tcId.count('_TC') > 0: | |
+ old_id = tcId.rsplit('_TC')[1] | |
old_pagename = tcId | |
try: | |
old_tc = TestCase(self.env, old_id, old_pagename) | |
@@ -430,7 +440,9 @@ | |
req.perm.require('TEST_PLAN_ADMIN') | |
planid = req.args.get('planid') | |
- catid = path.rpartition('_TT')[2] | |
+ catid = '-1' | |
+ if path.count('_TT') > 0: | |
+ catid = path.rsplit('_TT')[1] | |
self.env.log.debug("About to delete test plan %s on catalog %s" % (planid, catid)) | |
--- testman4trac/trunk/testmanager/macros.py.orig 2011-06-18 23:16:34.000000000 +0900 | |
+++ testman4trac/trunk/testmanager/macros.py 2011-06-23 18:57:43.000000000 +0900 | |
@@ -206,12 +206,17 @@ | |
# Determine current catalog name | |
cat_name = 'TC' | |
if curpage.find('_TC') >= 0: | |
- cat_name = curpage.rpartition('_TC')[0].rpartition('_')[2] | |
+ if curpage.rsplit('_TC')[0].count('_') > 0: | |
+ cat_name = curpage.rsplit('_TC')[0].rsplit('_')[1] | |
elif not curpage == 'TC': | |
- cat_name = curpage.rpartition('_')[2] | |
+ if curpage.count('_') > 0: | |
+ cat_name = curpage.rsplit('_')[1] | |
# Create the breadcrumb model | |
- path_name = curpage.partition('TC_')[2] | |
+ path_name = '' | |
+ if curpage.count('TC_') > 0: | |
+ path_name = curpage.split('TC_')[1] | |
+ | |
tokens = path_name.split("_") | |
curr_path = 'TC' | |
@@ -240,10 +245,12 @@ | |
# Determine current catalog name | |
cat_name = 'TC' | |
if curpage.find('_TC') >= 0: | |
- cat_name = curpage.rpartition('_TC')[0].rpartition('_')[2] | |
+ if curpage.rsplit('_TC')[0].count('_') > 0: | |
+ cat_name = curpage.rsplit('_TC')[0].rsplit('_')[1] | |
#cat_id = '-1' | |
elif not curpage == 'TC': | |
- cat_name = curpage.rpartition('_')[2] | |
+ if curpage.count('_') > 0: | |
+ cat_name = curpage.rsplit('_')[1] | |
if cat_name == 'TC': | |
mode = 'tree' | |
@@ -258,7 +265,10 @@ | |
subpage = WikiPage(env, subpage_name) | |
subpage_title = get_page_title(subpage.text) | |
- path_name = subpage_name.partition(curpage+'_')[2] | |
+ path_name = '' | |
+ if subpage_name.count(curpage+'_') > 0: | |
+ path_name = subpage_name.split(curpage+'_')[1] | |
+ | |
tokens = path_name.split("_") | |
parent = components | |
ltok = len(tokens) | |
@@ -281,7 +291,9 @@ | |
else: | |
# It is a test case page | |
- tc_id = tc.rpartition('TC')[2] | |
+ tc_id = '-1' | |
+ if tc.count('TC') > 0: | |
+ tc_id = tc.rsplit('TC')[1] | |
if subpage_title in parent['childrenT']: | |
unique_idx += 1 | |
@@ -367,9 +379,11 @@ | |
# Determine current catalog name | |
cat_name = 'TC' | |
if curpage.find('_TC') >= 0: | |
- cat_name = curpage.rpartition('_TC')[0].rpartition('_')[2] | |
+ if curpage.rsplit('_TC')[0].count('_') > 0: | |
+ cat_name = curpage.rsplit('_TC')[0].rsplit('_')[1] | |
elif not curpage == 'TC': | |
- cat_name = curpage.rpartition('_')[2] | |
+ if curpage.count('_') > 0: | |
+ cat_name = curpage.rsplit('_')[1] | |
tp = TestPlan(env, planid) | |
@@ -382,7 +396,9 @@ | |
subpage = WikiPage(env, subpage_name) | |
subpage_title = get_page_title(subpage.text) | |
- path_name = subpage_name.partition(curpage+'_')[2] | |
+ path_name = '' | |
+ if subpage_name.count(curpage+'_') > 0: | |
+ path_name = subpage_name.split(curpage+'_')[1] | |
tokens = path_name.split("_") | |
parent = components | |
ltok = len(tokens) | |
@@ -405,7 +421,9 @@ | |
else: | |
# It is a test case page | |
- tc_id = tc.partition('TC')[2] | |
+ tc_id = '-1' | |
+ if tc.count('TC') > 0: | |
+ tc_id = tc.split('TC')[1] | |
tcip = TestCaseInPlan(env, tc_id, planid) | |
if tcip.exists: | |
for ts, author, status in tcip.list_history(): | |
@@ -509,14 +527,17 @@ | |
def _build_testplan_list(env, req, curpage, mode, fulldetails): | |
# Determine current catalog name | |
cat_name = 'TC' | |
- catid = '-1' | |
if curpage.find('_TC') >= 0: | |
- cat_name = curpage.rpartition('_TC')[0].rpartition('_')[2] | |
- catid = cat_name.rpartition('TT')[2] | |
+ if curpage.rsplit('_TC')[0].count('_') > 0: | |
+ cat_name = curpage.rsplit('_TC')[0].rsplit('_')[1] | |
elif not curpage == 'TC': | |
- cat_name = curpage.rpartition('_')[2] | |
- catid = cat_name.rpartition('TT')[2] | |
- | |
+ if curpage.count('_') > 0: | |
+ cat_name = curpage.rsplit('_')[1] | |
+ | |
+ catid = '-1' | |
+ if cat_name.count('TT') > 0: | |
+ catid = cat_name.rsplit('TT')[1] | |
+ | |
if 'TEST_PLAN_ADMIN' in req.perm: | |
show_delete_button = True | |
else: | |
@@ -663,7 +684,9 @@ | |
testmanagersystem = TestManagerSystem(env) | |
tc_statuses = testmanagersystem.get_tc_statuses_by_name() | |
- tc_id = curpage.rpartition('_TC')[2] | |
+ tc_id = '-1' | |
+ if curpage.count('_TC') > 0: | |
+ tc_id = curpage.rsplit('_TC')[1] | |
tcip = TestCaseInPlan(env, tc_id, planid) | |
if tcip.exists: | |
@@ -711,7 +734,9 @@ | |
# Custom testcatalog columns | |
if custom_ctx['testcatalog'][0]: | |
- tcat_id = comp['id'].rpartition('TT')[2] | |
+ tcat_id = '-1' | |
+ if comp['id'].count('TT') > 0: | |
+ tcat_id = comp['id'].rsplit('TT')[1] | |
tcat = TestCatalog(env, tcat_id) | |
text += _get_custom_fields_columns(tcat, custom_ctx['testcatalog'][1]) | |
@@ -807,8 +832,10 @@ | |
tc_statuses = testmanagersystem.get_tc_statuses_by_name() | |
tc_statuses_by_color = testmanagersystem.get_tc_statuses_by_color() | |
- tc_id = curpage.rpartition('_TC')[2] | |
- | |
+ tc_id = '-1' | |
+ if curpage.count('_TC') > 0: | |
+ tc_id = curpage.rsplit('_TC')[1] | |
+ | |
tcip = TestCaseInPlan(env, tc_id, planid) | |
if tcip.exists: | |
status = tcip['status'].lower() | |
@@ -877,8 +904,10 @@ | |
testmanagersystem = TestManagerSystem(env) | |
tc_statuses = testmanagersystem.get_tc_statuses_by_name() | |
- tc_id = curpage.rpartition('_TC')[2] | |
- | |
+ tc_id = '-1' | |
+ if curpage.count('_TC') > 0: | |
+ tc_id = curpage.rsplit('_TC')[1] | |
+ | |
tcip = TestCaseInPlan(env, tc_id, planid) | |
text = '<form id="testCaseHistory"><fieldset id="testCaseHistoryFields" class="collapsed"><legend class="foldable" style="cursor: pointer;"><a href="#no3" onclick="expandCollapseSection(\'testCaseHistoryFields\')">'+_("Status change history")+'</a></legend>' | |
--- testman4trac/trunk/testmanager/model.py.orig 2011-06-18 23:16:34.000000000 +0900 | |
+++ testman4trac/trunk/testmanager/model.py 2011-06-23 18:53:41.000000000 +0900 | |
@@ -133,14 +133,15 @@ | |
Returns the catalog containing this test catalog, or None if its a root catalog. | |
""" | |
page_name = self.values['page_name'] | |
- cat_page = page_name.rpartition('_TT')[0] | |
- | |
+ cat_page = page_name.rsplit('_TT')[0] | |
if cat_page == 'TC': | |
return None | |
- else: | |
- cat_id = page_name.rpartition('TT')[0].page_name.rpartition('TT')[2].rpartition('_')[0] | |
- return TestCatalog(self.env, cat_id, cat_page) | |
+ cat_id = '-1' | |
+ if page_name.count('TT') > 0: | |
+ cat_id = page_name.rsplit('TT')[1].rsplit('_')[0] | |
+ | |
+ return TestCatalog(self.env, cat_id, cat_page) | |
def list_subcatalogs(self, db=None): | |
""" | |
@@ -153,7 +154,8 @@ | |
for tc in tc_search.list_matching_objects(exact_match=False, db=db): | |
# Only return direct sub-catalogs and exclude test cases | |
- if cat_re.match(tc['page_name'].partition(self.values['page_name']+'_')[2]) : | |
+ pat = tc['page_name'].split(self.values['page_name']+'_') | |
+ if len(pat) > 0 and cat_re.match(pat[1]): | |
yield tc | |
def list_testcases(self, plan_id=None, db=None): | |
@@ -205,8 +207,10 @@ | |
Returns the catalog containing this test case. | |
""" | |
page_name = self.values['page_name'] | |
- cat_id = page_name.rpartition('TT')[2].rpartition('_')[0] | |
- cat_page = page_name.rpartition('_TC')[0] | |
+ cat_page = page_name.rsplit('_TC')[0] | |
+ cat_id = '-1' | |
+ if page_name.count('TT') > 0: | |
+ cat_id = page_name.rsplit('TT')[1].rsplit('_')[0] | |
return TestCatalog(self.env, cat_id, cat_page) | |
--- testman4trac/trunk/testmanager/stats.py.orig 2011-06-18 23:16:34.000000000 +0900 | |
+++ testman4trac/trunk/testmanager/stats.py 2011-06-23 16:41:49.000000000 +0900 | |
@@ -190,8 +190,11 @@ | |
grab_testplan = req.args.get('testplan') | |
if grab_testplan and not grab_testplan == "__all": | |
- testplan = grab_testplan.partition('|')[0] | |
- catpath = grab_testplan.partition('|')[2] | |
+ if grab_testplan.count('|') > 0: | |
+ testplan,catpath = grab_testplan.split('|') | |
+ else: | |
+ testplan = grab_testplan | |
+ cat_path = '' | |
today = datetime.today() | |
today = today.replace(tzinfo = req.tz)+timedelta(2) | |
--- testman4trac/trunk/testmanager/util.py.orig 2011-06-18 23:16:34.000000000 +0900 | |
+++ testman4trac/trunk/testmanager/util.py 2011-06-23 18:36:40.000000000 +0900 | |
@@ -12,6 +12,8 @@ | |
def get_page_description(text): | |
- return text.partition(CRLF)[2] | |
+ if text.count(CRLF) > 0: | |
+ return text.split(CRLF)[1] | |
+ else: | |
+ return text | |
- | |
--- testman4trac/trunk/testmanager/wiki.py.orig 2011-06-18 23:16:34.000000000 +0900 | |
+++ testman4trac/trunk/testmanager/wiki.py 2011-06-23 19:14:19.000000000 +0900 | |
@@ -76,7 +76,7 @@ | |
# Only Test Case deletion is supported. | |
# Deleting a Test Catalog will not delete all of the inner | |
# Test Cases. | |
- tc_id = page.name.rpartition('_TC')[2] | |
+ tc_id = page.name.rsplit('_TC')[1] | |
tc = TestCase(self.env, tc_id) | |
if tc.exists: | |
tc.delete(del_wiki_page=False) | |
@@ -119,8 +119,12 @@ | |
def _catalog_wiki_view(self, req, formatter, page_name, stream): | |
path_name = req.path_info | |
- cat_name = path_name.rpartition('/')[2] | |
- cat_id = cat_name.rpartition('TT')[2] | |
+ cat_name = '' | |
+ if path_name.count('/') > 0: | |
+ cat_name = path_name.rsplit('/')[-1] | |
+ cat_id = '-1' | |
+ if cat_name.count('TT') > 0: | |
+ cat_id = cat_name.rsplit('TT')[-1] | |
mode = req.args.get('mode', 'tree') | |
fulldetails = req.args.get('fulldetails', 'False') | |
@@ -253,9 +257,13 @@ | |
def _testplan_wiki_view(self, req, formatter, page_name, planid, stream): | |
path_name = req.path_info | |
- cat_name = path_name.rpartition('/')[2] | |
- cat_id = cat_name.rpartition('TT')[2] | |
- | |
+ cat_name = '' | |
+ if path_name.count('/') > 0: | |
+ cat_name = path_name.rsplit('/')[-1] | |
+ cat_id = '-1' | |
+ if cat_name.count('TT') > 0: | |
+ cat_id = cat_name.rsplit('TT')[-1] | |
+ | |
mode = req.args.get('mode', 'tree') | |
fulldetails = req.args.get('fulldetails', 'False') | |
@@ -306,7 +314,7 @@ | |
def _testcase_wiki_view(self, req, formatter, planid, page_name, stream): | |
tc_name = page_name | |
- cat_name = page_name.partition('_TC')[0] | |
+ cat_name = page_name.split('_TC')[0] | |
mode = req.args.get('mode', 'tree') | |
fulldetails = req.args.get('fulldetails', 'False') | |
@@ -314,8 +322,10 @@ | |
has_status = False | |
plan_name = '' | |
- | |
- tc_id = tc_name.partition('_TC')[2] | |
+ | |
+ tc_id = '-1' | |
+ if tc_name.count('_TC') > 0: | |
+ tc_id = tc_name.split('_TC')[1] | |
test_case = TestCase(self.env, tc_id, tc_name) | |
tmmodelprovider = GenericClassModelProvider(self.env) | |
@@ -360,7 +370,7 @@ | |
def _testcase_in_plan_wiki_view(self, req, formatter, planid, page_name, stream): | |
tc_name = page_name | |
- cat_name = page_name.partition('_TC')[0] | |
+ cat_name = page_name.split('_TC')[0] | |
mode = req.args.get('mode', 'tree') | |
fulldetails = req.args.get('fulldetails', 'False') | |
@@ -368,8 +378,10 @@ | |
has_status = True | |
tp = TestPlan(self.env, planid) | |
plan_name = tp['name'] | |
- | |
- tc_id = tc_name.partition('_TC')[2] | |
+ | |
+ tc_id = '-1' | |
+ if tc_name.count('_TC') > 0: | |
+ tc_id = tc_name.split('_TC')[1] | |
# Note that assigning a default status here is functional. If the tcip actually exists, | |
# the real status will override this value. | |
tcip = TestCaseInPlan(self.env, tc_id, planid, page_name, TestManagerSystem(self.env).get_default_tc_status()) | |
@@ -412,7 +424,7 @@ | |
def _get_breadcrumb_markup(self, formatter, planid, page_name, mode='tree', fulldetails='False'): | |
if planid and not planid == '-1': | |
# We are in the context of a test plan | |
- if not page_name.rpartition('_TC')[2] == '': | |
+ if page_name.count('_TC') > 0: | |
# It's a test case in plan | |
tp = TestPlan(self.env, planid) | |
catpath = tp['page_name'] | |
--- testman4trac/trunk/testmanager/workflow.py.orig 2011-06-18 23:16:34.000000000 +0900 | |
+++ testman4trac/trunk/testmanager/workflow.py 2011-06-23 18:35:45.000000000 +0900 | |
@@ -77,14 +77,17 @@ | |
if page_name.find('_TC') >= 0: | |
if not planid or planid == '-1': | |
realm = 'testcase' | |
- key = {'id': page_name.rpartition('_TC')[2]} | |
+ key = {'id': page_name.rsplit('_TC')[1]} | |
else: | |
realm = 'testcaseinplan' | |
- key = {'id': page_name.rpartition('_TC')[2], 'planid': planid} | |
+ key = {'id': page_name.rsplit('_TC')[1], 'planid': planid} | |
else: | |
if not planid or planid == '-1': | |
realm = 'testcatalog' | |
- key = {'id': page_name.rpartition('_TT')[2]} | |
+ if page_name.count('_TT') > 0: | |
+ key = {'id': page_name.rsplit('_TT')[1]} | |
+ else: | |
+ key = {'id': '-1'} | |
else: | |
realm = 'testplan' | |
key = {'id': planid} | |
--- tracgenericclass/trunk/tracgenericclass/util.py.orig 2011-06-18 23:16:34.000000000 +0900 | |
+++ tracgenericclass/trunk/tracgenericclass/util.py 2011-06-23 18:13:30.000000000 +0900 | |
@@ -136,14 +136,17 @@ | |
def get_dictionary_from_string(str): | |
result = {} | |
- sub = str.partition('{')[2].rpartition('}')[0] | |
- tokens = sub.split(",") | |
+ if str.count('{') > 0: | |
+ tokens = str.split('{')[1].rsplit('}')[0].split(',') | |
+ else: | |
+ tokens = [] | |
for tok in tokens: | |
- name = remove_quotes(tok.partition(':')[0]) | |
- value = remove_quotes(tok.partition(':')[2]) | |
- | |
- result[name] = value | |
+ if tok.count(':') > 0: | |
+ name, value = tok.split(':') | |
+ result[remove_quotes(name)] = remove_quotes(value) | |
+ else: | |
+ result[tok] = '' | |
return result | |
@@ -164,7 +167,10 @@ | |
def remove_quotes(str, quote='\''): | |
- return str.partition(quote)[2].rpartition(quote)[0] | |
+ if str.count(quote) > 0: | |
+ return str.split(quote)[1].rsplit(quote)[0] | |
+ else: | |
+ return str | |
def compatible_domain_functions(domain, function_name_list): | |
--- tracgenericworkflow/trunk/tracgenericworkflow/api.py.orig 2011-06-18 23:16:34.000000000 +0900 | |
+++ tracgenericworkflow/trunk/tracgenericworkflow/api.py 2011-06-23 13:49:56.000000000 +0900 | |
@@ -134,7 +134,7 @@ | |
for section in self.config.sections(): | |
if section.find('-resource_workflow') > 0: | |
self.log.debug("ResourceWorkflowSystem - parsing config section %s" % section) | |
- realm = section.partition('-')[0] | |
+ realm = section.split('-')[0] | |
raw_actions = list(self.config.options(section)) | |
self.actions[realm] = parse_workflow_config(raw_actions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment