~gz/juju-ci-tools/assess_jes_dump_logs

« back to all changes in this revision

Viewing changes to tests/test_jujupy.py

  • Committer: Aaron Bentley
  • Date: 2016-02-08 15:45:21 UTC
  • mfrom: (1258.1.3 juju-data)
  • Revision ID: aaron.bentley@canonical.com-20160208154521-0m77mw0kqrm20z1p
Support JUJU_DATA for 2.0-alpha2 and later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    EnvJujuClient25,
40
40
    EnvJujuClient26,
41
41
    EnvJujuClient2A1,
 
42
    EnvJujuClient2A2,
42
43
    ErroredUnit,
43
44
    GroupReporter,
44
45
    get_cache_path,
767
768
            self.assertIs(type(client), EnvJujuClient2A1)
768
769
            self.assertEqual(client.version, '2.0-alpha1')
769
770
            client = EnvJujuClient.by_version(None)
770
 
            self.assertIs(type(client), EnvJujuClient)
 
771
            self.assertIs(type(client), EnvJujuClient2A2)
771
772
            self.assertEqual(client.version, '2.0-alpha2')
772
773
            client = EnvJujuClient.by_version(None)
773
774
            self.assertIs(type(client), EnvJujuClient)
1027
1028
            (sys.executable, get_timeout_path(), '5.00', '--', 'juju',
1028
1029
             '--show-log', 'bar', '-m', 'foo'))
1029
1030
 
 
1031
    def test__shell_environ_juju_data(self):
 
1032
        client = EnvJujuClient(
 
1033
            SimpleEnvironment('baz', {'type': 'ec2'}), '1.25-foobar', 'path',
 
1034
            'asdf')
 
1035
        env = client._shell_environ()
 
1036
        self.assertEqual(env['JUJU_DATA'], 'asdf')
 
1037
        self.assertNotIn('JUJU_HOME', env)
 
1038
 
1030
1039
    def test__shell_environ_cloudsigma(self):
1031
1040
        client = EnvJujuClient(
1032
1041
            SimpleEnvironment('baz', {'type': 'cloudsigma'}),
2145
2154
                client.get_service_config('foo')
2146
2155
 
2147
2156
 
 
2157
class TestEnvJujuClient2A2(TestCase):
 
2158
 
 
2159
    def test__shell_environ_juju_home(self):
 
2160
        client = EnvJujuClient2A2(
 
2161
            SimpleEnvironment('baz', {'type': 'ec2'}), '1.25-foobar', 'path',
 
2162
            'asdf')
 
2163
        with patch.dict(os.environ, {'PATH': ''}):
 
2164
            env = client._shell_environ()
 
2165
        # For transition, supply both.
 
2166
        self.assertEqual(env['JUJU_HOME'], 'asdf')
 
2167
        self.assertEqual(env['JUJU_DATA'], 'asdf')
 
2168
 
 
2169
 
2148
2170
class TestEnvJujuClient1X(ClientTest):
2149
2171
 
2150
2172
    def test_no_duplicate_env(self):
2250
2272
            self.assertIs(type(client), EnvJujuClient2A1)
2251
2273
            self.assertEqual(client.version, '2.0-alpha1')
2252
2274
            client = EnvJujuClient1X.by_version(None)
2253
 
            self.assertIs(type(client), EnvJujuClient)
 
2275
            self.assertIs(type(client), EnvJujuClient2A2)
2254
2276
            self.assertEqual(client.version, '2.0-alpha2')
2255
2277
            client = EnvJujuClient1X.by_version(None)
2256
2278
            self.assertIs(type(client), EnvJujuClient)
2539
2561
            (sys.executable, get_timeout_path(), '5.00', '--', 'juju',
2540
2562
             '--show-log', 'bar', '-e', 'foo'))
2541
2563
 
 
2564
    def test__shell_environ_juju_home(self):
 
2565
        client = EnvJujuClient1X(
 
2566
            SimpleEnvironment('baz', {'type': 'ec2'}), '1.25-foobar', 'path',
 
2567
            'asdf')
 
2568
        env = client._shell_environ()
 
2569
        self.assertEqual(env['JUJU_HOME'], 'asdf')
 
2570
        self.assertNotIn('JUJU_DATA', env)
 
2571
 
2542
2572
    def test__shell_environ_cloudsigma(self):
2543
2573
        client = EnvJujuClient1X(
2544
2574
            SimpleEnvironment('baz', {'type': 'cloudsigma'}),
3810
3840
            agent_version = client.get_matching_agent_version()
3811
3841
            with temp_bootstrap_env(fake_home, client):
3812
3842
                temp_home = os.environ['JUJU_HOME']
 
3843
                self.assertEqual(temp_home, os.environ['JUJU_DATA'])
3813
3844
                self.assertNotEqual(temp_home, fake_home)
3814
3845
                symlink_path = get_jenv_path(fake_home, 'qux')
3815
3846
                symlink_target = os.path.realpath(symlink_path)
3846
3877
        env = SimpleEnvironment('qux', {'type': 'local'})
3847
3878
        client = self.get_client(env)
3848
3879
        os.environ['JUJU_HOME'] = 'foo'
 
3880
        os.environ['JUJU_DATA'] = 'bar'
3849
3881
        with patch('jujupy.check_free_disk_space', autospec=True):
3850
3882
            with temp_bootstrap_env(self.home_dir, client, set_home=False):
3851
3883
                self.assertEqual(os.environ['JUJU_HOME'], 'foo')
 
3884
                self.assertEqual(os.environ['JUJU_DATA'], 'bar')
3852
3885
 
3853
3886
    def test_output(self):
3854
3887
        env = SimpleEnvironment('qux', {'type': 'local'})