Beispiel #1
0
    def test_profile(self):
        name = "dummy_profile_name %d" % time.time()
        copyname = "copy_%s" % name
        renamedname = "move_%s" % name
        dummy_profile = {"aaa": [1, 2, 3]}
        io.run_sync(profile.Upload(self.storage, name, dummy_profile).execute,
                    timeout=2)

        io.run_sync(profile.Copy(self.storage, name, copyname).execute,
                    timeout=2)
        io.run_sync(profile.Rename(self.storage, copyname,
                                   renamedname).execute,
                    timeout=2)

        listing = io.run_sync(profile.List(self.storage).execute, timeout=2)
        assert isinstance(listing, (list, tuple)), listing
        assert name in listing
        assert copyname not in listing
        assert renamedname in listing

        pr = io.run_sync(profile.View(self.storage, name).execute, timeout=2)
        assert pr == dummy_profile

        io.run_sync(profile.Remove(self.storage, name).execute, timeout=2)
        try:
            io.run_sync(profile.View(self.storage, name).execute, timeout=2)
        except ServiceError:
            pass
        else:
            raise AssertionError("an exception is expected")
Beispiel #2
0
    def test_ProfileViewAction(self):
        storage = mock()
        action = profile.View(storage, **{'name': 'ProfileName'})
        when(storage).read(any(str), any(str)).thenReturn(Chain([lambda: 'Ok']))
        action.execute().get()

        verify(storage).read('profiles', 'ProfileName')
Beispiel #3
0
def profile_read(name, response):
    try:
        pf = yield profile.View(storage, name).execute()
        response.write(pf)
    except Exception as err:
        log.error(str(err))
        response.error(ITEM_IS_ABSENT, "Profile %s is missing" % name)
    finally:
        response.close()
 def view(self):
     return profile.View(self.storage, self.name).execute()