Exemple #1
0
 def test_entry_archive_year(self):
     response=self.client.get(reverse('pomlog_entry_archive_year',kwargs={'year':'2010'}))
     self.assertEqual('Entries for the Year',get_context_variable(response,'page_title'))
     self.assertEqual('2010',get_context_variable(response,'year'))
     entries_page=get_context_variable(response,'entries')
     self.assertEquals(2,entries_page.paginator.count)
     
     response=self.client.get(reverse('pomlog_entry_archive_year',args=['2009']))
     entries_page=get_context_variable(response,'entries')
     self.assertEquals(1,entries_page.paginator.count)
     
     response=self.client.get(reverse('pomlog_entry_archive_year',args=['2008']))
     entries_page=get_context_variable(response,'entries')
     self.assertEquals(3,entries_page.paginator.count)
Exemple #2
0
 def test_can_view_shared_entry_detail(self):
     print 'test_can_view_shared_entry_detail()::'
     self.client.logout()
     self.client.login(username='sajan',password='sajan')
     user1=User.objects.get(username='sajan')
     user2=User.objects.get(username='denny')
     user1entries=PomEntry.objects.filter(author=user1)
     for entry in user1entries:
         self.assertTrue(user2 not in entry.sharedwith.all())
     self.share_selectedentries_post_data={
                             'sharing_options':[u'selectedentries'],
                             'users_selected': [u'2'],
                             'entries_selected': [u'2']
                           }
     response=self.client.post(reverse('pomlog_share_entries'),self.share_selectedentries_post_data)
     #user2 tries to view details of this entry
     self.client.logout()
     self.client.login(username='denny',password='denny')
     response2=self.client.get(reverse('pomlog_entry_detail',kwargs={'id':2}))
     obj=get_context_variable(response2,'object')
     self.assertTemplateUsed(response2,'pomlogger/pomentry_detail.html')
     self.assertEquals(200,response2.status_code)
     self.assertEqual('2010-05-13',str(obj.today))
     self.assertEqual('09:29:50',str(obj.start_time))
     self.client.logout()
Exemple #3
0
 def test_share_already_shared_entry(self):
     print 'test_share_already_shared_entry()::'
     self.client.logout()
     self.client.login(username='sajan',password='sajan')
     user1=User.objects.get(username='sajan')
     user2=User.objects.get(username='denny')
     user1entries=PomEntry.objects.filter(author=user1)
     for entry in user1entries:
         self.assertTrue(user2 not in entry.sharedwith.all())
     self.share_selectedentries_post_data={
                             'sharing_options':[u'selectedentries'],
                             'users_selected': [u'2'],
                             'entries_selected': [u'1']
                           }
     response=self.client.post(reverse('pomlog_share_entries'),self.share_selectedentries_post_data)
     self.share_repeat_selectedentries_post_data={
                             'sharing_options':[u'selectedentries'],
                             'users_selected': [u'2'],
                             'entries_selected': [u'1']
                           }
     print '..........trying to share the same entry again.......'
     response1=self.client.post(reverse('pomlog_share_entries'),self.share_repeat_selectedentries_post_data)
     self.assertRedirects(response1,reverse('pomlog_entry_archive_index'),status_code=302, target_status_code=200)
     self.client.logout()
     self.client.login(username='denny',password='denny')
     response2=self.client.get(reverse('pomlog_entries_shared'))
     ol=list(get_context_variable(response2,'entries_sharedto_me'))
     selected_entries=list(PomEntry.objects.filter(id=1))
     self.assertEqual(selected_entries,ol)
     self.client.logout()
Exemple #4
0
 def test_other_user_can_view_entries_of_cat(self):
     print 'test_other_user_can_view_entries_of_cat()::'
     self.client.logout()
     self.client.login(username='sajan',password='sajan')
     user1=User.objects.get(username='sajan')
     user2=User.objects.get(username='denny')
     user1entries=PomEntry.objects.filter(author=user1)
     for entry in user1entries:
         self.assertTrue(user2 not in entry.sharedwith.all())
     self.share_entries_with_cat_post_data={
                             'sharing_options':[u'entriesofcat'],
                             'users_selected': [u'2'],
                             'categories_selected': [u'2']
                           }
     response1=self.client.post(reverse('pomlog_share_entries'),self.share_entries_with_cat_post_data)
     self.assertRedirects(response1,reverse('pomlog_entry_archive_index'),status_code=302, target_status_code=200)
     self.client.logout()
     self.client.login(username='denny',password='denny')
     response2=self.client.get(reverse('pomlog_entries_shared'))
     ol=list(get_context_variable(response2,'entries_sharedto_me'))
     cat_shared=PomCategory.objects.get(id=2)
     #entries_shared=list(PomEntry.objects.filter(categories=cat_shared).filter(author=user1))
     entries_shared=list(PomEntry.objects.filter(author=user1,categories=cat_shared))
     self.assertEqual(entries_shared,ol)
     self.client.logout()
Exemple #5
0
 def test_entry_detail(self):
     response=self.client.get(reverse('pomlog_entry_detail',kwargs={'id':5}))
     obj=get_context_variable(response,'object')
     self.assertTemplateUsed(response,'pomlogger/pomentry_detail.html')
     self.assertEquals(200,response.status_code)
     self.assertEqual('2008-02-21',str(obj.today))
     self.assertEqual('09:00:00',str(obj.start_time))
Exemple #6
0
 def test_entry_archive_year_noentry(self):
     response=self.client.get(reverse('pomlog_entry_archive_year',kwargs={'year':'2000'}))
     #ol=get_context_variable(response,'object_list')
     #self.assertEquals(0,ol.count())
     entries_page=get_context_variable(response,'entries')
     self.assertEquals(0,entries_page.paginator.count)
     self.assertContains(response,'No Entries in 2000',status_code=200)
Exemple #7
0
 def test_entry_archive_day(self):
     '''
      should contain 2 entries
     '''
     response=self.client.get(reverse('pomlog_entry_archive_day',kwargs={'year':'2007','month':'mar','day':'13'}))
     entries_page=get_context_variable(response,'entries')
     self.assertEquals(2,entries_page.paginator.count)
     self.assertContains(response,'Entries for the day of 13 mar 2007',status_code=200)
Exemple #8
0
 def test_category_list_view(self):
     #print 'reverse=',reverse('pomlog_category_list')
     response=self.client.get(reverse('pomlog_category_list'))
     status_code=response.status_code
     #print 'st code=',status_code
     cats=get_context_variable(response,'cats')
     self.assertEqual(3,len(cats))
     self.assertEqual(200,status_code)
Exemple #9
0
 def __test_view_entries_of_user(self,user,passwd,expected_entries):
     userloggedin=self.client.login(username=user,password=passwd)
     if userloggedin:
         response=self.client.get(reverse('pomlog_entry_archive_index'))
         #ol=get_context_variable(response,'object_list')
         #self.assertEquals(expected_entries,ol.count())
         entries_page=get_context_variable(response,'entries')
         self.assertEquals(expected_entries,entries_page.paginator.count)
         self.client.logout()
Exemple #10
0
 def test_entry_archive_month(self):
     '''
     should contain 3 entries
     '''
     response=self.client.get(reverse('pomlog_entry_archive_month',kwargs={'year':'2008','month':'feb'}))
     #ol=get_context_variable(response,'object_list')
     #self.assertEquals(3,ol.count())# 3 entries in year 2008feb
     entries_page=get_context_variable(response,'entries')
     self.assertEquals(3,entries_page.paginator.count)
     self.assertContains(response,'Entries for the month of feb 2008',status_code=200)
Exemple #11
0
 def test_entry_archive_index(self):
     '''
     object_list should contain same num of entries as in database
     '''
     response=self.client.get(reverse('pomlog_entry_archive_index'))
     #ol=get_context_variable(response,'object_list')
     #self.assertEquals(8,ol.count())# 8 entries
     entries_page=get_context_variable(response,'entries')
     self.assertEquals(8,entries_page.paginator.count)
     self.assertContains(response,'All entries',status_code=200)
Exemple #12
0
 def test_add_entry_endtime_less_than_starttime(self):
     print 'test_add_entry_endtime_less_than_starttime()::'
     initialentrycount=PomEntry.objects.count()
     print 'initialentrycount=%d'%initialentrycount
     self.post_data['timerstopped']='1266643110000'                
     response=self.client.post(reverse('pomlog_add_entry'),self.post_data)        
     finalentrycount=PomEntry.objects.count()
     print 'finalentrycount=%d'%finalentrycount
     print 'status code=%d'%response.status_code
     erlst=get_context_variable(response,'errorlist')
     self.assertTrue('starttime should be less than endtime' in erlst)
     self.assertEqual(0,finalentrycount)
     self.assertEqual(200,response.status_code)
Exemple #13
0
 def test_entry_archive_day_noentry(self):
     response=self.client.get(reverse('pomlog_entry_archive_day',kwargs={'year':'2007','month':'mar','day':'14'}))
     entries_page=get_context_variable(response,'entries')
     
     self.assertEquals(0,entries_page.paginator.count)
     self.assertContains(response,'No Entries on 14 mar 2007',status_code=200)
Exemple #14
0
 def test_entry_archive_month_noentry(self):
     response=self.client.get(reverse('pomlog_entry_archive_month',kwargs={'year':'2007','month':'feb'}))
     # has 0 items
     entries_page=get_context_variable(response,'entries')
     self.assertEquals(0,entries_page.paginator.count)
     self.assertContains(response,'No Entries in feb 2007',status_code=200)