'Test utility function set_attributes() which creates Attribute instances attached
to a Layer instance.'

def test_set_attributes_creates_attributes(self):

    self.client.login(username='norman', password='norman')
    disconnected_post_save = signals.post_save.disconnect(geoserver_post_save, sender=Layer)
    l = Layer.objects.create(name='dummy_layer')
    if disconnected_post_save:
        signals.post_save.connect(geoserver_post_save, sender=Layer)
    attribute_map = [['id', 'Integer'], ['date', 'IntegerList'], ['enddate', 'Real'], ['date_as_date', 'xsd:dateTime']]
    expected_results = copy.deepcopy(attribute_map)
    set_attributes(l, attribute_map)
    self.assertEquals(l.attributes.count(), len(expected_results))
    for a in l.attributes:
        self.assertIn([a.attribute, a.attribute_type], expected_results)
