Esempio n. 1
0
    def test_push_experiment_to_kinto_sends_fenix_experiment_data(self):
        experiment = NimbusExperimentFactory.create_with_status(
            NimbusExperiment.Status.DRAFT,
            application=NimbusExperiment.Application.FENIX,
            population_percent=Decimal("50.0"),
        )

        tasks.nimbus_push_experiment_to_kinto(experiment.id)

        self.assertEqual(experiment.bucket_range.start, 0)
        self.assertEqual(experiment.bucket_range.count, 5000)

        data = NimbusExperimentSerializer(experiment).data

        self.mock_kinto_client.create_record.assert_called_with(
            data=data,
            collection=settings.KINTO_COLLECTION_NIMBUS_MOBILE,
            bucket=settings.KINTO_BUCKET,
            if_not_exists=True,
        )

        self.assertTrue(
            NimbusChangeLog.objects.filter(
                experiment=experiment,
                changed_by__email=settings.KINTO_DEFAULT_CHANGELOG_USER,
                old_status=NimbusExperiment.Status.DRAFT,
                new_status=NimbusExperiment.Status.ACCEPTED,
            ).exists())
Esempio n. 2
0
    def test_push_experiment_to_kinto_sends_desktop_experiment_data_and_sets_accepted(
        self, ):
        experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE,
            application=NimbusExperiment.Application.DESKTOP,
        )

        tasks.nimbus_push_experiment_to_kinto(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP, experiment.id)

        data = NimbusExperimentSerializer(experiment).data

        self.mock_kinto_client.create_record.assert_called_with(
            data=data,
            collection=settings.KINTO_COLLECTION_NIMBUS_DESKTOP,
            bucket=settings.KINTO_BUCKET_WORKSPACE,
            if_not_exists=True,
        )

        experiment = NimbusExperiment.objects.get(id=experiment.id)
        self.assertEqual(experiment.publish_status,
                         NimbusExperiment.PublishStatus.WAITING)
        self.assertTrue(
            experiment.changes.filter(
                old_publish_status=NimbusExperiment.PublishStatus.APPROVED,
                new_publish_status=NimbusExperiment.PublishStatus.WAITING,
                message=NimbusChangeLog.Messages.LAUNCHING_TO_KINTO,
            ).exists())
Esempio n. 3
0
 def test_push_experiment_to_kinto_reraises_exception(self):
     experiment = NimbusExperimentFactory.create(
         publish_status=NimbusExperiment.PublishStatus.APPROVED, )
     self.mock_kinto_client.create_record.side_effect = Exception
     with self.assertRaises(Exception):
         tasks.nimbus_push_experiment_to_kinto(
             settings.KINTO_COLLECTION_NIMBUS_DESKTOP, experiment.id)
Esempio n. 4
0
    def test_push_experiment_to_kinto_sends_fenix_experiment_data(self):
        experiment = NimbusExperimentFactory.create_with_lifecycle(
            NimbusExperimentFactory.Lifecycles.LAUNCH_APPROVE,
            application=NimbusExperiment.Application.DESKTOP,
        )

        tasks.nimbus_push_experiment_to_kinto(
            settings.KINTO_COLLECTION_NIMBUS_DESKTOP, experiment.id
        )

        data = NimbusExperimentSerializer(experiment).data

        self.mock_kinto_client.create_record.assert_called_with(
            data=data,
            collection=settings.KINTO_COLLECTION_NIMBUS_DESKTOP,
            bucket=settings.KINTO_BUCKET_WORKSPACE,
            if_not_exists=True,
        )
Esempio n. 5
0
 def test_push_experiment_to_kinto_reraises_exception(self):
     experiment = NimbusExperimentFactory.create_with_status(
         NimbusExperiment.Status.DRAFT, )
     self.mock_kinto_client.create_record.side_effect = Exception
     with self.assertRaises(Exception):
         tasks.nimbus_push_experiment_to_kinto(experiment.id)