def test_build_from_build_stats(self): build_stats = get_test_build_stats() build = Build(build_stats) assert_build_matches_build_stats(self, build, build_stats) self.assertIsNotNone(build.stages) self.assertEqual(len(build.stages), 0)
def setUp(self): self.example_build_stats = get_test_build_stats() self.example_test_stats = EXAMPLE_TESTS_STATS self.example_build_stats_collector = MagicMock() self.example_build_stats_collector.collect = MagicMock( return_value=self.example_build_stats) self.example_test_stats_collector = MagicMock() self.example_test_stats_collector.collect = MagicMock( return_value=self.example_test_stats)
def test_publish_build_stats_no_stages(self): build_stats = get_test_build_stats() self.publisher.publish(build_stats) build_count = self.session.query(Build).count() self.assertEqual(build_count, 1) stage_count = self.session.query(Stage).count() self.assertEqual(stage_count, 0) build = self.session.query(Build).one() assert_build_matches_build_stats(self, build, build_stats)
def test_publish_build_stats_with_report(self): self.assertEqual(self.session.query(Build).count(), 0) self.assertEqual(self.session.query(Report).count(), 0) build_stats = get_test_build_stats(test_stats=EXAMPLE_TESTS_STATS) self.publisher.publish(build_stats) self.assertEqual(self.session.query(Build).count(), 1) self.assertEqual(self.session.query(Report).count(), 1) build = self.session.query(Build).one() assert_build_matches_build_stats(self, build, build_stats) assert_report_matches_test_stats(self, build.report, EXAMPLE_TESTS_STATS)
def test_build_from_build_and_stages_stats(self): build_stats = get_test_build_stats([TEST_STAGE1_STATS, TEST_STAGE2_STATS]) build = Build(build_stats) assert_build_matches_build_stats(self, build, build_stats) self.assertIsNotNone(build.stages) self.assertEqual(len(build.stages), 2) assert_stage_matches_stage_stats(self, build.stages[0], TEST_STAGE1_STATS) self.assertEqual(build.stages[0].build_id, build_stats.build_id) self.assertEqual(build.stages[0].build, build) assert_stage_matches_stage_stats(self, build.stages[1], TEST_STAGE2_STATS) self.assertEqual(build.stages[1].build_id, build_stats.build_id) self.assertEqual(build.stages[1].build, build)
def test_publish_build_stats_with_stages(self): build_stats = get_test_build_stats( [TEST_STAGE1_STATS, TEST_STAGE2_STATS]) self.publisher.publish(build_stats) build_count = self.session.query(Build).count() self.assertEqual(build_count, 1) build = self.session.query(Build).one() self.assertEqual(len(build.stages), 2) assert_stage_matches_stage_stats(self, build.stages[0], TEST_STAGE1_STATS) self.assertEqual(build.stages[0].build_id, build.build_id) self.assertEqual(build.stages[0].build, build) assert_stage_matches_stage_stats(self, build.stages[1], TEST_STAGE2_STATS) self.assertEqual(build.stages[1].build_id, build.build_id) self.assertEqual(build.stages[1].build, build)
def test_build_from_build_and_without_test_stats(self): build_stats = get_test_build_stats(test_stats=None) build = Build(build_stats) assert_build_matches_build_stats(self, build, build_stats) self.assertIsNone(build.report)
def test_build_from_build_and_test_stats(self): build_stats = get_test_build_stats(test_stats=EXAMPLE_TESTS_STATS) build = Build(build_stats) assert_build_matches_build_stats(self, build, build_stats) assert_report_matches_test_stats(self, build.report, EXAMPLE_TESTS_STATS)
def test_stage_stringifying(self): build = Build(get_test_build_stats([TEST_STAGE1_STATS])) stage = build.stages[0] self.assertEqual(str(stage), '<Stage(job_name=MyJob, build_id=7, stage=Stage1)>')
def test_build_stringifying(self): build = Build(get_test_build_stats()) self.assertEqual(str(build), '<Build(job_name=MyJob, build_id=7)>')