Exemplo n.º 1
0
    def test_publishrequest_permalink(self):
        r = PublishRequest.objects.create(
            requestor="Permalink Test",
            resource_type=self.model.resource_type,
            language=self.model.language,
            checking_level=1,
            source_text=self.model.source_text)

        permalink = r.permalink
        decoded_pk = PublishRequest.pk_from_permalink(permalink)
        decoded_pk2 = PublishRequest.pk_from_permalink(unicode(permalink))
        self.assertEqual(r.pk, decoded_pk)
        self.assertEqual(r.pk, decoded_pk2)
    def test_get_context_data(self):
        client = Client()
        response = client.get(reverse('publish_request_resubmit', args=[self.pub_req.permalink]))

        self.assertIsNotNone(response.context_data['publishrequest'])

        # check the permalink value to be sure it is the one we requested
        found_permalink = response.context_data['publishrequest'].permalink
        self.assertEqual(self.pub_req.permalink, found_permalink)

        # check the method for decoding the permalink back to the pk
        pk_from_permalink = PublishRequest.pk_from_permalink(found_permalink)
        self.assertEqual(self.pub_req.pk, pk_from_permalink)
Exemplo n.º 3
0
    def test_get_context_data(self):
        client = Client()
        response = client.get(
            reverse('publish_request_resubmit', args=[self.pub_req.permalink]))

        self.assertIsNotNone(response.context_data['publishrequest'])

        # check the permalink value to be sure it is the one we requested
        found_permalink = response.context_data['publishrequest'].permalink
        self.assertEqual(self.pub_req.permalink, found_permalink)

        # check the method for decoding the permalink back to the pk
        pk_from_permalink = PublishRequest.pk_from_permalink(found_permalink)
        self.assertEqual(self.pub_req.pk, pk_from_permalink)
 def get_object(self, queryset=None):
     self.permalink = self.kwargs.get('permalink')
     pk = PublishRequest.pk_from_permalink(self.permalink)
     request = get_object_or_404(self.model, id=pk)
     return request
 def get_object(self, queryset=None):
     self.permalink = self.kwargs.get('permalink')
     pk = PublishRequest.pk_from_permalink(self.permalink)
     request = get_object_or_404(self.model, id=pk)
     return request