示例#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")
示例#2
0
    def test_ProfileRemoveAction(self):
        storage = mock()
        action = profile.Remove(storage, **{'name': 'ProfileName'})
        when(storage).remove(any(str), any(str)).thenReturn(Chain([lambda: 'Ok']))
        action.execute().get()

        verify(storage).remove('profiles', 'ProfileName')
示例#3
0
def profile_remove(name, response):
    try:
        yield profile.Remove(storage, name).execute()
    except Exception as err:
        log.error(str(err))
        response.error(ITEM_IS_ABSENT, "Unable to remove profile")
    finally:
        response.close()
示例#4
0
 def test_ProfileRemoveActionRethrowsExceptions(self):
     storage = mock()
     action = profile.Remove(storage, **{'name': 'ProfileName'})
     when(storage).remove(any(str), any(str)).thenRaise(Exception)
     self.assertRaises(Exception, action.execute().get)