Пример #1
0
    def testSetValues(self):
        """
		This method tests :meth:`foundations.environment.Environment.setValues` method.
		"""

        environment = Environment()
        self.assertTrue(environment.setValues(JOHN="DOE"))
        self.assertIn("JOHN", os.environ)
        self.assertTrue(environment.setValues(JOHN="EOD", DOE="JOHN"))
        self.assertIn("DOE", os.environ)
        self.assertEqual(environment.getValues()["JOHN"], "EOD")
	def testSetValues(self):
		"""
		Tests :meth:`foundations.environment.Environment.setValues` method.
		"""

		environment = Environment()
		self.assertTrue(environment.setValues(JOHN="DOE"))
		self.assertIn("JOHN", os.environ)
		self.assertTrue(environment.setValues(JOHN="EOD", DOE="JOHN"))
		self.assertIn("DOE", os.environ)
		self.assertEqual(environment.getValues()["JOHN"], "EOD")
	def testGetValues(self):
		"""
		Tests :meth:`foundations.environment.Environment.getValues` method.
		"""

		if platform.system() == "Windows" or platform.system() == "Microsoft":
			variable = "APPDATA"
		elif platform.system() == "Darwin":
			variable = "HOME"
		elif platform.system() == "Linux":
			variable = "HOME"

		environment = Environment(variable)
		self.assertIsInstance(environment.getValues(), dict)
		self.assertIsInstance(environment.getValues(variable), dict)

		self.assertIsInstance(environment.getValues().get(variable), unicode)
		self.assertEqual(environment.getValues()[variable], os.environ[variable])
		environment.getValues("JOHNDOE_IS_FOR_SURE_A_NON_EXISTING_SYSTEM_ENVIRONMENT_VARIABLE")
		self.assertFalse(environment.getValues()["JOHNDOE_IS_FOR_SURE_A_NON_EXISTING_SYSTEM_ENVIRONMENT_VARIABLE"])
Пример #4
0
    def testGetValues(self):
        """
		This method tests :meth:`foundations.environment.Environment.getValues` method.
		"""

        if platform.system() == "Windows" or platform.system() == "Microsoft":
            variable = "APPDATA"
        elif platform.system() == "Darwin":
            variable = "HOME"
        elif platform.system() == "Linux":
            variable = "HOME"

        environment = Environment(variable)
        self.assertIsInstance(environment.getValues(), dict)
        self.assertIsInstance(environment.getValues(variable), dict)

        self.assertIsInstance(environment.getValues().get(variable), str)
        self.assertEqual(environment.getValues()[variable],
                         os.environ[variable])
        environment.getValues(
            "JOHNDOE_IS_FOR_SURE_A_NON_EXISTING_SYSTEM_ENVIRONMENT_VARIABLE")
        self.assertFalse(
            environment.getValues()
            ["JOHNDOE_IS_FOR_SURE_A_NON_EXISTING_SYSTEM_ENVIRONMENT_VARIABLE"])