Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amer
erp5
Commits
0ac82b7d
Commit
0ac82b7d
authored
Jun 28, 2017
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: an experimental test suite to run business template coding style checks
parent
0a1a952f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
0 deletions
+106
-0
product/ERP5Type/tests/CodingStyleTest.py
product/ERP5Type/tests/CodingStyleTest.py
+90
-0
tests/__init__.py
tests/__init__.py
+16
-0
No files found.
product/ERP5Type/tests/CodingStyleTest.py
0 → 100644
View file @
0ac82b7d
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
os
import
unittest
from
glob
import
glob
from
Products.ERP5Type.tests.CodingStyleTestCase
import
CodingStyleTestCase
class
CodingStyleTest
(
CodingStyleTestCase
):
"""Run a coding style test for business template defined by
TESTED_BUSINESS_TEMPLATE environment variable, that is set by
ERP5BusinessTemplateCodingStyleTestSuite in test/__init__.py
"""
def
getBusinessTemplateList
(
self
):
# install erp5_administration to check with tools from erp5_administration
return
(
'erp5_administration'
,
self
.
tested_business_template
)
def
_installBusinessTemplateList
(
self
,
bt_list
,
update_repository_bt_list
=
True
,
*
args
,
**
kwargs
):
"""Install depencencies automatically
taken from runUnitTest._ZodbTestComponentBootstrapOnly.
"""
template_tool
=
self
.
portal
.
portal_templates
from
Products.ERP5.ERP5Site
import
getBootstrapDirectory
bt5_path_list
=
[
os
.
environ
.
get
(
'erp5_tests_bootstrap_path'
)
or
getBootstrapDirectory
()]
for
path
in
os
.
environ
[
'erp5_tests_bt5_path'
].
split
(
','
):
if
os
.
path
.
exists
(
os
.
path
.
join
(
path
,
"bt5list"
)):
bt5_path_list
.
append
(
path
)
for
path
in
glob
(
os
.
path
.
join
(
path
,
"*"
,
"bt5list"
)):
bt5_path_list
.
append
(
os
.
path
.
dirname
(
path
))
template_tool
.
updateRepositoryBusinessTemplateList
(
bt5_path_list
)
url_bt_tuple_list
=
[
(
'%s/%s'
%
(
repository
,
bt_title
),
bt_title
)
for
repository
,
bt_title
in
template_tool
.
resolveBusinessTemplateListDependency
(
[
x
[
1
]
for
x
in
bt_list
],
with_test_dependency_list
=
True
)]
return
super
(
CodingStyleTest
,
self
).
_installBusinessTemplateList
(
url_bt_tuple_list
,
*
args
,
**
kwargs
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
tested_business_template
=
os
.
environ
[
'TESTED_BUSINESS_TEMPLATE'
]
testclass
=
type
(
'CodingStyleTest %s'
%
tested_business_template
,
(
CodingStyleTest
,
),
{
'tested_business_template'
:
tested_business_template
})
suite
.
addTest
(
unittest
.
makeSuite
(
testclass
))
return
suite
tests/__init__.py
View file @
0ac82b7d
...
@@ -167,3 +167,19 @@ class ERP5_XHTML_Only(_ERP5):
...
@@ -167,3 +167,19 @@ class ERP5_XHTML_Only(_ERP5):
def
_getAllTestList
(
self
):
def
_getAllTestList
(
self
):
path
=
sys
.
path
[
0
]
path
=
sys
.
path
[
0
]
return
[
'%s/product/ERP5/tests/testXHTML.py'
%
path
]
return
[
'%s/product/ERP5/tests/testXHTML.py'
%
path
]
class
ERP5BusinessTemplateCodingStyleTestSuite
(
_ERP5
):
"""Run coding style test on all business templates.
"""
def
getTestList
(
self
):
test_list
=
[]
path
=
sys
.
path
[
0
]
for
business_template_path
in
glob
(
'%s/bt5/*'
%
path
):
if
os
.
path
.
isdir
(
business_template_path
):
test_list
.
append
(
os
.
path
.
basename
(
business_template_path
))
return
test_list
def
run
(
self
,
full_test
):
return
self
.
runUnitTest
(
'CodingStyleTest'
,
TESTED_BUSINESS_TEMPLATE
=
full_test
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment