From e786e16220386eb684371c29070843469a81f81a Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 3 Oct 2013 15:51:11 -0500 Subject: [PATCH] Add test for test_all_runs Signed-off-by: Zack Cerza --- teuthology/test/fake_archive.py | 18 ++++++++++++++++++ teuthology/test/test_report.py | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 teuthology/test/test_report.py diff --git a/teuthology/test/fake_archive.py b/teuthology/test/fake_archive.py index b27a1a7877..ce804e8b5e 100644 --- a/teuthology/test/fake_archive.py +++ b/teuthology/test/fake_archive.py @@ -79,3 +79,21 @@ class FakeArchive(object): with file(summary_path, 'w') as yfile: yaml.safe_dump(job['summary'], yfile) + def create_fake_run(self, run_name, job_count, yaml_path): + """ + Creates a fake run using run_name. Uses the YAML specified for each + job's config.yaml + """ + assert os.path.exists(yaml_path) + assert job_count > 0 + jobs = [] + for i in range(job_count): + jobs.append(self.get_random_metadata(run_name)) + #job_config = yaml.safe_load(yaml_path) + self.populate_archive(run_name, jobs) + for job in jobs: + job_id = job['job_id'] + job_yaml_path = os.path.join(self.archive_base, run_name, + str(job_id), 'config.yaml') + shutil.copyfile(yaml_path, job_yaml_path) + diff --git a/teuthology/test/test_report.py b/teuthology/test/test_report.py new file mode 100644 index 0000000000..6b943cef93 --- /dev/null +++ b/teuthology/test/test_report.py @@ -0,0 +1,22 @@ +import fake_archive +from .. import report + + +class TestReport(object): + def setup(self): + self.archive = fake_archive.FakeArchive() + self.archive.setup() + self.archive_base = self.archive.archive_base + self.reporter = report.ResultsReporter(archive_base=self.archive_base) + + def teardown(self): + self.archive.teardown() + + def test_all_runs(self): + run_name = "test_all_runs" + yaml_path = "examples/3node_ceph.yaml" + job_count = 3 + self.archive.create_fake_run(run_name, job_count, yaml_path) + assert [run_name] == self.reporter.serializer.all_runs + + -- 2.39.5