Say I have a cosine series defined on 0 to $L$:
$$ P(x) = \sum_{n=0}^\infty A(n)\cos \left ( \frac{n \pi x}{2L} \right ) = \delta(x) $$
Getting the coefficients:
$$ A(n) = \frac{2}{L} \int_0^{L} \delta(x) \cos \left ( \frac{n \pi x}{2L} \right ) = \frac{2}{L}. $$
So
$$P(x) = \frac{2}{L} \sum_{n=0}^\infty \cos \left( \frac{n \pi x }{2L} \right )$$
I would expect the integral here to be 1 (like the original delta function), but here I get:
\begin{align} \int_0^L P(x) dx &= \frac{2}{L} \sum_{n=0}^\infty \int_0^L \cos \left(\frac{n \pi x}{2L} \right) dx\\ &= \frac{2}{L} \sum_{n=0}^\infty \frac{2L}{n \pi} \sin \left( \frac{n \pi}{2} \right) \\ &= \frac{4}{\pi} \sum_{n=0}^\infty \frac{1}{2n+1}, \end{align}
which diverges.
Have I gone wrong somewhere?
The final line should read $$\frac{4}{\pi} \sum_{n=0}^{\infty} \frac{(-1)^n}{2n+1}$$ which is indeed $1$. You forgot to let $\sin(n\pi / 2)$ take negative values.