# encoding: utf-8
from __future__ import absolute_import, division, print_function, unicode_literals

import pytest

import turbasen

@pytest.fixture
def configure_dev():
    turbasen.configure(ENDPOINT_URL='http://dev.nasjonalturbase.no/')

@pytest.fixture
def no_etag_cache():
    turbasen.configure(ETAG_CACHE_PERIOD=0)

@pytest.mark.skipif(turbasen.settings.Settings.API_KEY is None, reason="API key not set")
def test_get_sted(configure_dev):
    sted = turbasen.Sted.get('52407fb375049e561500004e')
    assert sted.navn == 'Tjørnbrotbu'
    assert sted.ssr_id == 382116

@pytest.mark.skipif(turbasen.settings.Settings.API_KEY is None, reason="API key not set")
def test_get_gruppe(configure_dev):
    gruppe = turbasen.Gruppe.get('52407f3c4ec4a13815000173')
    assert gruppe.navn == 'Alta og omegn turlag'

@pytest.mark.skipif(turbasen.settings.Settings.API_KEY is None, reason="API key not set")
def test_get_omrade(configure_dev):
    omrade = turbasen.Omrade.get('52408144e7926dcf15000004')
    assert omrade.navn == 'Sørlandet'

@pytest.mark.skipif(turbasen.settings.Settings.API_KEY is None, reason="API key not set")
def test_refresh(configure_dev, no_etag_cache):
    sted = turbasen.Sted.get('52407fb375049e561500004e')
    etag = sted._etag
    sted.refresh()
    assert etag == sted._etag

@pytest.mark.skipif(turbasen.settings.Settings.API_KEY is None, reason="API key not set")
def test_lookup(configure_dev):
    results = turbasen.Sted.lookup(pages=2)
    result_list = list(results)
    assert len(result_list) == turbasen.settings.Settings.LIMIT * 2
    assert result_list[0].object_id != ''

@@ -1033,16 +1033,799 @@
 andet'%0A%0A
+@pytest.mark.skipif(turbasen.settings.Settings.API_KEY is None, reason=%22API key not set%22)%0Adef test_post(configure_dev):%0A    sted = turbasen.Sted(%0A        lisens='Privat',%0A        status='Kladd',%0A        navn='Testhytta',%0A        geojson=%7B%0A            'properties': %7B'altitude': -999%7D, 'type': 'Point', 'coordinates': %5B12.18104163626816, 60.368712513406365%5D%0A        %7D,%0A        fylke='Testfylket',%0A        beskrivelse='Testhytta er en opplevelse for seg selv',%0A        tags=%5B%5D,%0A        bilder=%5B%5D,%0A    )%0A    assert sted.object_id is None%0A%0A    # POST the object and see that we've now defined its object_id%0A    sted.save()%0A    assert sted.object_id is not None%0A%0A    # See that we can retrieve our POSTed data%0A    assert sted.beskrivelse == turbasen.Sted.get(sted.object_id).beskrivelse%0A%0A
 @pytest.

Add POST test