def test_get_activities_should_return_activities_within_days(self): habit = self.create_habit() self.add_activity(habit, 20.0) self.add_activity(habit, update_date=ModelTests.two_days_ago) h = models.get_activities(1) expect(h[0].activities_prefetch).to.have.length_of(1) expect(h[0].activities_prefetch[0].quantum).to.equal(20.0)
def test_get_activities_should_return_activities_sorted(self): habit = self.create_habit() a1 = self.add_activity(habit, 20.0, ModelTests.one_day_ago) a2 = self.add_activity(habit, 1.0, ModelTests.two_days_ago) a3 = self.add_activity(habit, 10.0, ModelTests.one_day_ago) h = models.get_activities(3) expect(h[0].activities_prefetch).to.equal([a1, a3, a2])
def test_get_activities_should_return_activities_sorted(self): habit = self.create_habit() a1 = self.add_activity(habit, 20.0, ModelTests.one_day_ago) a2 = self.add_activity(habit, 1.0, ModelTests.two_days_ago) a3 = self.add_activity(habit, 10.0, ModelTests.one_day_ago) h = models.get_activities(3) assert h[0].activities == [a1, a3, a2]
def test_get_activities_should_return_activities_within_days(self): habit = self.create_habit() self.add_activity(habit, 20.0) self.add_activity(habit, update_date=ModelTests.two_days_ago) h = models.get_activities(1) assert len(h[0].activities) == 1 assert h[0].activities[0].quantum == 20.0
def test_get_activities_should_return_empty_for_no_activities(self): self.create_habit() ha = models.get_activities(1) expect(ha[0].activities_prefetch).to.empty
def test_get_activities_should_return_empty_for_no_activities(self): self.create_habit() ha = models.get_activities(1) assert len(ha[0].activities) == 0
def test_get_activities_raises_for_invalid_days(self): with pytest.raises(ValueError): models.get_activities(-1)