def test_create_models(self):
        geoshape = ('45.56342779158167 -122.67650283873081 0.0 0.0;'
                    '45.56176327330353 -122.67669159919024 0.0 0.0;'
                    '45.56151562182025 -122.67490658909082 0.0 0.0;'
                    '45.563479432877415 -122.67494414001703 0.0 0.0;'
                    '45.56176327330353 -122.67669159919024 0.0 0.0')
        data = {
            'id': 'a1',
            'meta': {
                'instanceID': 'uuid:b3f225d3-0fac-4a0b-80c7-60e6db4cc0ad'
            },
            'version': str(self.questionnaire.version),
            'party_name': 'Party One',
            'party_type': 'IN',
            'party_attributes_individual': {
                'fname': False,
                'fname_two': 'socks',
            },
            'party_photo': 'sad_birthday.png',
            'party_resource_invite': 'invitation.pdf',
            'location_type': 'BU',
            'location_geometry': geoshape,
            'location_attributes': {
                'fname': False,
                'fname_two': 'Location One',
            },
            'location_photo': 'resource_one.png',
            'location_resource_invite': 'resource_two.pdf',
            'tenure_type': 'CO',
            'tenure_relationship_attributes': {
                'fname': False,
                'fname_two': 'Tenure One'
            },
            'tenure_resource_photo': 'resource_three.png'
        }

        (questionnaire,
         parties, party_resources,
         locations, location_resources,
         tenure_relationships, tenure_resources) = mh.create_models(mh(), data)

        assert questionnaire == self.questionnaire
        party = Party.objects.get(name='Party One')
        assert parties == [party]
        assert party_resources[0]['id'] == party.id
        assert 'sad_birthday.png' in party_resources[0]['resources']
        assert 'invitation.pdf' in party_resources[0]['resources']

        location = SpatialUnit.objects.get(type='BU')
        assert locations == [location]
        assert location_resources[0]['id'] == location.id
        assert 'resource_two.pdf' in location_resources[0]['resources']

        tenure = TenureRelationship.objects.get(spatial_unit=location)
        assert tenure_relationships == [tenure]
        assert tenure.party == party
        assert tenure_resources[0]['id'] == tenure.id
        assert 'resource_three.png' in tenure_resources[0]['resources']
    def test_create_models(self):
        geoshape = ('45.56342779158167 -122.67650283873081 0.0 0.0;'
                    '45.56176327330353 -122.67669159919024 0.0 0.0;'
                    '45.56151562182025 -122.67490658909082 0.0 0.0;'
                    '45.563479432877415 -122.67494414001703 0.0 0.0;'
                    '45.56176327330353 -122.67669159919024 0.0 0.0')
        data = {
            'id': 'a1',
            'version': str(self.questionnaire.version),
            'party_name': 'Party One',
            'party_type': 'IN',
            'party_attributes_individual': {
                'fname': False,
                'fname_two': 'socks',
            },
            'party_photo': 'sad_birthday.png',
            'party_resource_invite': 'invitation.pdf',
            'location_type': 'BU',
            'location_geometry': geoshape,
            'location_attributes': {
                'fname': False,
                'fname_two': 'Location One',
            },
            'location_photo': 'resource_one.png',
            'location_resource_invite': 'resource_two.pdf',
            'tenure_type': 'CO',
            'tenure_relationship_attributes': {
                'fname': False,
                'fname_two': 'Tenure One'
            },
            'tenure_resource_photo': 'resource_three.png'
        }

        (questionnaire, party_resources, location_resources,
         tenure_resources) = mh.create_models(mh(), data)

        assert questionnaire == self.questionnaire
        party = Party.objects.get(name='Party One')
        assert party_resources[0]['id'] == party.id
        assert 'sad_birthday.png' in party_resources[0]['resources']
        assert 'invitation.pdf' in party_resources[0]['resources']

        location = SpatialUnit.objects.get(type='BU')
        assert location_resources[0]['id'] == location.id
        assert 'resource_two.pdf' in location_resources[0]['resources']

        tenure = TenureRelationship.objects.get(spatial_unit=location)
        assert tenure.party == party
        assert tenure_resources[0]['id'] == tenure.id
        assert 'resource_three.png' in tenure_resources[0]['resources']
    def test_create_models(self):
        geoshape = ('45.56342779158167 -122.67650283873081 0.0 0.0;'
                    '45.56176327330353 -122.67669159919024 0.0 0.0;'
                    '45.56151562182025 -122.67490658909082 0.0 0.0;'
                    '45.563479432877415 -122.67494414001703 0.0 0.0;'
                    '45.56176327330353 -122.67669159919024 0.0 0.0')
        data = {
            'id': 'a1',
            'meta': {
                'instanceID': 'uuid:b3f225d3-0fac-4a0b-80c7-60e6db4cc0ad'
            },
            'version': str(self.questionnaire.version),
            'party_name': 'Party One',
            'party_type': 'IN',
            'party_attributes_individual': {
                'fname': False,
                'fname_two': 'socks',
            },
            'party_photo': 'sad_birthday.png',
            'party_resource_invite': 'invitation.pdf',
            'location_type': 'BU',
            'location_geometry': geoshape,
            'location_attributes': {
                'fname': False,
                'fname_two': 'Location One',
            },
            'location_photo': 'resource_one.png',
            'location_resource_invite': 'resource_two.pdf',
            'tenure_type': 'CO',
            'tenure_relationship_attributes': {
                'fname': False,
                'fname_two': 'Tenure One'
            },
            'tenure_resource_photo': 'resource_three.png'
        }

        user = UserFactory.create()
        OrganizationRole.objects.create(user=user,
                                        organization=self.project.organization,
                                        admin=True)

        (questionnaire, parties, party_resources, locations,
         location_resources, tenure_relationships,
         tenure_resources) = mh.create_models(mh(), data, user)

        assert questionnaire == self.questionnaire
        party = Party.objects.get(name='Party One')
        assert parties == [party]
        assert party_resources[0]['id'] == party.id
        assert 'sad_birthday.png' in party_resources[0]['resources']
        assert 'invitation.pdf' in party_resources[0]['resources']

        location = SpatialUnit.objects.get(type='BU')
        assert locations == [location]
        assert location_resources[0]['id'] == location.id
        assert 'resource_two.pdf' in location_resources[0]['resources']

        tenure = TenureRelationship.objects.get(spatial_unit=location)
        assert tenure_relationships == [tenure]
        assert tenure.party == party
        assert tenure_resources[0]['id'] == tenure.id
        assert 'resource_three.png' in tenure_resources[0]['resources']