def test_diff_redirect_order(self, fgh):
        fgh.return_value = [{
            'notices': [{
                'document_number': '3'
            }, {
                'document_number': '2'
            }]
        }, {
            'notices': [{
                'document_number': '1'
            }]
        }]
        request = RequestFactory().get('?new_version=3')
        response = redirect.diff_redirect(request, '1111-22', '1')
        self.assertTrue('diff/1111-22/1/3' in response['Location'])
        self.assertTrue('from_version=1' in response['Location'])
        response = redirect.diff_redirect(request, '1111-22', '2')
        self.assertTrue('diff/1111-22/2/3' in response['Location'])
        self.assertTrue('from_version=2' in response['Location'])

        request = RequestFactory().get('?new_version=2')
        response = redirect.diff_redirect(request, '1111-22', '1')
        self.assertTrue('diff/1111-22/1/2' in response['Location'])
        self.assertTrue('from_version=1' in response['Location'])
        response = redirect.diff_redirect(request, '1111-22', '3')
        self.assertTrue('diff/1111-22/2/3' in response['Location'])
        self.assertTrue('from_version=3' in response['Location'])

        request = RequestFactory().get('?new_version=1')
        response = redirect.diff_redirect(request, '1111-22', '2')
        self.assertTrue('diff/1111-22/1/2' in response['Location'])
        self.assertTrue('from_version=2' in response['Location'])
        response = redirect.diff_redirect(request, '1111-22', '3')
        self.assertTrue('diff/1111-22/1/3' in response['Location'])
        self.assertTrue('from_version=3' in response['Location'])
    def test_diff_redirect_order(self, fgh):
        fgh.return_value = [
            {'notices': [{'document_number': '3'}, {'document_number': '2'}]},
            {'notices': [{'document_number': '1'}]}]
        request = RequestFactory().get('?new_version=3')
        response = redirect.diff_redirect(request, '1111-22', '1')
        self.assertTrue('diff/1111-22/1/3' in response['Location'])
        self.assertTrue('from_version=1' in response['Location'])
        response = redirect.diff_redirect(request, '1111-22', '2')
        self.assertTrue('diff/1111-22/2/3' in response['Location'])
        self.assertTrue('from_version=2' in response['Location'])

        request = RequestFactory().get('?new_version=2')
        response = redirect.diff_redirect(request, '1111-22', '1')
        self.assertTrue('diff/1111-22/1/2' in response['Location'])
        self.assertTrue('from_version=1' in response['Location'])
        response = redirect.diff_redirect(request, '1111-22', '3')
        self.assertTrue('diff/1111-22/2/3' in response['Location'])
        self.assertTrue('from_version=3' in response['Location'])

        request = RequestFactory().get('?new_version=1')
        response = redirect.diff_redirect(request, '1111-22', '2')
        self.assertTrue('diff/1111-22/1/2' in response['Location'])
        self.assertTrue('from_version=2' in response['Location'])
        response = redirect.diff_redirect(request, '1111-22', '3')
        self.assertTrue('diff/1111-22/1/3' in response['Location'])
        self.assertTrue('from_version=3' in response['Location'])
 def test_diff_redirect_bad_version(self):
     request = RequestFactory().get('?new_version=A+Bad+Version')
     response = redirect.diff_redirect(request, 'lablab', 'verver')
     self.assertEqual(404, response.status_code)
 def test_diff_redirect_bad_version(self):
     request = RequestFactory().get('?new_version=A+Bad+Version')
     response = redirect.diff_redirect(request, 'lablab', 'verver')
     self.assertEqual(404, response.status_code)