Exemplo n.º 1
0
    def bz_users(self, count=1):
        self.begin("Bz users")
        for i in range(count):
            new = BzUser()
            new.email = "*****@*****.**"
            new.name = "Example"
            new.real_name = "Sample user"
            new.can_login = True
            self.add(new)

        self.commit()
Exemplo n.º 2
0
    def bz_users(self, count=1):
        self.begin('Bz users')
        for i in range(count):
            new = BzUser()
            new.email = '*****@*****.**'
            new.name = 'Example'
            new.real_name = 'Sample user'
            new.can_login = True
            self.add(new)

        self.commit()
Exemplo 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)
Exemplo n.º 4
0
    def bz_users(self, count=1):
        self.begin('Bz users')
        for _ in range(count):
            new = BzUser()
            new.email = '*****@*****.**'
            new.name = 'Example'
            new.real_name = 'Sample user'
            new.can_login = True
            self.add(new)

        self.commit()
Exemplo n.º 5
0
def create_anonymous_bzuser(db, uid=-1):
    """
    Create an anonymous BzUser in the database. If the user exists, return him.
    """
    bzuser = db.session.query(BzUser).filter(BzUser.id == uid).first()

    if bzuser is None:
        bzuser = BzUser(id=uid,
                        email='anonymous',
                        name='anonymous',
                        real_name='anonymous',
                        can_login=False)

        db.session.add(bzuser)
        db.session.flush()

    return bzuser
Exemplo n.º 6
0
    def _save_user(self, db, user):
        """
        Save bugzilla `user` to the database. Return persisted
        BzUser object.
        """

        # We need to account for case when user has changed
        # the email address.

        dbuser = (db.session.query(BzUser)
                  .filter(BzUser.id == user.userid).first())

        if not dbuser:
            dbuser = BzUser(id=user.userid)

        for field in ["name", "email", "can_login", "real_name"]:
            setattr(dbuser, field, getattr(user, field))

        db.session.add(dbuser)
        db.session.flush()
        return dbuser
Exemplo n.º 7
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)