def test_create(self):
        # check that user 1 sees her lone app and user 2's app
        response = self.client.get('/v1/apps', HTTP_AUTHORIZATION='token {}'.format(self.token))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.data['results']), 2)
        app_id = response.data['results'][0]['id']
        # check that user 2 can only see his app
        response = self.client.get('/v1/apps', HTTP_AUTHORIZATION='token {}'.format(self.token2))
        self.assertEqual(len(response.data['results']), 1)
        # check that user 2 can't see any of the app's builds, configs,
        # containers, limits, or releases
        for model in ['builds', 'config', 'containers', 'releases']:
            response = self.client.get("/v1/apps/{}/{}/".format(app_id, model),
                                       HTTP_AUTHORIZATION='token {}'.format(self.token2))
            msg = (response.status_code, response.data) % "Failed: status '%s', and data '%s'"
            self.assertEqual(response.status_code, 403, msg=msg)
            self.assertEqual(response.data['detail'],
                             'You do not have permission to perform this action.', msg=msg)
        # TODO: test that git pushing to the app fails
        # give user 2 permission to user 1's app
        url = "/v1/apps/{}/perms".format(app_id)
        body = {'username': 'autotest-2'}
        response = self.client.post(url, json.dumps(body), content_type='application/json',
                                    HTTP_AUTHORIZATION='token {}'.format(self.token))
        self.assertEqual(response.status_code, 201)
        # check that user 2 can see the app
        response = self.client.get('/v1/apps', HTTP_AUTHORIZATION='token {}'.format(self.token2))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.data['results']), 2)
        # check that user 2 sees (empty) results now for builds, containers,
        # and releases. (config and limit will still give 404s since we didn't
        # push a build here.)
        for model in ['builds', 'containers', 'releases']:
            response = self.client.get("/v1/apps/{}/{}/".format(app_id, model),
                                       HTTP_AUTHORIZATION='token {}'.format(self.token2))
            self.assertEqual(len(response.data['results']), 0)
        # TODO:  check that user 2 can git push the app
dataset/ETHPy150Open deis/deis/controller/api/tests/test_perm.py/TestAppPerms.test_create/swapped operands of `%`