예제 #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))