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)
示例#2
0
 def test_collecting_works(self):
     collector = BuildStatsCollector(
         build_stats_collector=self.example_build_stats_collector,
         test_stats_collector=self.example_test_stats_collector)
     build_stats = collector.collect()
     assert_build_matches_build_stats(self, build_stats,
                                      self.example_build_stats)
     assert_test_stats_equal(self, build_stats.test_stats,
                             self.example_test_stats)
示例#3
0
    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)
示例#4
0
    def test_collecting_works_when_test_stats_are_missing(self):
        test_stats_collector = MagicMock()
        test_stats_collector.collect = MagicMock(side_effect=Exception)

        collector = BuildStatsCollector(
            build_stats_collector=self.example_build_stats_collector,
            test_stats_collector=test_stats_collector)
        build_stats = collector.collect()
        assert_build_matches_build_stats(self, build_stats,
                                         self.example_build_stats)

        self.assertIsNone(build_stats.test_stats)
示例#5
0
    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_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)