Keep completed experiments in experiments.json fixes #73

This commit is contained in:
Jared Kerim 2017-06-21 11:19:05 -04:00 коммит произвёл Jared Kerim
Родитель dd1db67b0b
Коммит 8a9f04da9c
2 изменённых файлов: 22 добавлений и 8 удалений

Просмотреть файл

@ -8,7 +8,8 @@ from django.db import models
class ExperimentManager(models.Manager):
def started(self):
return self.get_queryset().filter(status=Experiment.EXPERIMENT_STARTED)
return self.get_queryset().filter(status__in=(
Experiment.EXPERIMENT_STARTED, Experiment.EXPERIMENT_COMPLETE))
class Experiment(models.Model):

Просмотреть файл

@ -11,8 +11,17 @@ class TestExperimentListView(TestCase):
def test_list_view_returns_started_experiments_for_project(self):
project = ProjectFactory.create()
started_experiments = []
# unstarted experiments should be excluded
for i in range(2):
ExperimentFactory.create_with_variants()
# another projects experiments should be excluded
for i in range(2):
ExperimentFactory.create_with_variants(project=project)
# started experiments should be included
for i in range(3):
experiment = ExperimentFactory.create_with_variants(
project=project)
@ -20,13 +29,17 @@ class TestExperimentListView(TestCase):
experiment.save()
started_experiments.append(experiment)
# another projects experiments should be excluded
for i in range(2):
ExperimentFactory.create_with_variants()
# completed experiments should be included
for i in range(3):
experiment = ExperimentFactory.create_with_variants(
project=project)
experiment.status = experiment.EXPERIMENT_STARTED
experiment.save()
# instarted experiments should be excluded
for i in range(2):
ExperimentFactory.create_with_variants(project=project)
experiment.status = experiment.EXPERIMENT_COMPLETE
experiment.save()
started_experiments.append(experiment)
response = self.client.get(
reverse('experiments-list', kwargs={'project_slug': project.slug}))