コード例 #1
0
    def test_filtering(self):
        """Verify checklists can be filtered."""
        today = timezone.now().date()
        yesterday = today - timedelta(days=1)

        ChecklistFactory(date=today, location=LocationFactory(name='C'))
        ChecklistFactory(date=today, location=LocationFactory(name='A'))
        ChecklistFactory(date=yesterday, location=LocationFactory(name='B'))
        result = checklists([Q(location__name='A')], self.order)
        self.assertEqual(1, len(result))
コード例 #2
0
    def test_ordering(self):
        """Verify checklists can be ordered."""
        today = timezone.now().date()
        yesterday = today - timedelta(days=1)

        ChecklistFactory(date=today, location=LocationFactory(name='C'))
        ChecklistFactory(date=today, location=LocationFactory(name='A'))
        ChecklistFactory(date=yesterday, location=LocationFactory(name='B'))

        expected = ['A', 'C', 'B']
        actual = [checklist.location.name for checklist
                  in checklists(order=self.order)]
        self.assertEqual(expected, actual)
コード例 #3
0
 def test_included(self):
     """Only checklist marked as included are fetched."""
     ChecklistFactory(include=False)
     ChecklistFactory(include=True)
     self.assertEqual(1, len(checklists()))