import pytest
from mock import patch


@pytest.fixture
def url(route_url):
    return route_url('wifi_setup')


def test_get_scanned_wifi(browser, url):
    assert browser.get_json(url).json == ['grandpausethisnetwork']


@pytest.fixture
def no_such_wifi(settings):
    settings['wifi_networks_path'] = '/no/such/file'
    return settings


def test_get_scanned_wifi_empty(no_such_wifi, browser, url):
    assert browser.get_json(url).json == []


@pytest.yield_fixture(autouse=True)
def mocked_run(request):
    """don't run actual external commands during these tests
    """
    with patch('senic.nuimo_hub.views.setup_wifi.run')\
            as mocked_run:
        yield mocked_run


def test_join_wifi(browser, url, mocked_run, settings):
    browser.post_json(url, dict(
        ssid='grandpausethisnetwork',
        password='foobar',
        device='wlan0')).json
    mocked_run.assert_called_once_with(
        [
            'sudo',
            '%s/join_wifi' % settings['bin_path'],
            '-c {fs_config_ini}'.format(**settings),
            'grandpausethisnetwork',
            'foobar',
        ]
    )

@@ -52,16 +52,22 @@
 ure%0Adef 
+setup_
 url(rout
@@ -70,24 +70,24 @@
 route_url):%0A
-
     return r
@@ -138,32 +138,38 @@
 d_wifi(browser, 
+setup_
 url):%0A    assert
@@ -178,32 +178,38 @@
 rowser.get_json(
+setup_
 url).json == %5B'g
@@ -407,16 +407,22 @@
 rowser, 
+setup_
 url):%0A  
@@ -447,16 +447,22 @@
 et_json(
+setup_
 url).jso
@@ -739,16 +739,22 @@
 rowser, 
+setup_
 url, moc
@@ -795,16 +795,22 @@
 st_json(
+setup_
 url, dic

Make `url` fixture less generic