Exemple #1
0
    def test_share_experiment(self):
        """ Test share experiment. """

        post_data = {
            "name": "test experiment",
            "run_id": "2b89911e867c42818b02e1426023a7e6",
            "metrics": [
                {"name": "test metric", "value": 0.1},
                {"name": "test metric 2", "value": 2}
            ],
            "parameters": [
                {"name": "test parameter", "value": "test parameter value"},
                {"name": "test parameter 2", "value": "test paraeter value 2"}
            ],
            "counts": [
                {"name": "measurement", "value": {"00": 1024, "11": 0}}
            ],
            "entrypoint": None
        }

        request = self.factory.post("/api/v1/core/experiments/share/", json.dumps(post_data),
                                    content_type='application/json')
        view = ExperimentViewSet.as_view({'post': 'share'})
        force_authenticate(request, user=self.sample_user)
        response = view(request)

        self.assertEqual(response.status_code, 200)
Exemple #2
0
    def test_experiments_list_unauthorized(self):
        """ Test experiment list unauthorized. """
        request = self.factory.get("/api/v1/core/experiments")
        view = ExperimentViewSet.as_view({'get': 'list'})
        response = view(request)

        self.assertEqual(response.status_code, 401)
        self.assertEqual(response.status_text, "Unauthorized")
Exemple #3
0
    def test_experiment_list_authorized(self):
        """ Test experiment list. """
        request = self.factory.get("/api/v1/core/experiments")
        view = ExperimentViewSet.as_view({'get': 'list'})
        force_authenticate(request, user=self.sample_user)
        response = view(request)

        self.assertEqual(response.data["count"], len(self.experiments))
        self.assertEqual(len(response.data["results"]), len(self.experiments))