コード例 #1
0
ファイル: test_compile.py プロジェクト: pombredanne/pdk
class TestReleaseWriter(TempDirTest):
    def set_up(self):
        super(self.__class__, self).set_up()
        self.search_path = pjoin(self.work_dir, 'repo', 'stuff')
        release_time = 'Wed, 22 Mar 2005 21:20:00 UTC'
        contents = { ('apt-deb', 'archive'): 'stable',
                     ('apt-deb', 'version'): '3.0r4',
                     ('apt-deb', 'origin'): 'Debian',
                     ('apt-deb', 'label'): 'Debian2',
                     ('apt-deb', 'suite'): 'happy',
                     ('apt-deb', 'codename'): 'woody',
                     ('apt-deb', 'date'): release_time,
                     ('apt-deb', 'description'): 'Hello World!' }
        self.writer = DebianReleaseWriter(contents, ['i386', 'alpha'],
                                          ['main', 'contrib'],
                                          self.search_path)

    def test_write_inner_release(self):
        dest = LazyWriter(pjoin(self.work_dir, 'Release'))
        self.writer.write(dest, 'main', 'i386')
        dest.close()
        expected = """Archive: stable
Version: 3.0r4
Component: main
Origin: Debian
Label: Debian2
Architecture: i386
"""
        actual = self.read_file('Release')
        self.assert_equals_long(expected, actual)

    def test_writer_outer_release(self):
        handle = LazyWriter(pjoin(self.search_path, 'data', 'Release'))
        print >> handle, 'testing123'
        handle.close()

        release_path = pjoin(self.search_path, 'Release')
        release_handle = LazyWriter(release_path)
        self.writer.write_outer(release_handle)
        release_handle.close()

        expected_release = """Origin: Debian
Label: Debian2
Suite: happy
Version: 3.0r4
Codename: woody
Date: Wed, 22 Mar 2005 21:20:00 UTC
Architectures: alpha i386
Components: main contrib
Description: Hello World!
MD5Sum:
 bad9425ff652b1bd52b49720abecf0ba               11 data/Release
SHA1:
 e3dc8362c1586e4d9702ad862f29b6bef869afde               11 data/Release
"""
        actual_release = self.read_file(release_path)
        # Newer versions of apt-ftparchive put more sums after the file.
        # We'll overlook these for now, for compatibility purposes.
        edited_release = ''.join(actual_release.splitlines(True)[:13])
        self.assert_equals_long(expected_release, edited_release)
コード例 #2
0
ファイル: test_compile.py プロジェクト: pombredanne/pdk
 def set_up(self):
     super(self.__class__, self).set_up()
     self.search_path = pjoin(self.work_dir, 'repo', 'stuff')
     release_time = 'Wed, 22 Mar 2005 21:20:00 UTC'
     contents = { ('apt-deb', 'archive'): 'stable',
                  ('apt-deb', 'version'): '3.0r4',
                  ('apt-deb', 'origin'): 'Debian',
                  ('apt-deb', 'label'): 'Debian2',
                  ('apt-deb', 'suite'): 'happy',
                  ('apt-deb', 'codename'): 'woody',
                  ('apt-deb', 'date'): release_time,
                  ('apt-deb', 'description'): 'Hello World!' }
     self.writer = DebianReleaseWriter(contents, ['i386', 'alpha'],
                                       ['main', 'contrib'],
                                       self.search_path)