示例#1
0
文件: test_utility.py 项目: mjs/juju
 def test_temp_dir_parent(self):
     with temp_dir() as p:
         with temp_dir(parent=p) as d:
             self.assertTrue(os.path.isdir(d))
             self.assertEqual(p, os.path.dirname(d))
         self.assertFalse(os.path.exists(d))
     self.assertFalse(os.path.exists(p))
示例#2
0
 def test_temp_dir_parent(self):
     with temp_dir() as p:
         with temp_dir(parent=p) as d:
             self.assertTrue(os.path.isdir(d))
             self.assertEqual(p, os.path.dirname(d))
         self.assertFalse(os.path.exists(d))
     self.assertFalse(os.path.exists(p))
示例#3
0
 def test_temp_dir_keep(self):
     with temp_dir() as p:
         with temp_dir(parent=p, keep=True) as d:
             self.assertTrue(os.path.isdir(d))
             open(os.path.join(d, "a-file"), "w").close()
         self.assertTrue(os.path.exists(d))
         self.assertTrue(os.path.exists(os.path.join(d, "a-file")))
     self.assertFalse(os.path.exists(p))
示例#4
0
文件: test_utility.py 项目: mjs/juju
 def test_temp_dir_keep(self):
     with temp_dir() as p:
         with temp_dir(parent=p, keep=True) as d:
             self.assertTrue(os.path.isdir(d))
             open(os.path.join(d, "a-file"), "w").close()
         self.assertTrue(os.path.exists(d))
         self.assertTrue(os.path.exists(os.path.join(d, "a-file")))
     self.assertFalse(os.path.exists(p))
示例#5
0
文件: test_utility.py 项目: mjs/juju
 def test_ignore_older_revision_build(self):
     with temp_dir() as root:
         path_1234 = make_candidate_dir(
             root, '1234-artifacts', 'mybranch', '1234')
         make_candidate_dir(root, '1233', 'mybranch', '1233')
         self.assertEqual(find_latest_branch_candidates(root), [
             (path_1234, 1234)])
示例#6
0
 def test_ignore_older_revision_build(self):
     with temp_dir() as root:
         path_1234 = make_candidate_dir(root, '1234-artifacts', 'mybranch',
                                        '1234')
         make_candidate_dir(root, '1233', 'mybranch', '1233')
         self.assertEqual(find_latest_branch_candidates(root),
                          [(path_1234, 1234)])
示例#7
0
文件: test_utility.py 项目: mjs/juju
 def test__find_candidates_artifacts_enabled(self):
     with temp_dir() as root:
         make_candidate_dir(root, 'master-artifacts')
         make_candidate_dir(root, '1.25')
         candidate = os.path.join(root, 'candidate', 'master-artifacts')
         self.assertEqual(list(_find_candidates(root, artifacts=True)), [
             (candidate, os.path.join(candidate, 'buildvars.json'))])
示例#8
0
 def test_find_candidates_find_all(self):
     with temp_dir() as root:
         a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
         master_path = make_candidate_dir(root, '1.23', modified=a_week_ago)
         master_path_2 = make_candidate_dir(root, '1.24')
         self.assertItemsEqual(list(find_candidates(root)), [master_path_2])
         self.assertItemsEqual(list(find_candidates(root, find_all=True)),
                               [master_path, master_path_2])
示例#9
0
 def test__find_candidates_artifacts_enabled(self):
     with temp_dir() as root:
         make_candidate_dir(root, 'master-artifacts')
         make_candidate_dir(root, '1.25')
         candidate = os.path.join(root, 'candidate', 'master-artifacts')
         self.assertEqual(
             list(_find_candidates(root, artifacts=True)),
             [(candidate, os.path.join(candidate, 'buildvars.json'))])
示例#10
0
文件: test_utility.py 项目: mjs/juju
 def test_find_candidates_find_all(self):
     with temp_dir() as root:
         a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
         master_path = make_candidate_dir(root, '1.23', modified=a_week_ago)
         master_path_2 = make_candidate_dir(root, '1.24')
         self.assertItemsEqual(list(find_candidates(root)), [master_path_2])
         self.assertItemsEqual(list(find_candidates(root, find_all=True)),
                               [master_path, master_path_2])
示例#11
0
 def test_include_older_revision_build_different_branch(self):
     with temp_dir() as root:
         path_1234 = make_candidate_dir(root, '1234-artifacts',
                                        'branch_foo', '1234')
         path_1233 = make_candidate_dir(root, '1233-artifacts',
                                        'branch_bar', '1233')
         self.assertItemsEqual(find_latest_branch_candidates(root),
                               [(path_1233, 1233), (path_1234, 1234)])
示例#12
0
文件: test_utility.py 项目: mjs/juju
 def test_include_older_revision_build_different_branch(self):
     with temp_dir() as root:
         path_1234 = make_candidate_dir(
             root, '1234-artifacts', 'branch_foo', '1234')
         path_1233 = make_candidate_dir(
             root, '1233-artifacts', 'branch_bar', '1233')
         self.assertItemsEqual(
             find_latest_branch_candidates(root), [
                 (path_1233, 1233), (path_1234, 1234)])
示例#13
0
def client_and_plan():
    cur_client = fake_juju_client()
    cur_client.bootstrap()
    with patch('hammer_time.hammer_time.client_for_existing',
               return_value=cur_client,
               autospec=True) as cfe_mock:
        with temp_dir() as plan_dir:
            plan_file = os.path.join(plan_dir, 'asdf.yaml')
            yield (cur_client, cfe_mock, plan_file)
示例#14
0
 def test_no_warn_on_empty_logs(self):
     """Special case a file named 'empty' doesn't make log dir dirty"""
     with warnings.catch_warnings(record=True) as warned:
         with temp_dir() as log_dir:
             open(os.path.join(log_dir, "empty"), "w").close()
             cmd_line = ['local', '/a/juju', log_dir, 'testtest']
             parser = add_basic_testing_arguments(ArgumentParser())
             parser.parse_args(cmd_line)
         self.assertEqual(warned, [])
     self.assertEqual("", self.log_stream.getvalue())
示例#15
0
文件: test_utility.py 项目: mjs/juju
 def test_no_warn_on_empty_logs(self):
     """Special case a file named 'empty' doesn't make log dir dirty"""
     with warnings.catch_warnings(record=True) as warned:
         with temp_dir() as log_dir:
             open(os.path.join(log_dir, "empty"), "w").close()
             cmd_line = ['local', '/a/juju', log_dir, 'testtest']
             parser = add_basic_testing_arguments(ArgumentParser())
             parser.parse_args(cmd_line)
         self.assertEqual(warned, [])
     self.assertEqual("", self.log_stream.getvalue())
示例#16
0
 def test_warns_on_dirty_logs(self):
     with warnings.catch_warnings(record=True) as warned:
         with temp_dir() as log_dir:
             open(os.path.join(log_dir, "existing.log"), "w").close()
             cmd_line = ['local', '/a/juju', log_dir, 'testtest']
             parser = add_basic_testing_arguments(ArgumentParser())
             parser.parse_args(cmd_line)
         self.assertEqual(len(warned), 1)
         self.assertRegexpMatches(
             str(warned[0].message),
             r"^Directory '.*' has existing contents.$")
     self.assertEqual("", self.log_stream.getvalue())
示例#17
0
文件: test_utility.py 项目: mjs/juju
 def test_warns_on_dirty_logs(self):
     with warnings.catch_warnings(record=True) as warned:
         with temp_dir() as log_dir:
             open(os.path.join(log_dir, "existing.log"), "w").close()
             cmd_line = ['local', '/a/juju', log_dir, 'testtest']
             parser = add_basic_testing_arguments(ArgumentParser())
             parser.parse_args(cmd_line)
         self.assertEqual(len(warned), 1)
         self.assertRegexpMatches(
             str(warned[0].message),
             r"^Directory '.*' has existing contents.$")
     self.assertEqual("", self.log_stream.getvalue())
示例#18
0
文件: test_utility.py 项目: mjs/juju
 def test_find_candidates_old_buildvars(self):
     with temp_dir() as root:
         a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
         make_candidate_dir(root, 'master', modified=a_week_ago)
         self.assertEqual(list(find_candidates(root)), [])
示例#19
0
 def test_find_latest_branch_candidates(self):
     with temp_dir() as root:
         master_path = make_candidate_dir(root, 'master-artifacts')
         self.assertEqual(find_latest_branch_candidates(root),
                          [(master_path, 1234)])
示例#20
0
文件: test_utility.py 项目: mjs/juju
 def test_find_latest_branch_candidates(self):
     with temp_dir() as root:
         master_path = make_candidate_dir(root, 'master-artifacts')
         self.assertEqual(find_latest_branch_candidates(root),
                          [(master_path, 1234)])
示例#21
0
 def test_find_candidates_artifacts(self):
     with temp_dir() as root:
         make_candidate_dir(root, 'master-artifacts')
         self.assertEqual(list(find_candidates(root)), [])
示例#22
0
 def test_find_candidates(self):
     with temp_dir() as root:
         master_path = make_candidate_dir(root, 'master')
         self.assertEqual(list(find_candidates(root)), [master_path])
示例#23
0
文件: test_utility.py 项目: mjs/juju
 def test_find_candidates(self):
     with temp_dir() as root:
         master_path = make_candidate_dir(root, 'master')
         self.assertEqual(list(find_candidates(root)), [master_path])
示例#24
0
文件: test_utility.py 项目: mjs/juju
 def test_temp_dir_contents(self):
     with temp_dir() as d:
         self.assertTrue(os.path.isdir(d))
         open(os.path.join(d, "a-file"), "w").close()
     self.assertFalse(os.path.exists(d))
示例#25
0
 def test_temp_dir(self):
     with temp_dir() as d:
         self.assertTrue(os.path.isdir(d))
     self.assertFalse(os.path.exists(d))
示例#26
0
 def test_find_candidates_old_buildvars(self):
     with temp_dir() as root:
         a_week_ago = time() - timedelta(days=7, seconds=1).total_seconds()
         make_candidate_dir(root, 'master', modified=a_week_ago)
         self.assertEqual(list(find_candidates(root)), [])
示例#27
0
文件: test_utility.py 项目: mjs/juju
 def test_find_candidates_artifacts(self):
     with temp_dir() as root:
         make_candidate_dir(root, 'master-artifacts')
         self.assertEqual(list(find_candidates(root)), [])
示例#28
0
文件: test_utility.py 项目: mjs/juju
 def test_temp_dir(self):
     with temp_dir() as d:
         self.assertTrue(os.path.isdir(d))
     self.assertFalse(os.path.exists(d))
示例#29
0
 def test_temp_dir_contents(self):
     with temp_dir() as d:
         self.assertTrue(os.path.isdir(d))
         open(os.path.join(d, "a-file"), "w").close()
     self.assertFalse(os.path.exists(d))