github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/acceptancetests/jujupy/tests/test_configuration.py (about) 1 import os 2 from unittest import TestCase 3 4 try: 5 from mock import patch 6 except ImportError: 7 from unittest.mock import patch 8 9 from jujupy.configuration import ( 10 get_juju_data, 11 ) 12 13 14 class TestGetJujuData(TestCase): 15 16 def test_from_home(self): 17 with patch.dict(os.environ, { 18 'HOME': 'foo-bar', 19 }, clear=True): 20 self.assertEqual(get_juju_data(), 'foo-bar/.local/share/juju') 21 22 def test_from_data_home(self): 23 with patch.dict(os.environ, { 24 'HOME': 'foo-bar', 25 'XDG_DATA_HOME': 'baz', 26 }, clear=True): 27 self.assertEqual(get_juju_data(), 'baz/juju') 28 29 def test_from_juju_data(self): 30 with patch.dict(os.environ, { 31 'HOME': 'foo-bar', 32 'XDG_DATA_HOME': 'baz', 33 'JUJU_DATA': 'qux', 34 }, clear=True): 35 self.assertEqual(get_juju_data(), 'qux')