"""Tests for tondortools.raster — pure-computation functions."""
import math
import pytest

from tondortools.raster import get_wgs_resolution


_REF_10M = 0.0000898315   # the constant baked into the function


class TestGetWgsResolution:
    def test_default_is_30m(self):
        assert get_wgs_resolution() == pytest.approx(_REF_10M * 3)

    def test_10m_equals_reference(self):
        assert get_wgs_resolution(10) == pytest.approx(_REF_10M)

    def test_20m_is_double_reference(self):
        assert get_wgs_resolution(20) == pytest.approx(_REF_10M * 2)

    def test_30m_is_triple_reference(self):
        assert get_wgs_resolution(30) == pytest.approx(_REF_10M * 3)

    def test_60m_is_six_times_reference(self):
        assert get_wgs_resolution(60) == pytest.approx(_REF_10M * 6)

    def test_scales_linearly(self):
        r20 = get_wgs_resolution(20)
        r40 = get_wgs_resolution(40)
        assert r40 == pytest.approx(r20 * 2)

    def test_returns_float(self):
        assert isinstance(get_wgs_resolution(10), float)

    def test_string_pixel_size_accepted(self):
        # The function wraps pixel_size in int(), so strings work too.
        assert get_wgs_resolution("30") == pytest.approx(_REF_10M * 3)
