Beispiel #1
0
 def test_cannot_save_a_zero_count_item(self):
     log_ = Log.objects.create()
     count = Step(log=log_, count='0')
     with self.assertRaises(ValidationError):
         count.save()
         count.full_clean()
Beispiel #2
0
    def test_saving_and_retrieving_steps(self):
        log_ =Log()
        log_.save()

        first_count = Step()
        first_count.count = 1234
        first_count.date = self.yesterday
        first_count.log = log_
        first_count.save()

        second_count = Step()
        second_count.count = 5678
        second_count.date = self.today
        second_count.log = log_
        second_count.save()


        saved_steps = Step.objects.all()
        self.assertEqual(saved_steps.count(), 2)

        first_saved_count = saved_steps[0]
        second_saved_count = saved_steps[1]

        self.assertEqual(first_saved_count.count, 1234)
        self.assertEqual(first_saved_count.date, self.yesterday)
        self.assertEqual(first_saved_count.log, log_)

        self.assertEqual(second_saved_count.count, 5678)
        self.assertEqual(second_saved_count.date, self.today)
        self.assertEqual(second_saved_count.log, log_)