@@ -0,0 +1,2190 @@
+from unittest import TestCase%0Afrom uuid import uuid4%0A%0Aimport mock%0A%0Afrom unicore.hub.client import App%0A%0A%0Aclass AppTestCase(TestCase):%0A    app_data = %7B%0A        'uuid': uuid4().hex,%0A        'title': 'Foo',%0A        'groups': %5B'group:apps_manager'%5D%0A    %7D%0A%0A    def create_app(self, app_client=None, **data_overrides):%0A        data = self.app_data.copy()%0A        data.update(data_overrides)%0A%0A        if not app_client:%0A            app_client = mock.Mock()%0A%0A        return App(app_client, data)%0A%0A    def test_set(self):%0A        app = self.create_app()%0A%0A        # check that immutable fields cannot be set%0A        for field in ('uuid', 'password'):%0A            with self.assertRaisesRegexp(ValueError, 'cannot be set'):%0A                app.set(field, 'new_%25s' %25 field)%0A%0A        # check that other fields can be set%0A        app.set('title', 'New Foo')%0A        self.assertEqual(app.data%5B'title'%5D, 'New Foo')%0A%0A    def test_get(self):%0A        app = self.create_app()%0A%0A        with self.assertRaises(KeyError):%0A            app.get('doesnotexist')%0A%0A        self.assertEqual(self.app_data%5B'title'%5D, app.get('title'))%0A%0A    def test_save(self):%0A        app = self.create_app()%0A        app.save()%0A%0A        app.client.save_app_data.assert_called_with(%0A            self.app_data%5B'uuid'%5D, self.app_data)%0A%0A    def test_refresh(self):%0A        app = self.create_app()%0A        new_app_data = %7B%0A            'uuid': self.app_data%5B'uuid'%5D,%0A            'title': 'New Foo',%0A            'groups': %5B%5D,%0A        %7D%0A        self.assertNotEqual(app.data, new_app_data)%0A%0A        app.client.get_app_data = mock.Mock()%0A        app.client.get_app_data.return_value = new_app_data%0A        app.refresh()%0A        app.client.get_app_data.assert_called_with(self.app_data%5B'uuid'%5D)%0A        self.assertEqual(app.data, new_app_data)%0A%0A    def test_reset_password(self):%0A        app = self.create_app()%0A        app.client.reset_app_password = mock.Mock()%0A        app.client.reset_app_password.return_value = 'new_password'%0A%0A        password = app.reset_password()%0A        app.client.reset_app_password.assert_called_with(self.app_data%5B'uuid'%5D)%0A        self.assertEqual(password, 'new_password')%0A        self.assertNotIn('password', app.data)%0A

test App object