コード例 #1
0
 def testFindEntries(self):
     """
     Given a list of users and a starting point, entries should generate a
     list of all entries for each user from that time until now.
     """
     start = check_entries.Command().find_start()
     if start.day == 1:
         start += timedelta(days=1)
     all_people = check_entries.Command().find_people()
     entries = check_entries.Command().find_entries(all_people, start)
     #Determine the number of days checked
     today = timezone.now() - \
         relativedelta(hour=0, minute=0, second=0, microsecond=0)
     diff = today - start
     days_checked = diff.days
     total_entries = 0
     while True:
         try:
             person_entries = entries.next()
             for entry in person_entries:
                 total_entries += 1
         except StopIteration:
             #Verify that every entry from the start point was returned
             expected_total = days_checked * len(self.all_users)
             self.assertEqual(total_entries, expected_total)
             return
コード例 #2
0
 def testFindStart(self):
     """
     With various kwargs, find_start should return the correct date
     """
     #Establish some datetimes
     now = timezone.now()
     today = now - relativedelta(hour=0, minute=0, second=0, microsecond=0)
     last_billing = today - relativedelta(months=1, day=1)
     yesterday = today - relativedelta(days=1)
     ten_days_ago = today - relativedelta(days=10)
     thisweek = utils.get_week_start(today)
     thismonth = today - relativedelta(day=1)
     thisyear = today - relativedelta(month=1, day=1)
     #Use command flags to obtain datetimes
     start_default = check_entries.Command().find_start()
     start_yesterday = check_entries.Command().find_start(days=1)
     start_ten_days_ago = check_entries.Command().find_start(days=10)
     start_of_week = check_entries.Command().find_start(week=True)
     start_of_month = check_entries.Command().find_start(month=True)
     start_of_year = check_entries.Command().find_start(year=True)
     #assure the returned datetimes are correct
     self.assertEqual(start_default, last_billing)
     self.assertEqual(start_yesterday, yesterday)
     self.assertEqual(start_ten_days_ago, ten_days_ago)
     self.assertEqual(start_of_week, thisweek)
     self.assertEqual(start_of_month, thismonth)
     self.assertEqual(start_of_year, thisyear)
コード例 #3
0
 def testCheckEntry(self):
     """
     Given lists of entries from users, check_entry should return all
     overlapping entries.
     """
     start = check_entries.Command().find_start()
     all_people = check_entries.Command().find_people()
     entries = check_entries.Command().find_entries(all_people, start)
     total_overlaps = 0
     #make some bad entries
     num_days = 5
     self.make_entry_bulk(self.all_users, num_days)
     while True:
         try:
             person_entries = entries.next()
             user_overlaps = check_entries.Command().check_entry(
                 person_entries, verbosity=0)
             total_overlaps += user_overlaps
         except StopIteration:
             self.assertEqual(total_overlaps,
                              num_days * len(self.all_users))
             return
コード例 #4
0
 def testFindPeople(self):
     """
     With args, find_people should search and return those user objects
     Without args, find_people should return all user objects
     """
     #Find one person by icontains first or last name, return all if no args
     people1 = check_entries.Command().find_people('firsT1')
     people2 = check_entries.Command().find_people('LasT2')
     all_people = check_entries.Command().find_people()
     #obtain instances from the querysets
     person1 = people1.get(pk=self.user.pk)
     person2 = people2.get(pk=self.user2.pk)
     all_1 = all_people.get(pk=self.user.pk)
     all_2 = all_people.get(pk=self.user2.pk)
     all_3 = all_people.get(pk=self.superuser.pk)
     self.assertEqual(people1.count(), 1)
     self.assertEqual(people2.count(), 1)
     self.assertEqual(all_people.count(), 3)
     self.assertEqual(person1, self.user)
     self.assertEqual(person2, self.user2)
     self.assertEqual(all_1, person1)
     self.assertEqual(all_2, person2)
     self.assertEqual(all_3, self.superuser)
コード例 #5
0
 def testFindUsers(self):
     """
     With args, find_users should search and return those user objects
     Without args, find_users should return all user objects
     """
     #Find one user by icontains first or last name, return all if no args
     users1 = check_entries.Command().find_users('firsT1')
     users2 = check_entries.Command().find_users('LasT2')
     all_users = check_entries.Command().find_users()
     #obtain instances from the querysets
     user1 = users1.get(pk=self.user.pk)
     user2 = users2.get(pk=self.user2.pk)
     all_1 = all_users.get(pk=self.user.pk)
     all_2 = all_users.get(pk=self.user2.pk)
     all_3 = all_users.get(pk=self.superuser.pk)
     self.assertEqual(users1.count(), 1)
     self.assertEqual(users2.count(), 1)
     self.assertEqual(all_users.count(), 3)
     self.assertEqual(user1, self.user)
     self.assertEqual(user2, self.user2)
     self.assertEqual(all_1, user1)
     self.assertEqual(all_2, user2)
     self.assertEqual(all_3, self.superuser)