当前位置: 首页>>代码示例>>Python>>正文


Python Paper.save方法代码示例

本文整理汇总了Python中papers.models.Paper.save方法的典型用法代码示例。如果您正苦于以下问题:Python Paper.save方法的具体用法?Python Paper.save怎么用?Python Paper.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在papers.models.Paper的用法示例。


在下文中一共展示了Paper.save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_email_has_more_than_five_questions_with_three_questions

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
	def test_email_has_more_than_five_questions_with_three_questions(self):
		'''
		Method will return true if 5 or more papers exist for a certain e-mail.
		E-Mail is passed as a string for a count query. Creating 3 papers.
		'''
		sent_from = Sender(email="[email protected]", ip="10.10.50.50")
		sent_from.save()
		for x in range(3):
			paper = Paper(sender=sent_from, sent_to="[email protected]", active_until=timezone.now())
			paper.save()		
		self.assertEqual(email_has_more_than_five_questions_open('[email protected]'), False)
开发者ID:thingdeux,项目名称:doubleblind,代码行数:13,代码来源:tests.py

示例2: setUp

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
    def setUp(self):
        #Create test user but don't login.
        self.user = User.objects.create_user('test', '[email protected]', 'test')

        self.data = {'user': self.user, 'title': 'Test Title', 'url':
                'http://example.com', 'journal': 'Journal of Test', 'year':
                '2011', 'volume': '1', 'authors': 
                "Author One\nAuthor Two\nAuthor Three", 'issue': '2', 'pages':
                '3-4', }

        p = Paper(**self.data) #unpack dictionary to arguments
        p.save()
开发者ID:mikexstudios,项目名称:papersdb,代码行数:14,代码来源:exists.py

示例3: test_display_only_user_own_papers

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
    def test_display_only_user_own_papers(self):
        '''
        Make sure that the list of papers only displays the ones that the logged
        in user has added (and not someone else's papers).
        '''
        #Add another paper under a different user (than the currently logged in 
        #one).
        data = self.data.copy()
        second_user = User.objects.create_user('test2', '[email protected]', 'test2')
        data['user'] = second_user
        data['title'] = 'Second Unique Title'
        p = Paper(**data) #unpack dictionary to arguments
        p.save()

        #Make sure that the added paper does not show up in dashboard.
        r = self.client.get('/papers/', {})
        self.assertNotContains(r, data['title'])

        #Remove the second user's upload directory recursively. This also gets
        #rid of any test uploads.
        path = os.path.join(settings.UPLOAD_ROOT, second_user.username)
        shutil.rmtree(path)
开发者ID:mikexstudios,项目名称:papersdb,代码行数:24,代码来源:views.py

示例4: setUp

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
    def setUp(self):
        #We want to mock the crocodoc API library so that our tests don't have
        #to actually issue HTTP requests.
        self.patcher = mock.patch('crocodoc.Crocodoc')
        Mock = self.patcher.start()
        self.crocodoc_instance = Mock.return_value
        self.crocodoc_instance.upload.return_value = {'shortId': 'yQZpPm', 
                'uuid': '8e5b0721-26c4-11df-b354-002170de47d3'}
        self.crocodoc_instance.get_session.return_value = {'sessionId': 
                'fgH9qWEwnsJUeB0'}
        self.crocodoc_instance.delete.return_value = True

        #Create and login test user.
        self.user = User.objects.create_user('test', '[email protected]', 'test')
        self.client.login(username = 'test', password = 'test')

        self.data = {'user': self.user, 'title': 'Test Title', 'url':
                'http://example.com', 'journal': 'Journal of Test', 'year':
                '2011', 'volume': '1', 'authors': 
                "Author One\nAuthor Two\nAuthor Three", 'issue': '2', 'pages':
                '3-4', }

        p = Paper(**self.data) #unpack dictionary to arguments
        p.save()
开发者ID:mikexstudios,项目名称:papersdb,代码行数:26,代码来源:views.py

示例5: create_new_paper

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
def create_new_paper(**kwargs):	
	if email_has_more_than_five_questions_open(kwargs['sent_to']):
		#Do not create a new paper and return http response with error code 400		
		response = HttpResponse()
		response.status_code = 400
		response.reason_phrase = "Too many questions open for this e-mail"
		return response
	else:	#Insert Data into DB		
		#See if a DB record from the sender already exists.
		the_sender = checkExistingEmail(kwargs['sender'])			
		the_sender.ip = kwargs['ip']		
		the_sender.save()

		new_paper = Paper(sender=the_sender, sent_to=kwargs['sent_to'])
		new_paper.code = uuid.uuid4()
		new_paper.save()
		new_question = Question(sender=the_sender, paper=new_paper, question_text=kwargs['question'],
								question_type=kwargs['question_type'])		
		new_question.save()
		new_answers = create_answers_objects(the_sender, new_paper, new_question, 
											kwargs['answers'], kwargs['selected_answer'])		
				
		test = Answer.objects.bulk_create(new_answers)
		test.save()
开发者ID:thingdeux,项目名称:doubleblind,代码行数:26,代码来源:views.py

示例6: PaperShowTest

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
class PaperShowTest(TestCase):

    def setUp(self):
        #Bypass the celery daemon and directly test synchronously.
        settings.CELERY_ALWAYS_EAGER = True

        #Set Crocodoc upload method to POST
        settings.CROCODOC_UPLOAD_METHOD = 'post'

        #We want to mock the crocodoc API library so that our tests don't have
        #to actually issue HTTP requests.
        self.patcher = mock.patch('crocodoc.Crocodoc')
        Mock = self.patcher.start()
        self.crocodoc_instance = Mock.return_value
        self.crocodoc_instance.upload.return_value = {'shortId': 'yQZpPm', 
                'uuid': '8e5b0721-26c4-11df-b354-002170de47d3'}
        self.crocodoc_instance.get_session.return_value = {'sessionId': 
                'fgH9qWEwnsJUeB0'}
        self.crocodoc_instance.delete.return_value = True

        #Create and login test user.
        self.user = User.objects.create_user('test', '[email protected]', 'test')
        self.client.login(username = 'test', password = 'test')

        #Create a new paper entry with associated file.
        upload_filename = 'blank.pdf'
        self.data = {'user': self.user, 'title': 'Test Title', 'url':
                'http://example.com', 'journal': 'Journal of Test', 'year':
                '2011', 'volume': '1', 'authors': 
                "Author One\nAuthor Two\nAuthor Three", 'issue': '2', 'pages':
                '3-4', 'file': upload_filename }

        self.p = Paper(**self.data) #unpack dictionary to arguments
        self.p.save()

        #Now let's copy the dummy upload file from the test files location path
        #to the uploaded file location
        to_path = os.path.join(settings.UPLOAD_ROOT, self.p.user.username, self.p.hash)
        from_path = os.path.join(settings.SITE_ROOT, 'papers', 'tests',
                                 'files')
        os.makedirs(to_path, mode = 0755)
        shutil.copy2(os.path.join(from_path, upload_filename), to_path)
        self.uploaded_file = os.path.join(to_path, upload_filename)

        #Generate thumbnail and upload to crocodoc
        self.p.save()

        #Reload data
        self.p = Paper.objects.get(pk = self.p.id)

    def tearDown(self):
        #Delete the crocodoc uploaded paper
        try:
            self.p.crocodoc.delete()
        except AssertionError:
            #If we try to delete an already deleted object (like when we test
            #delete), we need to catch this error so that the test doesn't 
            #fail.
            pass

        #Stop patching process
        self.patcher.stop()

        #Remove the user's upload directory recursively. This also gets rid of 
        #any test uploads.
        path = os.path.join(settings.UPLOAD_ROOT, self.user.username)
        shutil.rmtree(path)
    
    def test_quickview_download_link_shown(self):
        '''
        If the paper has a crocodoc upload, then quickview link should be shown.
        If the paper has a file uploaded, then the download link should be shown.
        '''
        r = self.client.get('/papers/%i/' % self.p.local_id, {})
        self.assertContains(r, reverse('Paper#quickview', args=[self.p.local_id]))
        self.assertContains(r, reverse('Paper#download', args=[self.p.local_id]))

    def test_quickview_link_not_shown(self):
        '''
        If the paper does not have a crocodoc object, then quickview link should
        not be shown. The download link should still be shown.
        '''
        #Manually delete crocodoc object.
        self.p.crocodoc.delete()
        self.p = Paper.objects.get(pk = self.p.id)

        r = self.client.get('/papers/%i/' % self.p.local_id, {})
        self.assertNotContains(r, reverse('Paper#quickview', args=[self.p.local_id]))
        self.assertContains(r, reverse('Paper#download', args=[self.p.local_id]))

    def test_download_link_not_shown(self):
        '''
        If the paper does not have an upload associated with it, then neither
        quickview nor download links should be shown.
        '''
        #Delete crocodoc and clear uploaded file.
        self.p.crocodoc.delete()
        self.p.file = ''
        self.p.save()
        self.p = Paper.objects.get(pk = self.p.id)
#.........这里部分代码省略.........
开发者ID:mikexstudios,项目名称:papersdb,代码行数:103,代码来源:views.py

示例7: PapersEditTest

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
class PapersEditTest(TestCase):

    def setUp(self):
        #Bypass the celery daemon and directly test synchronously.
        settings.CELERY_ALWAYS_EAGER = True

        #Set Crocodoc upload method to POST
        settings.CROCODOC_UPLOAD_METHOD = 'post'

        #We want to mock the crocodoc API library so that our tests don't have
        #to actually issue HTTP requests.
        self.patcher = mock.patch('crocodoc.Crocodoc')
        Mock = self.patcher.start()
        self.crocodoc_instance = Mock.return_value
        self.crocodoc_instance.upload.return_value = {'shortId': 'yQZpPm', 
                'uuid': '8e5b0721-26c4-11df-b354-002170de47d3'}
        self.crocodoc_instance.get_session.return_value = {'sessionId': 
                'fgH9qWEwnsJUeB0'}
        self.crocodoc_instance.delete.return_value = True

        #Create and login test user.
        self.user = User.objects.create_user('test', '[email protected]', 'test')
        self.client.login(username = 'test', password = 'test')

        #Create a new paper entry with associated file.
        upload_filename = 'blank.pdf'
        self.data = {'user': self.user, 'title': 'Test Title', 'url':
                'http://example.com', 'journal': 'Journal of Test', 'year':
                '2011', 'volume': '1', 'authors': 
                "Author One\nAuthor Two\nAuthor Three", 'issue': '2', 'pages':
                '3-4', 'file': upload_filename }

        self.p = Paper(**self.data) #unpack dictionary to arguments
        self.p.save()

        #Now let's copy the dummy upload file from the test files location path
        #to the uploaded file location
        to_path = os.path.join(settings.UPLOAD_ROOT, self.p.user.username, self.p.hash)
        from_path = os.path.join(settings.SITE_ROOT, 'papers', 'tests',
                                 'files')
        os.makedirs(to_path, mode = 0755)
        shutil.copy2(os.path.join(from_path, upload_filename), to_path)
        self.uploaded_file = os.path.join(to_path, upload_filename)

        #Generate thumbnail and upload to crocodoc
        self.p.save()

    def tearDown(self):
        #Delete the crocodoc uploaded paper
        try:
            self.p.crocodoc.delete()
        except AssertionError:
            #If we try to delete an already deleted object (like when we test
            #delete), we need to catch this error so that the test doesn't 
            #fail.
            pass

        #Remove the user's upload directory recursively. This also gets rid of 
        #any test uploads.
        path = os.path.join(settings.UPLOAD_ROOT, self.user.username)
        shutil.rmtree(path)

        #Stop patching process
        self.patcher.stop()

    def test_resave_form_no_upload(self):
        '''
        Resave the form without re-uploading a file.
        '''
        #crocodoc information should not change. Let's save the old information:
        old_uuid = self.p.crocodoc.uuid

        #Change the data slightly so that we can verify that the update occurred.
        data = self.data.copy()
        data['title'] = 'Test Title 2'
        r = self.client.post(reverse('Paper#update', args=[self.p.local_id]), data)
        self.assertRedirects(r, reverse('Paper#show', args=[self.p.local_id]))

        #Verify that the update did in-fact occur. Need to first refresh our 
        #object though.
        self.p = Paper.objects.get(pk = self.p.pk)
        self.assertEqual(self.p.title, data['title'])

        #Make sure that crocodoc information did not change (since we didn't
        #upload a new file).
        self.assertEqual(old_uuid, self.p.crocodoc.uuid)

    def test_resave_form_with_upload(self):
        '''
        Test resaving when the only thing that changes is uploading a new file.
        The expected behavior is that the existing file is deleted and the new
        file is copied to the paper directory.
        '''
        #crocodoc information should change. Let's save the old information:
        old_uuid = self.p.crocodoc.uuid

        #TODO: Test that the thumbnail information has changed.

        #This is a dummy blank pdf that's different from the dummy PDF file
        #tha we already used.
#.........这里部分代码省略.........
开发者ID:mikexstudios,项目名称:papersdb,代码行数:103,代码来源:views.py

示例8: PaperModelTest

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
class PaperModelTest(TestCase):

    def setUp(self):
        #Bypass the celery daemon and directly test synchronously.
        settings.CELERY_ALWAYS_EAGER = True

        #We want to mock the crocodoc API library so that our tests don't have
        #to actually issue HTTP requests.
        self.patcher = mock.patch('crocodoc.Crocodoc')
        Mock = self.patcher.start()
        self.crocodoc_instance = Mock.return_value
        self.crocodoc_instance.upload.return_value = {'shortId': 'yQZpPm', 
                'uuid': '8e5b0721-26c4-11df-b354-002170de47d3'}
        self.crocodoc_instance.get_session.return_value = {'sessionId': 
                'fgH9qWEwnsJUeB0'}
        self.crocodoc_instance.delete.return_value = True

        #Create and login test user.
        self.user = User.objects.create_user('test', '[email protected]', 'test')
        self.client.login(username = 'test', password = 'test')

        #Create a new paper entry with associated file.
        upload_filename = 'blank.pdf'
        self.data = {'user': self.user, 'title': 'Test Title', 'url':
                'http://example.com', 'journal': 'Journal of Test', 'year':
                '2011', 'volume': '1', 'authors': 
                "Author One\nAuthor Two\nAuthor Three", 'issue': '2', 'pages':
                '3-4', 'file': upload_filename }

        self.p = Paper(**self.data) #unpack dictionary to arguments
        self.p.save()

        #Now let's copy the dummy upload file from the test files location path
        #to the uploaded file location
        #NOTE: Even though we may not generate a thumbnail. It is still good to 
        #      place a dummy file so that the thumbnail generation task can run
        #      successfully if called in the right conditions.
        to_path = os.path.join(settings.UPLOAD_ROOT, self.p.user.username, self.p.hash)
        from_path = os.path.join(settings.SITE_ROOT, 'papers', 'tests',
                                 'files')
        os.makedirs(to_path, mode = 0755)
        shutil.copy2(os.path.join(from_path, upload_filename), to_path)
        self.uploaded_file = os.path.join(to_path, upload_filename)

    def tearDown(self):
        #Remove the user's upload directory recursively. This also gets rid of 
        #any test uploads.
        path = os.path.join(settings.UPLOAD_ROOT, self.user.username)
        shutil.rmtree(path)

        #Stop patching process
        self.patcher.stop()

    def test_generate_thumbnail_no_file(self):
        '''
        Call the generate thumbnail task on the new paper with no file associated
        with that paper. We expect nothing to occur and that the task returns 
        False.
        '''
        self.p.file = ''
        self.p.save()

        r = self.p.generate_thumbnail()
        self.assertFalse(r)
        self.assertFalse(self.p.has_thumbnail)
开发者ID:mikexstudios,项目名称:papersdb,代码行数:67,代码来源:models.py

示例9: CrocodocTests

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
class CrocodocTests(TestCase):
    '''
    NOTE: At the same time, we end up testing some of the Crocodoc model methods.
    It may be a good idea to just test the task here without going through the
    Crocodoc model, but there is just so much overlap.
    '''

    def setUp(self):
        #Bypass the celery daemon and directly test synchronously.
        settings.CELERY_ALWAYS_EAGER = True

        #Set Crocodoc upload method to POST
        settings.CROCODOC_UPLOAD_METHOD = 'post'
        
        #We want to mock the crocodoc API library so that our tests don't have
        #to actually issue HTTP requests.
        self.patcher = mock.patch('crocodoc.Crocodoc')
        Mock = self.patcher.start()
        self.crocodoc_instance = Mock.return_value
        self.crocodoc_instance.upload.return_value = {'shortId': 'yQZpPm', 
                'uuid': '8e5b0721-26c4-11df-b354-002170de47d3'}
        self.crocodoc_instance.get_session.return_value = {'sessionId': 
                'fgH9qWEwnsJUeB0'}
        self.crocodoc_instance.delete.return_value = True

        #Create and login test user.
        self.user = User.objects.create_user('test', '[email protected]', 'test')
        self.client.login(username = 'test', password = 'test')

        #Create a new paper entry with associated file.
        upload_filename = 'blank.pdf'
        self.data = {'user': self.user, 'title': 'Test Title', 'url':
                'http://example.com', 'journal': 'Journal of Test', 'year':
                '2011', 'volume': '1', 'authors': 
                "Author One\nAuthor Two\nAuthor Three", 'issue': '2', 'pages':
                '3-4', 'file': upload_filename }

        self.p = Paper(**self.data) #unpack dictionary to arguments
        self.p.save()
        #uploading to crocodoc will fail here since the file does not exist (we
        #add it below).

        #Now let's copy the dummy upload file from the test files location path
        #to the uploaded file location
        to_path = self.p.get_file_dir()
        from_path = os.path.join(settings.SITE_ROOT, 'papers', 'tests',
                                 'files')
        os.makedirs(to_path, mode = 0755)
        shutil.copy2(os.path.join(from_path, upload_filename), to_path)
        self.uploaded_file = os.path.join(to_path, upload_filename)

        #We should re-save the Paper here to automatically generate thumbnail
        #and upload to crocodoc. But we don't since we are testing the
        #uploading to crocodoc.

    def tearDown(self):
        #Delete the crocodoc uploaded paper
        try:
            self.p.crocodoc.delete()
        except AssertionError:
            #If we try to delete an already deleted object (like when we test
            #delete), we need to catch this error so that the test doesn't 
            #fail.
            pass

        #Remove the user's upload directory recursively. This also gets rid of 
        #any test uploads.
        path = os.path.join(settings.UPLOAD_ROOT, self.user.username)
        shutil.rmtree(path)

        #Stop patching process
        self.patcher.stop()

    def test_crocodoc_upload_paper_post(self):
        '''
        Call the upload task on the new paper. The task should return
        True and short_id and uuid of the paper should be set.

        NOTE: We are using the POST method of uploading papers because there
        is not an easy way of testing the url method of uploading.

        NOTE: This test may not be very necessary since the act of saving 
        the file above automatically uploads the paper to crocodoc.
        '''
        r = self.p.crocodoc.upload()
        self.assertTrue(r.get()) #wait until task is done and get result

        #Need to refresh our object because of the upload.
        self.p = Paper.objects.get(pk = self.p.pk)

        self.assertTrue(len(self.p.crocodoc.short_id) > 4)
        self.assertTrue(len(self.p.crocodoc.uuid) == 36)
        #And that we also have a session_id
        self.assertTrue(len(self.p.crocodoc.session_id) == 15)

    def test_crocodoc_get_session_id(self):
        '''
        Call the get_session_id task on the new paper. The task should return
        True and the session_id should be different.
        '''
#.........这里部分代码省略.........
开发者ID:mikexstudios,项目名称:papersdb,代码行数:103,代码来源:tasks.py

示例10: GenerateThumbnailTest

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
class GenerateThumbnailTest(TestCase):

    def setUp(self):
        #Bypass the celery daemon and directly test synchronously.
        settings.CELERY_ALWAYS_EAGER = True

        #Set Crocodoc upload method to POST
        settings.CROCODOC_UPLOAD_METHOD = 'post'

        #We want to mock the crocodoc API library so that our tests don't have
        #to actually issue HTTP requests.
        self.patcher = mock.patch('crocodoc.Crocodoc')
        Mock = self.patcher.start()
        self.crocodoc_instance = Mock.return_value
        self.crocodoc_instance.upload.return_value = {'shortId': 'yQZpPm', 
                'uuid': '8e5b0721-26c4-11df-b354-002170de47d3'}
        self.crocodoc_instance.get_session.return_value = {'sessionId': 
                'fgH9qWEwnsJUeB0'}
        self.crocodoc_instance.delete.return_value = True

        #Create and login test user.
        self.user = User.objects.create_user('test', '[email protected]', 'test')
        self.client.login(username = 'test', password = 'test')

        #Create a new paper entry with associated file.
        upload_filename = 'blank.pdf'
        self.data = {'user': self.user, 'title': 'Test Title', 'url':
                'http://example.com', 'journal': 'Journal of Test', 'year':
                '2011', 'volume': '1', 'authors': 
                "Author One\nAuthor Two\nAuthor Three", 'issue': '2', 'pages':
                '3-4', 'file': upload_filename }
        self.p = Paper(**self.data) #unpack dictionary to arguments
        self.p.save()

        #Now let's copy the dummy upload file from the test files location path
        #to the uploaded file location
        to_path = self.p.get_file_dir()
        from_path = os.path.join(settings.SITE_ROOT, 'papers', 'tests',
                                 'files')
        os.makedirs(to_path, mode = 0755)
        shutil.copy2(os.path.join(from_path, upload_filename), to_path)
        self.uploaded_file = os.path.join(to_path, upload_filename)

    def tearDown(self):
        #Remove the user's upload directory recursively. This also gets rid of 
        #any test uploads.
        path = os.path.join(settings.UPLOAD_ROOT, self.user.username)
        shutil.rmtree(path)

        #Stop patching process
        self.patcher.stop()

    def test_generate_thumbnail(self):
        '''
        Call the generate thumbnail task on the new paper. The task should return
        True and the thumbnail should be generated.
        '''
        r = tasks.generate_paper_thumbnail.delay(self.p)
        self.assertTrue(r.get()) #wait until task is done and get result

        #Refresh paper object
        self.p = Paper.objects.get(pk = self.p.pk)
        self.assertTrue(self.p.has_thumbnail)

        paper_dir = self.p.get_file_dir()
        thumbnail_file = os.path.join(paper_dir, settings.THUMBNAIL_FILENAME % self.p.hash)
        self.assertTrue(os.path.exists(thumbnail_file))
开发者ID:mikexstudios,项目名称:papersdb,代码行数:69,代码来源:tasks.py

示例11: PageExistsTest

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import save [as 别名]
class PageExistsTest(TestCase):

    def setUp(self):
        #Create and login test user.
        self.user = User.objects.create_user('test', '[email protected]', 'test')
        self.client.login(username = 'test', password = 'test')

        #Create a sample paper
        self.data = {'user': self.user, 'title': 'Test Title', 'url':
                'http://example.com', 'journal': 'Journal of Test', 'year':
                '2011', 'volume': '1', 'authors': 
                "Author One\nAuthor Two\nAuthor Three", 'issue': '2', 'pages':
                '3-4', }

        self.paper = Paper(**self.data) #unpack dictionary to arguments
        self.paper.save()

    def tearDown(self):
        pass

    def test_static_assets_exists(self):
        r = self.client.get('/static/css/screen.css', {})
        self.assertEqual(r.status_code, 200)

        r = self.client.get('/static/css/print.css', {})
        self.assertEqual(r.status_code, 200)

        r = self.client.get('/static/css/buttons.css', {})
        self.assertEqual(r.status_code, 200)

        #TODO: Make favicon.
        r = self.client.get('/favicon.ico', {})
        self.assertEqual(r.status_code, 404)

    def test_dashboard_exists(self):
        r = self.client.get('/papers/', {})
        self.assertEqual(r.status_code, 200)

    def test_papers_new_manual_exists(self):
        r = self.client.get('/papers/new/manual/', {})
        self.assertEqual(r.status_code, 200)

        #Also make sure that a form is being shown. Just check for a Title field
        #in the form. Assume if 'Title' exists, rest of the form does too.
        self.assertTrue(re.search('Title', str(r.context['self'].form)))

    def test_papers_new_auto_exists(self):
        r = self.client.get('/papers/new/', {})
        self.assertEqual(r.status_code, 200)

        #Also make sure that a form is being shown.
        self.assertTrue(re.search('URL', str(r.context['self'].form)))

    def test_papers_view_exists(self):
        r = self.client.get('/papers/%s/' % self.paper.local_id, {})
        self.assertEqual(r.status_code, 200)

        self.assertEqual(r.context['self'].paper.title, self.paper.title) 

    def test_papers_edit_exists(self):
        r = self.client.get('/papers/%s/edit/' % self.paper.local_id, {})
        self.assertEqual(r.status_code, 200)

        self.assertTrue(re.search('Title', str(r.context['self'].form)))
开发者ID:mikexstudios,项目名称:papersdb,代码行数:66,代码来源:exists.py


注:本文中的papers.models.Paper.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。