'Tests that deleting a layer with a shared default style will not cascade and
delete multiple layers.'

def test_non_cascading(self):

    layer1 = Layer.objects.get(pk=1)
    layer2 = Layer.objects.get(pk=2)
    url = reverse('layer_remove', args=(layer1.alternate,))
    layer1.default_style = Style.objects.get(pk=layer1.pk)
    layer1.save()
    layer2.default_style = Style.objects.get(pk=layer1.pk)
    layer2.save()
    self.assertEquals(layer1.default_style, layer2.default_style)
    self.client.login(username='admin', password='admin')
    response = self.client.post(url)
    self.assertEquals(response.status_code, 302)
    self.assertEquals(response['Location'], 'http://testserver/layers/')
    self.assertEquals(Layer.objects.filter(pk=layer1.pk).count(), 0)
    self.assertEquals(Layer.objects.filter(pk=2).count(), 1)
    self.assertEquals(Style.objects.count(), 1)
