class TestSavingPasswordData(unittest.TestCase):
	
	def test_FullFunctionality(self):
		print("Running the FullFunctionality test for the TestSavingPasswordData.")
		
		self.gen = SimpleLabelledKeyGenerator()
		self.pickler = PicklingMethodology()
		self.data = Definitions()
		
		lclFactory = FactoryProgramPasswordData()
		self.passwordData = lclFactory.build()		
		
		#self.passwordData.addPassword(self.lclpwd1)
		#self.passwordData.addPassword(self.lclpwd2)
		self.passwordData.addPassword(self.data.lclpwd3)
		print("Status: " + self.passwordData.toString())
		
		self.passwordData.addInput(self.data.passwordListA2)
		print("Status: " + self.passwordData.toString())
		
		self.passwordData.addPassword(self.data.lclpwd4)
		print("Status: " + self.passwordData.toString())
		
		self.passwordData.addPassword(self.data.lclpwd4d)
		print("Status: " + self.passwordData.toString())

		self.passwordData.addInputWithPasswords(self.data.passwordListB4)
		print("Status: " + self.passwordData.toString())

		self.pickler.saveVault(self.passwordData, "ExampleVault.vlt")
class ProgramState(object):
	'''
	classdocs
	'''
	def __init__(self):
		'''
		Constructor
		'''
		self.vaultFileName = ""
		self.passwordData = ProgramPasswordData()
		self.pickler = PicklingMethodology()
# 	def isOpen(self):
# 		if -1 in self.list.identifier():
# 			return True
# 		return False
	
	def addPassword(self, pPasswordTuple):
		self.passwordData.addPassword(pPasswordTuple)
	
	def removePassword(self, pPasswordTuple):
		self.passwordData.removePassword(pPasswordTuple)
		# Remove keys associated with password pair?
			
	def addInputPlusPasswords(self, pInputList):
		self.passwordData.addInputWithPasswords(pInputList)
		#self.addInput(pInputList)
		#for i in pInputList.getList():
		#	self.addPassword(i)
	
	def addInput(self, pInputList):
		self.passwordData.addInput(pInputList)
	
	def setFileName(self, pFileName):
		self.vaultFileName = pFileName
	
	def saveVault(self):
		self.pickler.saveVault(self.passwordData, self.vaultFileName)
	
	def loadVault(self):
		#Check for malicious pickling
		return self.pickler.getVaultFromFile(self.vaultFileName)
	
	def removeInput(self, pInputList):
		self.passwordData.removeInput(pInputList)
	
	def displayedPasswords(self):
		lclPasswordList = self.passwordData.getPasswordList()
		del lclPasswordList["Intermediate Constant: 3161379751047332383565"]
		return lclPasswordList
		
	def toString(self):
		print("Password Data contents:")
		print(self.vault.toString())
		#print("The recovered password list:")
		#print(self.recoveredList())
	def __init__(self):
		'''
		Constructor
		'''
		self.vaultFileName = ""
		self.passwordData = ProgramPasswordData()
		self.pickler = PicklingMethodology()
	def test_FullFunctionality(self):
		
		self.data = Definitions()
		self.pickler = PicklingMethodology()
		
		lclVaultXX = self.pickler.getVaultFromFile("ExampleVault.vlt")
		print(lclVaultXX.toString())
		lclResults = lclVaultXX.recover(self.data.passwordListA3)
		print(lclResults)