from mlair.configuration.join_settings import join_settings

import pytest


class TestJoinSettings:

    def test_no_args(self):
        url, headers = join_settings()
        assert url == 'https://join.fz-juelich.de/services/rest/surfacedata/'
        assert headers == {}

    def test_daily(self):
        url, headers = join_settings("daily")
        assert url == 'https://join.fz-juelich.de/services/rest/surfacedata/'
        assert headers == {}

    def test_hourly(self):
        url, headers = join_settings("hourly")
        assert "Authorization" in headers.keys()

    def test_unknown_sampling(self):
        with pytest.raises(NameError) as e:
            join_settings("monthly")
        assert "Given sampling monthly is not supported, choose from either daily or hourly sampling" in e.value.args[0]