'Testing that the \'discard\' HREF goes to the correct place when it\'s
explicitely and implicitely set'

def test_discard_location(self):

    self.client.login(username='admin', password='testpass')
    def _create_doc(slug, locale):
        doc = document(slug=slug, is_localizable=True, locale=locale)
        doc.save()
        r = revision(document=doc)
        r.save()
        return doc
    doc = _create_doc('testdiscarddoc', settings.WIKI_DEFAULT_LANGUAGE)
    response = self.client.get(reverse('wiki.edit', args=[doc.slug], locale=doc.locale))
    eq_(pq(response.content).find('.btn-discard').attr('href'), reverse('wiki.document', args=[doc.slug], locale=doc.locale))
    response = self.client.get((reverse('wiki.translate', args=[doc.slug], locale=doc.locale) + '?tolocale=es'))
    eq_(pq(response.content).find('.btn-discard').attr('href'), reverse('wiki.document', args=[doc.slug], locale=doc.locale))
    foreign_doc = _create_doc('testdiscarddoc', 'es')
    response = self.client.get(reverse('wiki.edit', args=[foreign_doc.slug], locale=foreign_doc.locale))
    eq_(pq(response.content).find('.btn-discard').attr('href'), reverse('wiki.document', args=[foreign_doc.slug], locale=foreign_doc.locale))
    response = self.client.get(reverse('wiki.create', locale=settings.WIKI_DEFAULT_LANGUAGE))
    eq_(pq(response.content).find('.btn-discard').attr('href'), reverse('wiki.create', locale=settings.WIKI_DEFAULT_LANGUAGE))
