Пример #1
0
    def test_applications_PUT_ids_must_match(self):
        app = Application.get(1)
        self.req.swagger_data = {'id': 42, 'application': app}
        httpApps = Applications(self.req)
        response = httpApps.applications_PUT()

        assert response.status_code == 400
Пример #2
0
    def test_applications_PUT_application_must_exist(self):
        app = Application(id=42, name='Apperture Science')
        self.req.swagger_data = {'id': 42, 'application': app}
        httpApps = Applications(self.req)
        response = httpApps.applications_PUT()

        assert response.status_code == 400
Пример #3
0
    def test_applications_POST_apikey_is_set(self):
        self.req.swagger_data = {'application': Application(name='App 3')}
        httpApps = Applications(self.req)
        response = httpApps.applications_POST()

        expected = Application.get_by('name', 'App 3').as_dict()
        assert expected['apikey'] is not None
Пример #4
0
    def test_applications_PUT_exists(self):
        app = Application.get(1)
        self.req.swagger_data = {'id': 1, 'application': app}
        httpApps = Applications(self.req)
        response = httpApps.applications_PUT()

        assert response == app.as_dict()
Пример #5
0
    def test_applications_POST(self):
        self.req.swagger_data = {'application': Application(name='App 3')}
        httpApps = Applications(self.req)
        response = httpApps.applications_POST()

        expected = Application.get_by('name', 'App 3').as_dict()
        assert response == expected
Пример #6
0
    def test_application_POST_name_is_not_empty(self):
        expected_count = Application.query().count()

        self.req.swagger_data = {'application': Application(name='')}
        httpApps = Applications(self.req)
        response = httpApps.applications_POST()

        count_now = Application.query().count()
        assert expected_count == count_now
Пример #7
0
    def test_applications_DELETE_one(self):
        self.req.swagger_data = {'id': 1}
        httpApps = Applications(self.req)
        response = httpApps.applications_DELETE_one()
        assert response == {}

        self.req.swagger_data = {'id': 3}
        response = httpApps.applications_DELETE_one()
        assert response.status_code == 400
Пример #8
0
    def test_applications_PUT(self):
        app = Application.get(1)
        expected_app_name = 'It is now changed'
        app.name = expected_app_name

        self.req.swagger_data = {'id': 1, 'application': app}
        httpApps = Applications(self.req)
        response = httpApps.applications_PUT()

        assert Application.get(1).name == expected_app_name
Пример #9
0
    def test_data_for_app_GET(self):
        from toolz import assoc, concat
        self.req.swagger_data = {'id': 1}
        httpApps = Applications(self.req)
        response = httpApps.data_for_app_GET()

        app = Application.get(1)
        configurationkeys = app.configurationkeys
        ranges = list(concat(list(map(lambda _: _.rangeconstraints, configurationkeys))))

        app_data = app.as_dict()
        app_data = assoc(app_data, 'configurationkeys', list(map(lambda _: _.as_dict(), configurationkeys)))
        app_data = assoc(app_data, 'rangeconstraints', list(map(lambda _: _.as_dict(), ranges)))
        app_data = assoc(app_data, 'exclusionconstraints', list(map(lambda _: _.as_dict(), httpApps.get_app_exclusionconstraints(1))))

        assert response == app_data
Пример #10
0
    def test_applications_PUT(self):
        expected_name = 'Veri specil'

        self.req.swagger_data = {'application': Application(name=expected_name)}
        httpApps = Applications(self.req)
        httpApps.applications_POST()

        app = Application.get_by('name', expected_name)
        apikey = app.apikey
        id = app.id
        self.req.swagger_data = {'id': app.id, 'application': Application(name='', apikey=apikey, id=id)}
        httpApps.applications_PUT()

        name_now = Application.get(id).name
        assert name_now == expected_name
Пример #11
0
 def test_applications_GET(self):
     httpApps = Applications(self.req)
     response = httpApps.applications_GET()
     expected = list(map(lambda _: _.as_dict(), Application.all()))
     assert response == expected
Пример #12
0
 def test_applications_GET_one_apikey_not_none(self):
     self.req.swagger_data = {'id': 1}
     httpApps = Applications(self.req)
     response = httpApps.applications_GET_one()
     assert response['apikey'] != None
Пример #13
0
 def test_applications_GET_one(self):
     self.req.swagger_data = {'id': 1}
     httpApps = Applications(self.req)
     response = httpApps.applications_GET_one()
     expected = Application.get(1).as_dict()
     assert response == expected