Merge lp:~eeejay/mago/tweaks into lp:~mago-contributors/mago/mago-1.0

Proposed by Eitan Isaacson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~eeejay/mago/tweaks
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: None lines
To merge this branch: bzr merge lp:~eeejay/mago/tweaks
Reviewer Review Type Date Requested Status
Javier Collado (community) Approve
Ara Pulido Approve
Review via email: mp+6820@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Eitan Isaacson (eeejay) wrote :

Makes the application class factory a class attribute of the test suite.

Revision history for this message
Javier Collado (javier.collado) wrote :

The code change it's OK to me. I just think that the in the TestSuite class documentation string a comment should be added to state clearly what's the aim of the new APPLICATION_FACTORY class attribute.

review: Needs Information
Revision history for this message
Ara Pulido (ara) wrote :

Same thing here, I think that the code is OK, but apart of the comment Javier's suggested, I would also appreciate a comment on why it was decided to remove application as an init method parameter.
(commenting here in launchpad, I mean)

review: Needs Information
Revision history for this message
Eitan Isaacson (eeejay) wrote :

> Same thing here, I think that the code is OK, but apart of the comment
> Javier's suggested, I would also appreciate a comment on why it was decided to
> remove application as an init method parameter.
> (commenting here in launchpad, I mean)

It is hard (not clean) to subclass an Application class, and include it as the factory for the TestSuite class.

The specific use-case is the pidgin_messaging.py script overrides Application.open() and Application.close().

Before the app/suite split, it was an easy override, but now we need to:
1. Override Pidgin as PidginUseApp
2. Override PidginUseTest.__init__(), re-implement it without calling the superclass init, because it will provide (and use) the wrong factory. Here is what it looks like:

class PidginUseApp(Pidgin):
    def open(self):
        Pidgin.open(self)
        self.buddy_login()
        self.wait_for_account_connect(self.get_account_name('XMPP'), 'XMPP')
        self.wait_for_buddy(self.get_account_alias('OtherXMPP'))

    def close(self):
        self.buddy.disconnect()
        Pidgin.exit(self)

class PidginUseTest(PidginTestSuite):
    def __init__(self, clean_profile=True,
                 profile_template='',
                 credentials=''):
        self.clean_profile = clean_profile
        self.profile_template = profile_template
        self.credentials = credentials
        SingleApplicationTestSuite.__init__(self, PidginUseApp)

With my changes, besides overriding Pidgin, you just need to override a static class attribute.

Phew!!

lp:~eeejay/mago/tweaks updated
54. By Eitan Isaacson

add helpful docstring for SingleApplicationTestSuite.APPLICATION_FACTORY

Revision history for this message
Eitan Isaacson (eeejay) wrote :

> The code change it's OK to me. I just think that the in the TestSuite class
> documentation string a comment should be added to state clearly what's the aim
> of the new APPLICATION_FACTORY class attribute.

Added a docstring.

Revision history for this message
Ara Pulido (ara) wrote :

Thanks for the comments :-)

review: Approve
Revision history for this message
Javier Collado (javier.collado) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'desktoptesting/test_suite/deskex.py'
2--- desktoptesting/test_suite/deskex.py 2009-05-06 09:37:46 +0000
3+++ desktoptesting/test_suite/deskex.py 2009-05-27 10:45:38 +0000
4@@ -10,9 +10,7 @@
5 """
6 Default test suite for Seahorse
7 """
8- def __init__(self):
9- SingleApplicationTestSuite.__init__(self, IndicatorApplet)
10-
11+ APPLICATION_FACTORY = IndicatorApplet
12 def setup(self):
13 self.application.open()
14
15@@ -26,9 +24,7 @@
16 """
17 Default test suite for Seahorse
18 """
19- def __init__(self):
20- SingleApplicationTestSuite.__init__(self, NotifyOSD)
21-
22+ APPLICATION_FACTORY = NotifyOSD
23 def setup(self):
24 self.application.open()
25
26
27=== modified file 'desktoptesting/test_suite/gnome.py'
28--- desktoptesting/test_suite/gnome.py 2009-04-21 10:15:09 +0000
29+++ desktoptesting/test_suite/gnome.py 2009-05-27 10:45:38 +0000
30@@ -10,9 +10,7 @@
31 """
32 Default test suite for Seahorse
33 """
34- def __init__(self):
35- SingleApplicationTestSuite.__init__(self, Seahorse)
36-
37+ APPLICATION_FACTORY = Seahorse
38 def setup(self):
39 self.application.open()
40
41@@ -28,9 +26,7 @@
42 """
43 Default test suite for GEdit
44 """
45- def __init__(self):
46- SingleApplicationTestSuite.__init__(self, GEdit)
47-
48+ APPLICATION_FACTORY = GEdit
49 def setup(self):
50 self.application.open()
51
52
53=== modified file 'desktoptesting/test_suite/main.py'
54--- desktoptesting/test_suite/main.py 2009-04-21 10:15:09 +0000
55+++ desktoptesting/test_suite/main.py 2009-05-27 10:45:38 +0000
56@@ -2,6 +2,8 @@
57 test_suite module contains the definition of the TestSuite class that
58 must be used by all test suites written for the desktoptesting package
59 """
60+from ..application.main import Application
61+
62 class TestSuite:
63 """
64 TestSuite that implements all the test suite methods desired in a
65@@ -22,8 +24,9 @@
66 Test suite intended to make sure that a single application is
67 running
68 """
69- def __init__(self, application_factory):
70- self.application = application_factory()
71+ APPLICATION_FACTORY = Application
72+ def __init__(self):
73+ self.application = self.APPLICATION_FACTORY()
74
75 def cleanup(self):
76 self.application.set_name(self.application.WINDOW)
77
78=== modified file 'desktoptesting/test_suite/ubuntu.py'
79--- desktoptesting/test_suite/ubuntu.py 2009-04-21 09:58:40 +0000
80+++ desktoptesting/test_suite/ubuntu.py 2009-05-27 10:45:38 +0000
81@@ -6,9 +6,7 @@
82 from ..application.ubuntu import UbuntuMenu, UpdateManager
83
84 class UbuntuMenuTestSuite(SingleApplicationTestSuite):
85- def __init__(self):
86- SingleApplicationTestSuite.__init__(self, UbuntuMenu)
87-
88+ APPLICATION_FACTORY = UbuntuMenu
89 def teardown(self):
90 self.cleanup()
91
92@@ -18,5 +16,4 @@
93
94
95 class UpdateManagerTestSuite(SingleApplicationTestSuite):
96- def __init__(self):
97- SingleApplicationTestSuite.__init__(self, UpdateManager)
98+ APPLICATION_FACTORY = UpdateManager

Subscribers

People subscribed via source and target branches

to status/vote changes: