@@ -0,0 +1,2739 @@
+# -*- coding: utf-8 -*-%0A#%0A# Copyright (c) 2010-2012 Cidadania S. Coop. Galega%0A#%0A# This file is part of e-cidadania.%0A#%0A# e-cidadania is free software: you can redistribute it and/or modify%0A# it under the terms of the GNU General Public License as published by%0A# the Free Software Foundation, either version 3 of the License, or%0A# (at your option) any later version.%0A#%0A# e-cidadania is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A# GNU General Public License for more details.%0A#%0A# You should have received a copy of the GNU General Public License%0A# along with e-cidadania. If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A%0Aimport unittest%0A%0Afrom tests.data_seeder import seeder%0A%0Afrom core.spaces.models import Space%0A%0Afrom django.contrib.auth.models import User%0A%0A%0Aclass TestDataSeeder(unittest.TestCase):%0A    %22%22%22Tests the DataSeeder class methods.%0A    %22%22%22%0A    %0A    def testInstanceIsCreated(self):%0A        %22%22%22Tests if the correct instance of a model is generated.%0A        %22%22%22%0A        %0A        created_model = seeder.seed(Space)%0A        self.assertTrue(isinstance(created_model, Space))%0A    %0A    def testCorrectNumberOfInstancesAreGenerated(self):%0A        %22%22%22Tests if correct number of model instances are generated.%0A        %22%22%22%0A        %0A        count = 5%0A        actual_list = seeder.seedn(count, Space)%0A        self.assertEqual(len(actual_list), count)%0A    %0A    def testIfInstanceIsGeneratedWithRequiredAttributes(self):%0A        %22%22%22Tests if the generated instance has the desired properties.%0A        %22%22%22%0A        %0A        properties = %7B%0A            'name': 'Test Space',%0A            'description': 'Temporary Description',%0A            'public': 'False',%0A        %7D%0A        instance = seeder.seed(Space, model_properties=properties)%0A        self.assertEqual(instance.name, properties%5B'name'%5D)%0A        self.assertEqual(instance.description, properties%5B'description'%5D)%0A        self.assertEqual(instance.public, properties%5B'public'%5D)%0A        #Space.author is a Foreign Key. Since generate_fk is False by default,%0A        #Space.author should be None as it will not be populated.%0A        self.assertEqual(instance.author, None)%0A        self.assertFalse(isinstance(instance.author, User))%0A    %0A    def testIfForeignKeyFieldsOfaModelIsPopulated(self):%0A        %22%22%22Tests if the foreign key fields of a model is populated if%0A        generate_fk is set to True%0A        %22%22%22%0A        %0A        instance = seeder.seed(Space)%0A        self.assertEqual(instance.author, None)%0A        %0A        instance = seeder.seed(Space, generate_fk=True)%0A        self.assertTrue(isinstance(instance.author, User))%0A        User.objects.all().delete()

Add tests for the data seeder.