def test_fixture_module_string_5(self):
     old_pkgs = getattr(settings, 'FIXTURE_PACKAGES', [])
     settings.FIXTURE_PACKAGES = [
         "class_fixtures.tests.some_fixture_modules",
     ]
     try:
         handlers = associate_handlers(['some_fixtures', 'moar_fixtures'])
         some_module = import_module('class_fixtures.tests.fixtures.some_fixtures')
         moar_module = import_module('class_fixtures.tests.some_fixture_modules.moar_fixtures')
         self.assertEqual(handlers, [
             ('some_fixtures', 'django', None, None),
             ('some_fixtures', 'class_fixtures', 'submodule_name', some_module),
             ('moar_fixtures', 'django', None, None),
             ('moar_fixtures', 'class_fixtures', 'submodule_name', moar_module)
         ])
         l = Loaddata()
         l.stdout = sys.stdout
         l.stderr = sys.stderr
         l.handle('some_fixtures', 'moar_fixtures', verbosity=0)
         self.assertEqual(Company.objects.count(), 1)
         self.assertEqual(Employee.objects.count(), 2)
         self.assertEqual(EmployeeHistory.objects.count(), 2)
         self.assertEqual(Band.objects.count(), 1)
         self.assertEqual(Musician.objects.count(), 1)
         self.assertEqual(Membership.objects.count(), 1)
     finally:
         settings.FIXTURE_PACKAGES = old_pkgs
 def test_appname_fixturemodule_string(self):
     handlers = associate_handlers(['tests.some_fixtures'])
     fixture_submodule = import_module('class_fixtures.tests.fixtures.some_fixtures')
     self.assertEqual(handlers, [('tests.some_fixtures', 'class_fixtures', 'submodule_name', fixture_submodule)])
     l = Loaddata()
     l.stdout = sys.stdout
     l.stderr = sys.stderr
     l.handle('tests.some_fixtures', verbosity=0)
     self.assertEqual(Company.objects.count(), 1)
     self.assertEqual(Employee.objects.count(), 2)
     self.assertEqual(EmployeeHistory.objects.count(), 2)
 def test_fixture_module_string_3(self):
     handlers = associate_handlers(['app_level_fixture.json'])
     self.assertEqual(handlers, [('app_level_fixture.json', 'django', None, None)])
     l = Loaddata()
     l.stdout = sys.stdout
     l.stderr = sys.stderr
     l.handle('app_level_fixture.json', verbosity=0)
     self.assertEqual(Band.objects.count(), 2)
     self.assertEqual(MetalBand.objects.count(), 1)
     self.assertEqual(Musician.objects.count(), 2)
     self.assertEqual(Membership.objects.count(), 3)
     self.assertEqual(Roadie.objects.count(), 1)
     self.assertEqual(Company.objects.count(), 1)
     self.assertEqual(Employee.objects.count(), 2)
     self.assertEqual(EmployeeHistory.objects.count(), 2)
 def test_fixture_module(self):
     fixture_module = import_module('class_fixtures.tests.fixtures.other_fixtures')
     handlers = associate_handlers([fixture_module])
     self.assertEqual(handlers, [(fixture_module, 'class_fixtures', 'module', None)])
     l = Loaddata()
     l.stdout = sys.stdout
     l.stderr = sys.stderr
     l.handle(fixture_module, verbosity=0)
     self.assertEqual(Band.objects.count(), 2)
     self.assertEqual(MetalBand.objects.count(), 1)
     self.assertEqual(Musician.objects.count(), 2)
     self.assertEqual(Membership.objects.count(), 2)
     self.assertEqual(Roadie.objects.count(), 3)
     self.assertEqual(Company.objects.count(), 1)
     self.assertEqual(Employee.objects.count(), 2)
     self.assertEqual(EmployeeHistory.objects.count(), 2)
 def test_appname_string(self):
     handlers = associate_handlers(['tests'])
     fixture_package = import_module('class_fixtures.tests.fixtures')
     self.assertEqual(handlers, [('tests', 'class_fixtures', 'app_label', fixture_package)])
     l = Loaddata()
     l.stdout = sys.stdout
     l.stderr = sys.stderr
     l.handle('tests', verbosity=0)
     # fixtures.some_fixtures and fixtures.other_fixtures contents combined
     self.assertEqual(Band.objects.count(), 2)
     self.assertEqual(MetalBand.objects.count(), 1)
     self.assertEqual(Musician.objects.count(), 2)
     self.assertEqual(Roadie.objects.count(), 3)
     self.assertEqual(Membership.objects.count(), 2)
     self.assertEqual(Company.objects.count(), 2)
     self.assertEqual(Employee.objects.count(), 4)
     self.assertEqual(EmployeeHistory.objects.count(), 4)
 def test_fixture_module_string_4(self):
     # Loads tests/testproject/project_fixtures/project_level_fixture.json
     old_fixture_dirs = settings.FIXTURE_DIRS
     settings.FIXTURE_DIRS = (os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testproject/project_fixtures'),)
     handlers = associate_handlers(['project_level_fixture'])
     self.assertEqual(handlers, [('project_level_fixture', 'django', None, None)])
     try:
         l = Loaddata()
         l.stdout = sys.stdout
         l.stderr = sys.stderr
         l.handle('project_level_fixture', verbosity=0)
     finally:
         settings.FIXTURE_DIRS = old_fixture_dirs
     self.assertEqual(Band.objects.count(), 2)
     self.assertEqual(MetalBand.objects.count(), 1)
     self.assertEqual(Musician.objects.count(), 2)
     self.assertEqual(Membership.objects.count(), 3)
     self.assertEqual(Roadie.objects.count(), 1)