def test_two_level_fk_o2o_hierarchy_mixed(self):
     # FK from Employee to Company, O2O from EmployeeHistory to Employee
     company_fixture = Fixture(Company)
     company_fixture.add(1, name='Macrohard')
     employee_fixture = Fixture(Employee)
     employee_fixture.add(1, name='Andy Depressant', company=company_fixture.fk(1), manager=None)
     history_fixture = Fixture(EmployeeHistory)
     history_fixture.add(1, employee=employee_fixture.o2o(1), date_joined='2007-02-22')
     # Load in mixed order: 3rd, 1st, 2nd level
     history_fixture.load()
     self.assertEqual(Company.objects.count(), 1)
     self.assertEqual(Employee.objects.count(), 1)
     self.assertEqual(EmployeeHistory.objects.count(), 1)
 def test_o2o_relation(self):
     company_fixture = Fixture(Company)
     company_fixture.add(1, name='Macrohard')
     employee_fixture = Fixture(Employee)
     employee_fixture.add(1, name='Andy Depressant', company=company_fixture.fk(1), manager=None)
     history_fixture = Fixture(EmployeeHistory)
     history_fixture.add(1, employee=employee_fixture.o2o(1), date_joined='2007-02-22')
     company_fixture.load()
     employee_fixture.load()
     history_fixture.load()
     self.assertEqual(Company.objects.count(), 1)
     self.assertEqual(Employee.objects.count(), 1)
     self.assertEqual(EmployeeHistory.objects.count(), 1)
     self.assertEqual(Employee.objects.all()[0].employeehistory, EmployeeHistory.objects.all()[0])
from class_fixtures.models import Fixture
from class_fixtures.tests.models import Company, Employee, EmployeeHistory

company_fixture = Fixture(Company)
employee_fixture = Fixture(Employee)
employee_history_fixture = Fixture(EmployeeHistory)

company_fixture.add(3, name="Dewey, Cheatem & Howe")
employee_fixture.add(5, name="Sly M. Ball", company=company_fixture.fk(3))
employee_fixture.add(6, name="Mei Ting", company=company_fixture.fk(3), manager=employee_fixture.fk(5))
employee_history_fixture.add(5, employee=employee_fixture.o2o(5), date_joined="2000-11-03")
employee_history_fixture.add(6, employee=employee_fixture.o2o(6), date_joined="1985-12-28")
membership_fixture.add(
    8,
    musician=musician_fixture.fk(5),
    band=metalband_fixture.fk(6),
    date_joined="1982-03-03",
    instrument="Guitarrrr-ahh",
)

# Single M2M addition with a kwarg
roadie_fixture.add(3, name="Tats Brimhat", hauls_for=[band_fixture.m2m(5)])

# Two M2M additions with a list of kwargs
roadie_fixture.add(4, name="Blackie Teeshirt", hauls_for=[band_fixture.m2m(5), metalband_fixture.m2m(6)])

# Single M2M addition with a relation token
roadie_fixture.add(5, name="Ciggy Tardust", hauls_for=[metalband_fixture.m2m(6)])


company_fixture = Fixture(Company)
employee_fixture = Fixture(Employee)
employee_history_fixture = Fixture(EmployeeHistory)

company_fixture.add(2, name="FacelessCorp Inc.")
# Normal FK relationship to another model
employee_fixture.add(3, name="Ty Rant", company=company_fixture.fk(2))
# Same, plus a recursive FK relationship to self
employee_fixture.add(4, name="Sue Ecide-Risk", company=company_fixture.fk(2), manager=employee_fixture.fk(3))
# OneToOne
employee_history_fixture.add(3, employee=employee_fixture.o2o(3), date_joined="2003-03-15")
employee_history_fixture.add(4, employee=employee_fixture.o2o(4), date_joined="2006-08-07")