'Test layer remove functionality'

def test_layer_remove(self):

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