'Ensure that navigating to a URL route correctly updates the page
content.'

@ddt.data(('browse', '.topics-list'), ('teams/{topic_id}/{team_id}', 'div.discussion-module'), ('topics/{topic_id}/create-team', 'div.create-team-instructions'), ('topics/{topic_id}', '.teams-list'), ('not-a-real-route', 'div.warning'))
@ddt.unpack
def test_url_routing(self, route, selector):

    topics = self.create_topics(1)
    topic = topics[0]
    self.set_team_configuration({u'max_team_size': 10, u'topics': topics})
    team = self.create_teams(topic, 1)[0]
    self.teams_page.visit()
    url = self.browser.current_url
    fragment_index = url.find('#')
    if (fragment_index >= 0):
        url = url[0:fragment_index]
    self.browser.get('{url}#{route}'.format(url=url, route=route.format(topic_id=topic['id'], team_id=team['id'])))
    self.teams_page.wait_for_page()
    self.teams_page.wait_for_ajax()
    self.assertTrue(self.teams_page.q(css=selector).present)
    self.assertTrue(self.teams_page.q(css=selector).visible)
