Closed jonathan-s closed 6 years ago
Ok, I have better explanation to what's going on here. There is a conflict with hangar_id
in the model and the foreign key document
. FactoryBoy creates two hangar_id
, even though it should not create another because of the syntax in the foreign key that says it should use the already existing hangar_id
It would be neat if this could be fixed :)
@jonathan-s Could you paste the output of this:
with factory.debug():
DocumentFactory()
VotingFactory()
Thanks!
A note, you'll see VotingAggFactory below, it's the same issue as VotingFactory and set up in the same way. Here you go:
BaseFactory: Preparing riksdagen.tests.factories.DocumentFactory(extra={})
BaseFactory: Preparing riksdagen.tests.factories.DocumentFactory(extra={})
<class 'riksdagen.tests.factories.DocumentFactory'>: Setting up next sequence (1)
<class 'riksdagen.tests.factories.DocumentFactory'>: Setting up next sequence (1)
LazyStub: Computing values for riksdagen.tests.factories.DocumentFactory(status='', documentstatus_url_xml='http://data.riksdagen.se/dokumentstatus/GY01AU4', doctype2='bet', doctype='bet', party_year='2013/14', committee_prop_url_xml='http://data.riksdagen.se/utskottsforslag/GY01AU4', document_url_text='http://data.riksdagen.se/dokument/GY01AU4/text', serial_num_end=0, subtitle='', hangar_id=<OrderedDeclarationWrapper for <factory.declarations.Sequence object at 0x10baea710>>, sourceid='', title='Random Junk Title', htmlformat='', templabel='', publicised=datetime.datetime(2014, 6, 22, 0, 0), govorgan='FIU', system_date=datetime.datetime(2014, 6, 22, 0, 0), document_url_html='Lots of html', date=datetime.date(2014, 6, 22), subtype='bet', doc_id='GY01AU4', label='FIU21', html='Again lots of html', serial_num=4, related_id='', receiver='', source='')
LazyStub: Computing values for riksdagen.tests.factories.DocumentFactory(status='', documentstatus_url_xml='http://data.riksdagen.se/dokumentstatus/GY01AU4', doctype2='bet', doctype='bet', party_year='2013/14', committee_prop_url_xml='http://data.riksdagen.se/utskottsforslag/GY01AU4', document_url_text='http://data.riksdagen.se/dokument/GY01AU4/text', serial_num_end=0, subtitle='', hangar_id=<OrderedDeclarationWrapper for <factory.declarations.Sequence object at 0x10baea710>>, sourceid='', title='Random Junk Title', htmlformat='', templabel='', publicised=datetime.datetime(2014, 6, 22, 0, 0), govorgan='FIU', system_date=datetime.datetime(2014, 6, 22, 0, 0), document_url_html='Lots of html', date=datetime.date(2014, 6, 22), subtype='bet', doc_id='GY01AU4', label='FIU21', html='Again lots of html', serial_num=4, related_id='', receiver='', source='')
Sequence: Computing next value of <function DocumentFactory.
/Users/jonathan/.virtualenvs/riksdagsrosten/lib/python3.3/site-packages/django/db/models/fields/init.py:903: RuntimeWarning: DateTimeField Document.publicised received a naive datetime (2014-06-22 00:00:00) while time zone support is active. RuntimeWarning)
BaseFactory: Preparing riksdagen.tests.factories.VotingAggFactory(extra={})
BaseFactory: Preparing riksdagen.tests.factories.VotingAggFactory(extra={})
<class 'riksdagen.tests.factories.VotingAggFactory'>: Setting up next sequence (1)
<class 'riksdagen.tests.factories.VotingAggFactory'>: Setting up next sequence (1)
LazyStub: Computing values for riksdagen.tests.factories.VotingAggFactory(document=<OrderedDeclarationWrapper for <factory.declarations.SubFactory object at 0x10baea790>>, voting_id='AAFAC7F5-AFCD-11D8-AE5D-0004755038D1', q1_absent=0, q1_abstained=0, q1_no=0, hangar_id=<OrderedDeclarationWrapper for <factory.declarations.Sequence object at 0x10baea690>>, date=datetime.date(2014, 6, 17), q1_yes=0)
LazyStub: Computing values for riksdagen.tests.factories.VotingAggFactory(document=<OrderedDeclarationWrapper for <factory.declarations.SubFactory object at 0x10baea790>>, voting_id='AAFAC7F5-AFCD-11D8-AE5D-0004755038D1', q1_absent=0, q1_abstained=0, q1_no=0, hangar_id=<OrderedDeclarationWrapper for <factory.declarations.Sequence object at 0x10baea690>>, date=datetime.date(2014, 6, 17), q1_yes=0)
SubFactory: Instantiating riksdagen.tests.factories.DocumentFactory(containers=(
Hmm, this doesn't seem to help :/
I think I'll need the description of the Document
model and the related DocumentFactory
...
Closing this issue as I won't be able to provide info any longer...
I have the following model setup in Django
The error I get when creating a
VotingFactory
is the crypticcolumn "hangar_id" specified more than once
. Any ideas for this?