OLD | NEW |
| (Empty) |
1 # test step.package.rpm.* | |
2 | |
3 from twisted.trial import unittest | |
4 | |
5 from buildbot.steps.package.rpm import RpmBuild, RpmLint, RpmSpec | |
6 | |
7 | |
8 class TestRpmBuild(unittest.TestCase): | |
9 """ | |
10 Tests the package.rpm.RpmBuild class. | |
11 """ | |
12 | |
13 def test_creation(self): | |
14 """ | |
15 Test that instances are created with proper data. | |
16 """ | |
17 rb = RpmBuild() | |
18 self.assertEquals(rb.specfile, None) | |
19 self.assertFalse(rb.autoRelease) | |
20 self.assertFalse(rb.vcsRevision) | |
21 | |
22 rb2 = RpmBuild('aspec.spec', autoRelease=True, vcsRevision=True) | |
23 self.assertEquals(rb2.specfile, 'aspec.spec') | |
24 self.assertTrue(rb2.autoRelease) | |
25 self.assertTrue(rb2.vcsRevision) | |
26 | |
27 def test_rpmbuild(self): | |
28 """ | |
29 Verifies the rpmbuild string is what we would expect. | |
30 """ | |
31 rb = RpmBuild('topdir', 'buildir', 'rpmdir', 'sourcedir', | |
32 'specdir', 'dist') | |
33 expected_result = ('rpmbuild --define "_topdir buildir"' | |
34 ' --define "_builddir rpmdir" --define "_rpmdir sourcedir"' | |
35 ' --define "_sourcedir specdir" --define "_specdir dist"' | |
36 ' --define "_srcrpmdir `pwd`" --define "dist .el5"') | |
37 self.assertEquals(rb.rpmbuild, expected_result) | |
38 | |
39 | |
40 class TestRpmLint(unittest.TestCase): | |
41 """ | |
42 Tests the package.rpm.RpmLint class. | |
43 """ | |
44 | |
45 def test_command(self): | |
46 """ | |
47 Test that instance command variable is created with proper data. | |
48 """ | |
49 rl = RpmLint() | |
50 expected_result = ["/usr/bin/rpmlint", "-i", '*rpm'] | |
51 self.assertEquals(rl.command, expected_result) | |
52 | |
53 | |
54 class TestRpmSpec(unittest.TestCase): | |
55 """ | |
56 Tests the package.rpm.RpmSpec class. | |
57 """ | |
58 | |
59 def test_creation(self): | |
60 """ | |
61 Test that instances are created with proper data. | |
62 """ | |
63 rs = RpmSpec() | |
64 self.assertEquals(rs.specfile, None) | |
65 self.assertEquals(rs.pkg_name, None) | |
66 self.assertEquals(rs.pkg_version, None) | |
67 self.assertFalse(rs.loaded) | |
68 | |
69 def test_load(self): | |
70 try: | |
71 from cStringIO import StringIO | |
72 except ImportError, ie: | |
73 from StringIO import StringIO | |
74 | |
75 specfile = StringIO() | |
76 specfile.write("""\ | |
77 Name: example | |
78 Version: 1.0.0 | |
79 Release: 1%{?dist} | |
80 Summary: An example spec | |
81 | |
82 Group: Development/Libraries | |
83 License: GPLv2+ | |
84 URL: http://www.example.dom | |
85 Source0: %{name}-%{version}.tar.gz | |
86 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) | |
87 | |
88 BuildArch: noarch | |
89 Requires: python >= 2.4 | |
90 BuildRequires: python-setuptools | |
91 | |
92 | |
93 %description | |
94 An example spec for an rpm. | |
95 | |
96 | |
97 %prep | |
98 %setup -q | |
99 | |
100 | |
101 %build | |
102 %{__python} setup.py build | |
103 | |
104 | |
105 %install | |
106 rm -rf $RPM_BUILD_ROOT | |
107 %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT/ | |
108 | |
109 | |
110 %clean | |
111 rm -rf $RPM_BUILD_ROOT | |
112 | |
113 | |
114 %files | |
115 %defattr(-,root,root,-) | |
116 %doc INSTALL LICENSE AUTHORS COPYING | |
117 # For noarch packages: sitelib | |
118 %{python_sitelib}/* | |
119 | |
120 | |
121 %changelog | |
122 * Wed Jan 7 2009 Steve 'Ashcrow' Milner <smilner+buildbot@redhat.com> - \ | |
123 1.0.0-1 | |
124 - example""") | |
125 specfile.flush() | |
126 specfile.seek(0) | |
127 rs = RpmSpec(specfile) | |
128 rs.load() | |
129 self.assertTrue(rs.loaded) | |
130 self.assertEquals(rs.pkg_name, 'example') | |
131 self.assertEquals(rs.pkg_version, '1.0.0') | |
OLD | NEW |