Index: /main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py	(revision 9199)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py	(revision 9200)
@@ -37,4 +37,5 @@
 from waeup.kofa.hostels.container import HostelsContainer
 from waeup.kofa.hostels.hostel import Hostel, Bed
+from waeup.kofa.hostels.export import BedExporter, HostelExporter
 from waeup.kofa.testing import (FunctionalLayer, FunctionalTestCase)
 from waeup.kofa.students.student import Student
@@ -143,7 +144,7 @@
         # Create a bed
         bed = Bed()
-        bed.bed_id = u'xyz'
+        bed.bed_id = u'hall_block_room_bed'
         bed.bed_number = 1
-        bed.bed_type = u'abc'
+        bed.bed_type = u'a_b_c'
         self.app['hostels'][hostel.hostel_id][bed.bed_id] = bed
 
@@ -175,12 +176,12 @@
         # We can find a certain bed
         cat = queryUtility(ICatalog, name='beds_catalog')
-        results = cat.searchResults(bed_type=(u'abc', u'abc'))
+        results = cat.searchResults(bed_type=(u'a_b_c', u'a_b_c'))
         results = [x for x in results] # Turn results generator into list
         assert len(results) == 1
-        assert results[0] is self.app['hostels']['hall-x']['xyz']
+        assert results[0] is self.app['hostels']['hall-x']['hall_block_room_bed']
 
     def test_search_by_owner(self):
         # We can find a certain bed
-        myobj = self.app['hostels']['hall-x']['xyz']
+        myobj = self.app['hostels']['hall-x']['hall_block_room_bed']
         myobj.owner = u'abc'
         notify(grok.ObjectModifiedEvent(myobj))
@@ -189,5 +190,5 @@
         results = [x for x in results] # Turn results generator into list
         assert len(results) == 1
-        assert results[0] is self.app['hostels']['hall-x']['xyz']
+        assert results[0] is self.app['hostels']['hall-x']['hall_block_room_bed']
 
 class HostelsUITests(HostelsFullSetup):
@@ -387,2 +388,38 @@
         self.assertTrue('zope.mgr - hostels.browser.HostelsContainerManagePage'
                         ' - hostels - all hostels cleared' in logcontent)
+
+class ExportTests(HostelsFullSetup):
+
+    layer = FunctionalLayer
+
+    def setUp(self):
+        super(ExportTests, self).setUp()
+        self.workdir = tempfile.mkdtemp()
+        self.outfile = os.path.join(self.workdir, 'myoutput.csv')
+        return
+
+    def test_export_hostels(self):
+        exporter = HostelExporter()
+        exporter.export_all(self.app, self.outfile)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'beds_for_all,beds_for_final,beds_for_fresh,beds_for_pre,'
+            'beds_for_returning,beds_reserved,blocks_for_female,'
+            'blocks_for_male,floors_per_block,hostel_id,hostel_name,'
+            'rooms_per_floor,sort_id,special_handling\r\n,,,,,[],,,1,'
+            'hall-x,Hall 1,2,10,regular\r\n'
+            )
+        return
+
+    def test_export_beds(self):
+        exporter = BedExporter()
+        exporter.export_all(self.app, self.outfile)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'bed_id,bed_number,bed_type,owner,hall,block,room,bed,'
+            'special_handling,sex,bt\r\nhall_block_room_bed,1,a_b_c,,'
+            'hall,block,room,bed,a,b,c\r\n'
+            )
+        return
