Merge lp:~compiz-team/compiz-compizconfig-python/compiz-compizconfig-python.fix_874799 into lp:compiz-compizconfig-python

Proposed by Sam Spilsbury
Status: Merged
Approved by: Tim Penhey
Approved revision: 174
Merged at revision: 168
Proposed branch: lp:~compiz-team/compiz-compizconfig-python/compiz-compizconfig-python.fix_874799
Merge into: lp:compiz-compizconfig-python
Diff against target: 226 lines (+130/-4)
9 files modified
CMakeLists.txt (+13/-0)
setup.py (+26/-2)
src/compizconfig.pyx (+4/-2)
tests/__init__.py (+11/-0)
tests/compiz_config_test.py (+11/-0)
tests/test_backend.py (+15/-0)
tests/test_plugin.py (+17/-0)
tests/test_profile.py (+12/-0)
tests/test_setting.py (+21/-0)
To merge this branch: bzr merge lp:~compiz-team/compiz-compizconfig-python/compiz-compizconfig-python.fix_874799
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+79454@code.launchpad.net

Description of the change

To post a comment you must log in.
167. By Sam Spilsbury

Fix conflicts

Revision history for this message
Tim Penhey (thumper) wrote :

Are there any tests for this project at all?

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

CCSM is a testcase ;-)

I think it might be useful to have a simple python script that excersizes all the bindings.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

(manual testcase: open ccsm and go to the profiles section and there will be no "garbage" profiles there.

Revision history for this message
Tim Penhey (thumper) :
review: Approve
168. By Sam Spilsbury

Added some tests

169. By Sam Spilsbury

Added a test target to distutils setup.py

170. By Sam Spilsbury

Added some CTest wrapper around the distutils testing stuff

171. By Sam Spilsbury

Added a simple test for CCSPlugin

172. By Sam Spilsbury

Added Backend test

173. By Sam Spilsbury

Remove useless line from setup.py

174. By Sam Spilsbury

Added test for Setting

Revision history for this message
Tim Penhey (thumper) wrote :

Thanks Sam. The world will thank you :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2011-07-08 05:59:37 +0000
3+++ CMakeLists.txt 2011-11-10 23:56:24 +0000
4@@ -29,6 +29,19 @@
5 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
6 COMMENT "Uninstalling Python Files")
7
8+find_program (PYTHON_EXECUTABLE python)
9+mark_as_advanced (FORCE PYTHON_EXECUTABLE)
10+
11+file (GLOB PYTHON_TESTS "tests/test_*.py")
12+
13+if (PYTHON_EXECUTABLE)
14+ foreach (PYTHON_TEST_FILE ${PYTHON_TESTS})
15+ get_filename_component (PYTHON_TEST ${PYTHON_TEST_FILE} NAME_WE)
16+ message (STATUS "Adding test " ${PYTHON_TEST})
17+ add_test (NAME ${PYTHON_TEST} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests" COMMAND ${PYTHON_EXECUTABLE} -m unittest ${PYTHON_TEST})
18+ endforeach (PYTHON_TEST_FILE)
19+endif (PYTHON_EXECUTABLE)
20+
21 compiz_print_configure_header ("CompizConfig Python")
22 compiz_print_configure_footer ()
23
24
25=== modified file 'setup.py'
26--- setup.py 2011-02-18 07:29:33 +0000
27+++ setup.py 2011-11-10 23:56:24 +0000
28@@ -1,5 +1,5 @@
29 # -*- coding: utf-8 -*-
30-from distutils.core import setup
31+from distutils.core import setup, Command
32 from distutils.command.build import build as _build
33 from distutils.command.install import install as _install
34 from distutils.command.install_data import install_data as _install_data
35@@ -8,6 +8,9 @@
36 import os
37 import subprocess
38
39+import unittest
40+import os
41+
42 # If src/compizconfig.pyx exists, build using Cython
43 if os.path.exists ("src/compizconfig.pyx"):
44 from Cython.Distutils import build_ext
45@@ -128,6 +131,26 @@
46 self.filelist.exclude_pattern ("src/compizconfig.pyx")
47 self.filelist.append ("src/compizconfig.c")
48
49+class test (Command):
50+ description = "run tests"
51+ user_options = []
52+
53+ def initialize_options (self):
54+ self.cwd = None
55+
56+ def finalize_options (self):
57+ self.cwd = os.getcwd ()
58+
59+ def run (self):
60+ assert os.getcwd () == self.cwd, 'Must be in package root: %s' % self.cwd
61+ loader = unittest.TestLoader ()
62+
63+ tests = loader.discover (os.getcwd (), pattern='test*')
64+ result = unittest.TestResult ()
65+
66+ unittest.TextTestRunner (verbosity=2).run (tests)
67+
68+
69 setup (
70 name = "compizconfig-python",
71 version = version,
72@@ -140,7 +163,8 @@
73 "install" : install,
74 "install_data" : install_data,
75 "build_ext" : build_ext,
76- "sdist" : sdist},
77+ "sdist" : sdist,
78+ "test" : test},
79 ext_modules=[
80 Extension ("compizconfig", [ext_module_src],
81 **pkgconfig("libcompizconfig"))
82
83=== modified file 'src/compizconfig.pyx'
84--- src/compizconfig.pyx 2011-08-05 13:31:11 +0000
85+++ src/compizconfig.pyx 2011-11-10 23:56:24 +0000
86@@ -303,7 +303,7 @@
87 '''General settings handling'''
88 cdef extern Bool ccsSetValue (CCSSetting * setting,
89 CCSSettingValue * value,
90- Bool processChanged)
91+ Bool processChanged)
92 cdef extern void ccsFreeSettingValue (CCSSettingValue * value)
93 cdef extern CCSSettingValueList * ccsSettingValueListAppend (
94 CCSSettingValueList * l,
95@@ -1180,10 +1180,12 @@
96 self.profiles = {}
97 self.currentProfile = Profile (self, ccsGetProfile (self.ccsContext))
98 cdef CCSStringList * profileList
99+ cdef CCSString * profileNameString
100 cdef char * profileName
101 profileList = ccsGetExistingProfiles (self.ccsContext)
102 while profileList != NULL:
103- profileName = <char *> profileList.data
104+ profileNameString = <CCSString *> profileList.data
105+ profileName = <char *> profileNameString.value
106 self.profiles[profileName] = Profile (self, profileName)
107 profileList = profileList.next
108
109
110=== added directory 'tests'
111=== added file 'tests/__init__.py'
112--- tests/__init__.py 1970-01-01 00:00:00 +0000
113+++ tests/__init__.py 2011-11-10 23:56:24 +0000
114@@ -0,0 +1,11 @@
115+import unittest
116+import compizconfig
117+import os
118+
119+def load_tests (loader, tests, pattern):
120+ tests = loader.discover (os.getcwd (), pattern='test_*.py')
121+ return tests
122+
123+if __name__ == "__main__":
124+ loader = unittest.defaultTestLoader
125+ unittest.main (testLoader=loader)
126
127=== added file 'tests/compiz_config_test.py'
128--- tests/compiz_config_test.py 1970-01-01 00:00:00 +0000
129+++ tests/compiz_config_test.py 2011-11-10 23:56:24 +0000
130@@ -0,0 +1,11 @@
131+import unittest
132+import compizconfig
133+import os
134+
135+class CompizConfigTest (unittest.TestCase):
136+
137+ ccs = compizconfig
138+
139+ def setUp (self):
140+ self.context = compizconfig.Context ()
141+
142
143=== added file 'tests/test_backend.py'
144--- tests/test_backend.py 1970-01-01 00:00:00 +0000
145+++ tests/test_backend.py 2011-11-10 23:56:24 +0000
146@@ -0,0 +1,15 @@
147+import compiz_config_test
148+
149+class CompizConfigTestBackend (compiz_config_test.CompizConfigTest):
150+
151+ def runTest (self):
152+
153+ info = ["ini", "Ini Backend", "Flat File Backend", True, False]
154+
155+ backend = self.ccs.Backend (self.context, info)
156+
157+ self.assertEqual (backend.Name, "ini")
158+ self.assertEqual (backend.ShortDesc, "Ini Backend")
159+ self.assertEqual (backend.LongDesc, "Flat File Backend")
160+ self.assertEqual (backend.IntegrationSupport, False)
161+ self.assertEqual (backend.ProfileSupport, True)
162
163=== added file 'tests/test_plugin.py'
164--- tests/test_plugin.py 1970-01-01 00:00:00 +0000
165+++ tests/test_plugin.py 2011-11-10 23:56:24 +0000
166@@ -0,0 +1,17 @@
167+import compiz_config_test
168+
169+class CompizConfigTestPlugin (compiz_config_test.CompizConfigTest):
170+
171+ def runTest (self):
172+ plugin = self.ccs.Plugin (self.context, "opengl")
173+ plugin.Update ()
174+
175+ self.assertEqual (plugin.Context, self.context)
176+ self.assertTrue (plugin.Groups is not None)
177+ self.assertTrue (plugin.Screen is not None)
178+ self.assertEqual (plugin.Name, "opengl")
179+ self.assertTrue (plugin.ShortDesc is not None)
180+ self.assertTrue (plugin.LongDesc is not None)
181+ self.assertTrue (plugin.Category is not None)
182+ self.assertTrue (plugin.Features is not None)
183+ self.assertTrue (plugin.Initialized is True)
184
185=== added file 'tests/test_profile.py'
186--- tests/test_profile.py 1970-01-01 00:00:00 +0000
187+++ tests/test_profile.py 2011-11-10 23:56:24 +0000
188@@ -0,0 +1,12 @@
189+import compiz_config_test
190+
191+class CompizConfigProfileTest (compiz_config_test.CompizConfigTest):
192+
193+ def runTest (self):
194+
195+ profile = self.ccs.Profile (self.context, "compizconfig")
196+ self.assertEqual (profile.Name, "compizconfig", 'wrong profile name')
197+ profile1 = self.ccs.Profile (self.context, "compizconfig2")
198+ self.assertEqual (profile1.Name, "compizconfig2", 'wrong profile name')
199+ profile2 = self.ccs.Profile (self.context, "compizconfig3")
200+ self.assertEqual (profile2.Name, "compizconfig3", 'wrong profile name')
201
202=== added file 'tests/test_setting.py'
203--- tests/test_setting.py 1970-01-01 00:00:00 +0000
204+++ tests/test_setting.py 2011-11-10 23:56:24 +0000
205@@ -0,0 +1,21 @@
206+import compiz_config_test
207+
208+class CompizConfigTestSetting (compiz_config_test.CompizConfigTest):
209+
210+ def runTest (self):
211+
212+ plugin = self.context.Plugins['core']
213+ setting = self.ccs.Setting (plugin, 'active_plugins')
214+
215+ self.assertEqual (setting.Plugin, plugin)
216+ self.assertEqual (setting.Name, 'active_plugins')
217+ self.assertEqual (setting.ShortDesc, 'Active Plugins')
218+ self.assertEqual (setting.LongDesc, 'List of currently active plugins')
219+ self.assertTrue (setting.Group is not None)
220+ self.assertTrue (setting.SubGroup is not None)
221+ self.assertEqual (setting.Type, "List")
222+ self.assertTrue (setting.Hints is not None)
223+ self.assertTrue (setting.DefaultValue is not None)
224+ self.assertTrue (setting.Value is not None)
225+ self.assertEqual (setting.Integrated, False)
226+ self.assertEqual (setting.ReadOnly, False)

Subscribers

People subscribed via source and target branches

to all changes: