]> git.decadent.org.uk Git - dak.git/blobdiff - tests/dbtest_contents.py
Add class SourceContentsWriter.
[dak.git] / tests / dbtest_contents.py
index 51a6ddf4898721c17fb350e6fbc2d7420c70379c..0f23053c3fe3d412191d48413352f8137be2594e 100755 (executable)
@@ -4,7 +4,7 @@ from db_test import DBDakTestCase, fixture
 
 from daklib.dbconn import *
 from daklib.contents import BinaryContentsWriter, BinaryContentsScanner, \
-    UnpackedSource, SourceContentsScanner
+    UnpackedSource, SourceContentsScanner, SourceContentsWriter
 
 from os.path import normpath
 from sqlalchemy.exc import FlushError, IntegrityError
@@ -201,6 +201,22 @@ class ContentsTestCase(DBDakTestCase):
         SourceContentsScanner(source.source_id).scan()
         self.assertTrue(source.contents.count() > 0)
 
+    def test_sourcecontentswriter(self):
+        '''
+        Test the SourceContentsWriter class.
+        '''
+        self.setup_sources()
+        self.session.flush()
+        # remove newer package from sid because it disturbs the test
+        self.source['hello_2.2-2'].suites = []
+        self.session.commit()
+        source = self.source['hello_2.2-1']
+        SourceContentsScanner(source.source_id).scan()
+        cw = SourceContentsWriter(source.suites[0], source.poolfile.location.component)
+        result = cw.get_list()
+        self.assertEqual(8, len(result))
+        self.assertTrue('debian/changelog\thello\n' in result)
+
     def classes_to_clean(self):
         return [Override, Suite, BinContents, DBBinary, DBSource, Architecture, Section, \
             OverrideType, Maintainer, Component, Priority, PoolFile]