diff --git a/ruterstop/__init__.py b/ruterstop/__init__.py
index 0c1986c..d1d7f24 100644
--- a/ruterstop/__init__.py
+++ b/ruterstop/__init__.py
@@ -134,6 +134,23 @@ def parse_departures(raw_dict, *, date_fmt="%Y-%m-%dT%H:%M:%S%z"):
 
 
 @webapp.route("/<stop_id:int>")
+def get_departures_proxy(*args, **kwargs):
+    """
+    A proxy function for get_departures to make get_departures mock-/patchable
+    even after decorated by bottle.
+    Calls get_departures with whitelisted kwargs defined in the querystring of
+    the current web request.
+    """
+    q = bottle.request.query
+
+    if q.direction:
+        kwargs["directions"] = q.direction
+    if q.min_eta:
+        kwargs["min_eta"] = int(q.min_eta)
+
+    return get_departures(*args, **kwargs)
+
+
 def get_departures(*, stop_id=None, directions=None, min_eta=0, text=True):
     """
     Returns a filtered list of departures. If `text` is True, return stringified

Send queryparams til API-funksjonskall
Så man f.eks kan filtrere på retning med `GET /1234?direction=inbound`
diff --git a/ruterstop/tests/test_webapp.py b/ruterstop/tests/test_webapp.py
index c79d47a..7f05385 100644
--- a/ruterstop/tests/test_webapp.py
+++ b/ruterstop/tests/test_webapp.py
@@ -1,14 +1,5 @@
-"""
-Note for webtest and bottle:
-Even though I'd ideally want to mock ruterstop.get_departures, that function
-is decorated with @bottle.get() on import-time, consequently wrapping the
-underlying function before it is patched/mocked.
-A work-around for this is to mock get_realtime_stop instead, as it is the
-first function called in get_departures, and use that to e.g. raise Exceptions
-as a side-effect.
-"""
 from unittest import TestCase
-from unittest.mock import patch
+from unittest.mock import Mock, patch
 
 from webtest import TestApp
 
@@ -24,28 +15,30 @@ class WebAppTestCase(TestCase):
         self.app.reset()
         pass
 
-    # The patchability of this module isn't great for this kind of test
-    @patch('ruterstop.get_realtime_stop', return_value={"data": "foobar"})
-    @patch('ruterstop.parse_departures', returl_value=[])
-    def test_calls_api_on_proper_path(self, parse_departures, get_realtime_stop):
-        res = self.app.get('/1234')
-        get_realtime_stop.assert_called_once_with(stop_id=1234)
+    @patch("ruterstop.get_departures", return_value=None)
+    def test_calls_api_on_proper_path(self, mock):
+        res = self.app.get("/1234")
+        mock.assert_called_once_with(stop_id=1234)
 
-    def test_simple_404_error(self):
-        res = self.app.get('/', expect_errors=True)
-        self.assertEqual(res.content_type, 'text/plain')
+    @patch("ruterstop.get_departures", return_value=None)
+    def test_simple_404_error(self, mock):
+        res = self.app.get("/", expect_errors=True)
+        self.assertEqual(res.content_type, "text/plain")
         self.assertEqual(res.status_code, 404)
-        self.assertTrue(str(res.body).count('\n') <= 1) # a single line of text
         self.assertEqual(res.body, "Ugyldig stoppested".encode())
-
-    def test_simple_500_error(self):
-        with patch('ruterstop.get_realtime_stop') as mock:
-            mock.side_effect = Exception("Trigger a 500")
-
-            res = self.app.get('/1234', expect_errors=True)
-            mock.assert_called_once()
-
-            self.assertEqual(res.content_type, 'text/plain')
-            self.assertEqual(res.status_code, 500)
-            self.assertTrue(str(res.body).count('\n') <= 1) # a single line of text
-            self.assertEqual(res.body, "Feil på serveren".encode())
+        self.assertEqual(mock.call_count, 0)
+
+    @patch("ruterstop.get_departures", return_value=None)
+    def test_simple_500_error(self, mock):
+        mock.side_effect = Exception("barf")
+        res = self.app.get("/1234", expect_errors=True)
+        self.assertEqual(res.content_type, "text/plain")
+        self.assertEqual(res.status_code, 500)
+        self.assertEqual(res.body, "Feil på serveren".encode())
+        self.assertEqual(mock.call_count, 1)
+
+    @patch("ruterstop.get_departures", return_value=None)
+    def test_calls_api_with_querystring_params(self, mock):
+        self.app.get("/1234?direction=inbound&min_eta=5&bogusargs=1337")
+        mock.assert_called_once_with(stop_id=1234, directions="inbound",
+                                     min_eta=5)

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
beautifulsoup4==4.13.3
bottle==0.13.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
coverage==7.2.7
exceptiongroup==1.2.2
freezegun==1.5.1
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
python-dateutil==2.9.0.post0
requests==2.31.0
-e git+https://github.com/stigok/ruterstop.git@01651a140d0639197dec3233ddaeb22ac0e2859a#egg=ruterstop
six==1.17.0
soupsieve==2.4.1
tomli==2.0.1
typing_extensions==4.7.1
urllib3==2.0.7
waitress==2.1.2
WebOb==1.8.9
WebTest==3.0.1
zipp==3.15.0

name: ruterstop
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - beautifulsoup4==4.13.3
      - bottle==0.13.2
      - charset-normalizer==3.4.1
      - coverage==7.2.7
      - exceptiongroup==1.2.2
      - freezegun==1.5.1
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - python-dateutil==2.9.0.post0
      - requests==2.31.0
      - six==1.17.0
      - soupsieve==2.4.1
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - waitress==2.1.2
      - webob==1.8.9
      - webtest==3.0.1
      - zipp==3.15.0
prefix: /opt/conda/envs/ruterstop

ruterstop/tests/test_webapp.py::WebAppTestCase::test_calls_api_on_proper_path ruterstop/tests/test_webapp.py::WebAppTestCase::test_calls_api_with_querystring_params ruterstop/tests/test_webapp.py::WebAppTestCase::test_simple_500_error
ruterstop/tests/test_webapp.py::WebAppTestCase::test_simple_404_error
ruterstop/__init__.py
ruterstop/__init__.py