コード例 #1
0
    def test_experimentgroup_GET_nonexistent_experiment(self):
        self.req.swagger_data = {'appid': 1, 'expid': 2}
        httpExperiments = Experiments(self.req)
        response = httpExperiments.experimentgroup_GET()
        expected = 400

        assert response.status_code == expected
コード例 #2
0
 def test_experiment_DELETE_nonexistent_experiment(self):
     self.req.swagger_data = {'appid': 1, 'expid': 2}
     print(self.req.matchdict)
     httpExperiments = Experiments(self.req)
     response = httpExperiments.experiment_DELETE()
     assert response.status_code == 400
     assert response.json == None
コード例 #3
0
 def test_experiments_GET_one(self):
     httpExperiments = Experiments(self.req)
     self.req.swagger_data = {'appid': 1, 'expid': 1}
     response = httpExperiments.experiments_GET_one()
     expected = Experiment.get(1).as_dict()
     expected['status'] = 'running'
     assert response == expected
コード例 #4
0
    def test_experimentgroup_GET(self):
        self.req.swagger_data = {'appid': 1, 'expid': 1}
        httpExperiments = Experiments(self.req)
        response = httpExperiments.experimentgroup_GET()
        expected = list(map(lambda _: _.as_dict(), \
                    ExperimentGroup.query().join(Experiment).join(Application)\
                    .filter(Application.id == 1, Experiment.id == 1).all()))

        assert response == expected
コード例 #5
0
 def test_clients_for_experiment_GET(self):
     self.req.swagger_data = {'appid': 1, 'expid': 1}
     httpExperiments = Experiments(self.req)
     response = httpExperiments.clients_for_experiment_GET()
     clients = [{
         'id': 1,
         'clientname': 'First client'
     }, {
         'id': 2,
         'clientname': 'Second client'
     }]
     assert response == clients
コード例 #6
0
    def test_experiments_GET(self):
        httpExperiments = Experiments(self.req)
        self.req.swagger_data = {'appid': 1}
        response = httpExperiments.experiments_GET()
        experiment = response[0]

        assert len(response) == 1
        assert experiment['id'] == 1
        assert experiment['name'] == 'Test experiment'
        assert experiment['startDatetime'] == '2016-01-01 00:00:00'
        assert experiment['endDatetime'] == '2017-01-01 00:00:00'
        assert experiment['status'] == 'running'
コード例 #7
0
 def test_experimentgroup_GET_one(self):
     self.req.swagger_data = {'appid': 1, 'expgroupid': 1, 'expid': 1}
     httpExperiments = Experiments(self.req)
     response = httpExperiments.experimentgroup_GET_one()
     experimentgroup = {
         'id':
         1,
         'name':
         'Group A',
         'experiment_id':
         1,
         'configurations': [{
             'experimentgroup_id': 1,
             'key': 'v1',
             'id': 1,
             'value': 0.5
         }, {
             'experimentgroup_id': 1,
             'key': 'v2',
             'id': 2,
             'value': True
         }],
         'dataitems': [{
             'id': 1,
             'client_id': 1,
             'key': 'key1',
             'value': 10,
             'startDatetime': '2016-01-01 00:00:00',
             'endDatetime': '2016-01-01 01:01:01',
             'client': {
                 'id': 1,
                 'clientname': 'First client'
             }
         }, {
             'id': 2,
             'client_id': 1,
             'key': 'key2',
             'value': 0.5,
             'startDatetime': '2016-02-02 01:01:02',
             'endDatetime': '2016-02-02 02:02:02',
             'client': {
                 'id': 1,
                 'clientname': 'First client'
             }
         }],
         'clients': [{
             'id': 1,
             'clientname': 'First client'
         }]
     }
     assert response == experimentgroup
コード例 #8
0
    def test_experiments_POST(self):
        self.req.swagger_data = {
            'appid':
            1,
            'experiment':
            Experiment(name='Example Experiment',
                       startDatetime=datetime.datetime(2016, 1, 1, 0, 0, 0),
                       endDatetime=datetime.datetime(2017, 1, 1, 0, 0, 0))
        }
        httpExperiments = Experiments(self.req)
        response = httpExperiments.experiments_POST()
        experiment = Experiment.get_by('name', 'Example Experiment').as_dict()

        assert response == experiment
コード例 #9
0
 def test_experimentgroup_DELETE_nonexistent_experiment_and_experimentgroup(
         self):
     self.req.swagger_data = {'appid': 1, 'expid': 2, 'expgroupid': 2}
     httpExperiments = Experiments(self.req)
     response = httpExperiments.experimentgroup_DELETE()
     assert response.status_code == 400
コード例 #10
0
 def test_experimentgroup_DELETE(self):
     self.req.swagger_data = {'appid': 1, 'expid': 1, 'expgroupid': 1}
     httpExperiments = Experiments(self.req)
     response = httpExperiments.experimentgroup_DELETE()
     assert response == {}
コード例 #11
0
 def test_experimentgroup_GET_one_nonexistent_experiment(self):
     self.req.swagger_data = {'appid': 1, 'expgroupid': 1, 'expid': 2}
     httpExperiments = Experiments(self.req)
     response = httpExperiments.experimentgroup_GET_one()
     assert response.status_code == 400
     assert response.json == None
コード例 #12
0
 def test_clients_for_experiment_GET_nonexistent_experiment(self):
     self.req.swagger_data = {'appid': 1, 'expid': 2}
     httpExperiments = Experiments(self.req)
     response = httpExperiments.clients_for_experiment_GET()
     assert response.status_code == 400
     assert response.json == None