Esempio n. 1
0
    def install(cls, db, logger=None):
        if logger is None:
            logger = log.getChildLogger(cls.__name__)

        logger.info("Adding bugtracker '{0}'".format(cls.name))
        new = Bugtracker()
        new.name = cls.name
        db.session.add(new)
        db.session.flush()
Esempio n. 2
0
    def install(cls, db, logger=None):
        if logger is None:
            logger = log.getChildLogger(cls.__name__)

        logger.info("Adding bugtracker '{0}'".format(cls.name))
        new = Bugtracker()
        new.name = cls.name
        db.session.add(new)
        db.session.flush()
Esempio n. 3
0
    def setUp(self):
        """
        Add required stuff to the database
        """

        super(UreportTestCase, self).setUp()
        self.basic_fixtures()

        tracker = Bugtracker(name="fedora-bugzilla")
        self.db.session.add(tracker)

        bzuser = BzUser(name="Fake user",
                        email="*****@*****.**",
                        real_name="Fake name",
                        can_login=False)

        self.db.session.add(bzuser)

        bug = BzBug()
        bug.id = 123456
        bug.summary = "Fake bug"
        bug.status = "NEW"
        bug.creation_time = datetime.datetime.now()
        bug.last_change_time = datetime.datetime.now()
        bug.whiteboard = "empty"
        bug.tracker = tracker
        bug.creator = bzuser
        bug.component = self.comp_faf
        bug.opsysrelease = self.release_20
        bug.private = False

        self.bug = bug
        self.db.session.add(bug)
        self.db.session.flush()

        self.sample_report_names = ("ureport1", "ureport2", "ureport_core",
                                    "ureport_python", "ureport_kerneloops",
                                    "ureport_java", "ureport_ruby",
                                    "ureport_kerneloops_nouveau")
        self.sample_reports = {}

        for report_name in self.sample_report_names:
            with open("sample_reports/{0}".format(report_name), "r") as file:
                self.sample_reports[report_name] = json.load(file)

        with open("sample_reports/bugzilla_attachment", "r") as file:
            self.bugzilla_attachment = json.load(file)

        with open("sample_reports/comment_attachment", "r") as file:
            self.comment_attachment = json.load(file)

        with open("sample_reports/contact_email_attachment", "r") as file:
            self.contact_email_attachment = json.load(file)

        with open("sample_reports/url_attachment", "r") as file:
            self.url_attachment = json.load(file)
Esempio n. 4
0
    def setUp(self):
        """
        Set up bugzilla instance with mockzilla.
        """

        super(BugzillaTestCase, self).setUp()

        self.basic_fixtures()

        tracker = Bugtracker(name="fakebugzilla")
        self.db.session.add(tracker)
        self.db.session.flush()

        cls = bugzilla.Bugzilla
        cls.name = "fakebugzilla"
        self.bz = cls()
        self.mz = mockzilla.Mockzilla()
        self.bz.bz = self.mz
        self.bz.connected = True
Esempio n. 5
0
    def releasedel_testing(self, repo_type):
        self.assertEqual(
            self.call_action("releasedel", {
                "opsys": "fedora",
                "opsys-release": "1337",
            }), 1)

        # add release f24 and assign two builds
        self.assign_release_to_builds_testing(repo_type)

        # assign sample_repo to f24 release (sample_repo comes from ^^^)
        self.assertEqual(
            self.call_action_ordered_args(
                "repoassign",
                [
                    "sample_repo",  # NAME
                    "Fedora 24",  # OPSYS
                    "x86_64",  # ARCH
                ]),
            0)

        tracker = Bugtracker(name="fedora-bugzilla")
        self.db.session.add(tracker)

        self.save_report('ureport_f20')
        self.save_report('ureport_core')
        self.call_action("create-problems")

        bzuser = BzUser(name="Fake user",
                        email="*****@*****.**",
                        real_name="Fake name",
                        can_login=False)

        self.db.session.add(bzuser)

        bug = BzBug()
        bug.id = 123456
        bug.summary = "Fake bug"
        bug.status = "NEW"
        bug.creation_time = datetime.now()
        bug.last_change_time = datetime.now()
        bug.whiteboard = "empty"
        bug.tracker = tracker
        bug.creator = bzuser
        bug.component = self.comp_faf
        bug.opsysrelease = self.release_20
        bug.private = False

        self.db.session.add(bug)

        # add package and lob that will be deleted
        pkg_del = Package()
        pkg_del.build = self.db.session.query(Build).first()
        pkg_del.arch = self.db.session.query(Arch).first()
        pkg_del.name = "pkg-test-del"
        self.db.session.add(pkg_del)
        self.db.session.flush()

        config["storage.lobdir"] = tempfile.mkdtemp(prefix="faf")

        sample_rpm = glob.glob("sample_rpms/sample*.rpm")[0]
        with open(sample_rpm, mode='rb') as sample:
            pkg_del.save_lob("package", sample, truncate=True)
        self.assertTrue(pkg_del.has_lob("package"))

        # add build and package and lob that will not be deleted
        build = Build()
        build.base_package_name = "build_unassigned"
        build.epoch = 0
        build.version = "1.2.3"
        build.release = "20.fc23"
        self.db.session.add(build)

        pkg_stay = Package()
        pkg_stay.build = build
        pkg_stay.arch = self.db.session.query(Arch).first()
        pkg_stay.name = "pkg-test-stay"
        self.db.session.add(pkg_stay)
        self.db.session.flush()

        sample_rpm = glob.glob("sample_rpms/sample*.rpm")[0]
        with open(sample_rpm, mode='rb') as sample:
            pkg_stay.save_lob("package", sample, truncate=True)
        self.assertTrue(pkg_stay.has_lob("package"))

        init_bosra = self.db.session.query(BuildOpSysReleaseArch).count()
        bosra = self.db.session.query(BuildOpSysReleaseArch).count()

        # delete release f24 with assigned repos and builds with lobs
        self.assertEqual(
            self.call_action("releasedel", {
                "opsys": "fedora",
                "opsys-release": "24",
            }), 0)

        self.assertEqual(bosra, init_bosra)
        self.assertTrue(pkg_stay.has_lob("package"))
        self.assertFalse(pkg_del.has_lob("package"))

        self.assertEqual(self.db.session.query(Report).count(), 2)
        self.assertEqual(self.db.session.query(Problem).count(), 2)

        # delete release f20 with assigned bugs, reports and problems
        self.assertEqual(
            self.call_action("releasedel", {
                "opsys": "fedora",
                "opsys-release": "20",
            }), 0)

        self.assertEqual(self.db.session.query(Report).count(), 0)
        self.assertEqual(self.db.session.query(Problem).count(), 0)

        # attempt to delete deleted release f20
        self.assertEqual(
            self.call_action("releasedel", {
                "opsys": "fedora",
                "opsys-release": "20",
            }), 1)