def testUnparsableFile(self): # reset status env.state = {} # flag if function will be executed self.flag1 = 0 self.flag2 = 0 # example function @state(provides="custom.something") def fun1(): self.flag1 = 1 # call fun1() # function should be executed assert self.flag1 == 1 save_status("snake") # reset status env.state = {} # doInvalidFile file(self.fabstate_directory + "snake.fabstate", "wb").write("{9: la, a: 4\n") try: load_status("snake") except SystemExit, e: self.flag2 = 1
def testCustomName(self): # reset status env.state = {} # flag if function will be executed self.flag1 = 0 # example function @state(provides="custom.something") def fun1(): self.flag1 = 1 # call fun1() # function should be executed assert self.flag1 == 1 save_status("snake") # reset status env.state = {} load_status("snake") # reset flag self.flag1 = 0 # call fun1() # function shouldn't be called because status is already provided assert self.flag1 == 0
def testReadPermissions(self): # reset status env.state = {} # flag if function will be executed self.flag1 = 0 self.flag2 = 0 # example function @state(provides="custom.something") def fun1(): self.flag1 = 1 # call fun1() # function should be executed assert self.flag1 == 1 save_status("snake") # reset status env.state = {} self.revokePerms("snake") try: load_status("snake") except SystemExit, e: self.flag2 = 1