7
from mozprofile import addons
9
class AddonIDTest(unittest.TestCase):
10
""" Test finding the addon id in a variety of install.rdf styles """
12
def make_install_rdf(self, filecontents):
13
path = tempfile.mkdtemp()
14
f = open(os.path.join(path, "install.rdf"), "w")
19
def test_addonID(self):
20
testlist = self.get_test_list()
23
p = self.make_install_rdf(t)
24
a = addons.AddonManager(os.path.join(p, "profile"))
25
addon_id = a.addon_details(p)['id']
26
self.assertTrue(addon_id == "winning", "We got the addon id")
30
def get_test_list(self):
31
""" This just returns a hardcoded list of install.rdf snippets for testing.
32
When adding snippets for testing, remember that the id we're looking for
33
is "winning" (no quotes). So, make sure you have that id in your snippet
34
if you want it to pass.
37
"""<?xml version="1.0"?>
38
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
39
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
40
<Description about="urn:mozilla:install-manifest">
41
<em:id>winning</em:id>
42
<em:name>MozMill</em:name>
43
<em:version>2.0a</em:version>
44
<em:creator>Adam Christian</em:creator>
45
<em:description>A testing extension based on the Windmill Testing Framework client source</em:description>
46
<em:unpack>true</em:unpack>
47
<em:targetApplication>
50
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
51
<em:minVersion>3.5</em:minVersion>
52
<em:maxVersion>8.*</em:maxVersion>
54
</em:targetApplication>
55
<em:targetApplication>
58
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
59
<em:minVersion>3.0a1pre</em:minVersion>
60
<em:maxVersion>3.2*</em:maxVersion>
62
</em:targetApplication>
63
<em:targetApplication>
66
<em:id>{718e30fb-e89b-41dd-9da7-e25a45638b28}</em:id>
67
<em:minVersion>0.6a1</em:minVersion>
68
<em:maxVersion>1.0pre</em:maxVersion>
70
</em:targetApplication>
71
<em:targetApplication>
74
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
75
<em:minVersion>2.0a1</em:minVersion>
76
<em:maxVersion>2.1*</em:maxVersion>
78
</em:targetApplication>
79
<em:targetApplication>
82
<em:id>songbird@songbirdnest.com</em:id>
83
<em:minVersion>0.3pre</em:minVersion>
84
<em:maxVersion>1.3.0a</em:maxVersion>
86
</em:targetApplication>
87
<em:targetApplication>
89
<em:id>toolkit@mozilla.org</em:id>
90
<em:minVersion>1.9.1</em:minVersion>
91
<em:maxVersion>2.0*</em:maxVersion>
93
</em:targetApplication>
96
"""<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
97
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
98
<Description about="urn:mozilla:install-manifest">
99
<em:targetApplication>
102
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
103
<em:minVersion>3.5</em:minVersion>
104
<em:maxVersion>8.*</em:maxVersion>
106
</em:targetApplication>
107
<em:id>winning</em:id>
108
<em:name>MozMill</em:name>
109
<em:version>2.0a</em:version>
110
<em:creator>Adam Christian</em:creator>
111
<em:description>A testing extension based on the Windmill Testing Framework client source</em:description>
112
<em:unpack>true</em:unpack>
115
"""<RDF xmlns="http://www.mozilla.org/2004/em-rdf#"
116
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
117
<rdf:Description about="urn:mozilla:install-manifest">
120
<version>42</version>
121
<description>A testing extension based on the Windmill Testing Framework client source</description>
124
"""<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
125
xmlns:foobar="http://www.mozilla.org/2004/em-rdf#">
126
<Description about="urn:mozilla:install-manifest">
127
<foobar:targetApplication>
130
<foobar:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</foobar:id>
131
<foobar:minVersion>3.5</foobar:minVersion>
132
<foobar:maxVersion>8.*</foobar:maxVersion>
134
</foobar:targetApplication>
135
<foobar:id>winning</foobar:id>
136
<foobar:name>MozMill</foobar:name>
137
<foobar:version>2.0a</foobar:version>
138
<foobar:creator>Adam Christian</foobar:creator>
139
<foobar:description>A testing extension based on the Windmill Testing Framework client source</foobar:description>
140
<foobar:unpack>true</foobar:unpack>
145
if __name__ == '__main__':