Example #1
0
def populate():
    ProfileFactory.create_batch(size=10)
    PostFactory.create_batch(size=4)
    PostImageFactory.create_batch(size=16)
    PaperFactory.create_batch(size=10)

    for p in Post.objects.all():
        print(p)
    print("...population finished")
Example #2
0
    def test_PaperBibTexDownloadView(self):
        test_paper = PaperFactory.create(publish=True)
        url = reverse('research:paper_bibtex', kwargs={"slug": test_paper.slug})
        response = self.client.get(url)

        self.assertEqual(response.status_code, 200)
        self.assertTrue('attachment; filename=' and '.bib' in response.get('Content-Disposition'))
Example #3
0
    def test_PaperListView(self):
        test_paper = PaperFactory.create(publish=True)
        url = reverse('research:paper_list')
        response = self.client.get(url)

        self.assertEqual(response.status_code, 200)
        self.assertTrue('paper_list' in response.context)
        self.assertIn(test_paper, response.context['paper_list'])
Example #4
0
    def test_properties(self):
        test_paper = PaperFactory(papertype='Article', title='Test title', publish=True,
                                  authors__first_name='Peter', authors__last_name='File',
                                  authors__homepage='http://www.test.com',
                                  authors__email='*****@*****.**', authors__affiliation='Test school',
                                  keywords=['keyword1', 'keyword2'])
        self.assertTrue(isinstance(test_paper, Paper))
        self.assertEqual(test_paper.__str__(), test_paper.title)
        self.assertEqual(test_paper.slug, 'test-title')
        self.assertTrue(test_paper.first_author in test_paper.pdf.name)
        self.assertEqual(test_paper.get_mime_type(), 'application/pdf')
        self.assertTrue('Peter File' in test_paper.author_names)
        self.assertTrue('http://www.test.com' in test_paper.author_homepages)
        self.assertTrue('keyword1' and 'keyword2' in test_paper.keyword_list)

        for x in range(3):
            previous_count = test_paper.downloaded
            previous_date = test_paper.last_downloaded
            test_paper.increment_downloads()
            current_count = test_paper.downloaded
            current_date = test_paper.last_downloaded
            self.assertGreater(current_count, previous_count)
            self.assertGreater(current_date, previous_date)
Example #5
0
    def test_PaperPdfDownloadView(self):
        test_paper = PaperFactory.create(publish=True, authors__last_name='File')
        url = reverse('research:paper_pdf', kwargs={"slug": test_paper.slug})
        response = self.client.get(url)
        model_url = test_paper.get_absolute_url()
        model_response = self.client.get(model_url)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(model_response.status_code, 200)
        self.assertTrue('attachment; filename=' and '.pdf' in response.get('Content-Disposition'))

        query_kwargs = {'view': 'True'}
        pdf_view_url = '{0}?{1}'.format(url, urlencode(query_kwargs))
        pdf_view_response = self.client.get(pdf_view_url)
        self.assertEqual(pdf_view_response.status_code, 200)