Esempio n. 1
0
 def setUpClass(self):
     cfg = Config()
     self.axi = xapian.Database(cfg.axi)
     packages = [
         "gimp", "aaphoto", "eog", "emacs", "dia", "ferret", "festival",
         "file", "inkscape", "xpdf"
     ]
     path = "apprecommender/tests/test_data/.sample_axi"
     self.sample_axi = SampleAptXapianIndex(packages, self.axi, path)
     self.user = User({"gimp": 1, "aaphoto": 1, "eog": 1, "emacs": 1})
Esempio n. 2
0
 def test_profile_default(self):
     new_user = User(dict())
     desktop = set([
         "x11", "accessibility", "game", "junior", "office",
         "interface::x11"
     ])
     self.assertEqual(new_user.demographic_profile, desktop)
 def setUpClass(self):
     cfg = Config()
     self.axi = xapian.Database(cfg.axi)
     packages = ["gimp", "aaphoto", "eog", "emacs", "dia", "ferret",
                 "festival", "file", "inkscape", "xpdf"]
     path = "apprecommender/tests/test_data/.sample_axi"
     self.sample_axi = SampleAptXapianIndex(packages, self.axi, path)
     self.user = User({"gimp": 1, "aaphoto": 1, "eog": 1, "emacs": 1})
Esempio n. 4
0
 def get_model(self, cross_item_score):
     return User(cross_item_score)
Esempio n. 5
0
 def test_hash(self):
     new_user = User(dict())
     self.assertIsNotNone(new_user.id)
     self.assertNotEqual(self.user.id, new_user.id)
Esempio n. 6
0
class UserTests(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        cfg = Config()
        self.axi = xapian.Database(cfg.axi)
        packages = [
            "gimp", "aaphoto", "eog", "emacs", "dia", "ferret", "festival",
            "file", "inkscape", "xpdf"
        ]
        path = "apprecommender/tests/test_data/.sample_axi"
        self.sample_axi = SampleAptXapianIndex(packages, self.axi, path)
        self.user = User({"gimp": 1, "aaphoto": 1, "eog": 1, "emacs": 1})

    def test_hash(self):
        new_user = User(dict())
        self.assertIsNotNone(new_user.id)
        self.assertNotEqual(self.user.id, new_user.id)

    def test_profile_default(self):
        new_user = User(dict())
        desktop = set([
            "x11", "accessibility", "game", "junior", "office",
            "interface::x11"
        ])
        self.assertEqual(new_user.demographic_profile, desktop)

    def test_profile_desktop(self):
        self.user.set_demographic_profile(set(["desktop"]))
        desktop = set([
            "x11", "accessibility", "game", "junior", "office",
            "interface::x11"
        ])
        self.assertEqual(self.user.demographic_profile, desktop)

    def test_profile_admin(self):
        self.user.set_demographic_profile(set(["admin"]))
        admin = set([
            "admin", "hardware", "mail", "protocol", "network", "security",
            "web", "interface::web"
        ])
        self.assertEqual(self.user.demographic_profile, admin)

    def test_profile_devel(self):
        self.user.set_demographic_profile(set(["devel"]))
        devel = set(["devel", "role::devel-lib", "role::shared-lib"])
        self.assertEqual(self.user.demographic_profile, devel)

    def test_profile_art(self):
        self.user.set_demographic_profile(set(["art"]))
        art = set(["field::arts", "sound"])
        self.assertEqual(self.user.demographic_profile, art)

    def test_profile_science(self):
        self.user.set_demographic_profile(set(["science"]))
        science = set([
            "science", "biology", "field::astronomy", "field::aviation",
            "field::biology", "field::chemistry", "field::eletronics",
            "field::finance", "field::geography", "field::geology",
            "field::linguistics", "field::mathematics", "field::medicine",
            "field::meteorology", "field::physics", "field::statistics"
        ])
        self.assertEqual(self.user.demographic_profile, science)

    def test_multi_profile(self):
        self.user.set_demographic_profile(set(["devel", "art"]))
        devel_art = set([
            "devel", "role::devel-lib", "role::shared-lib", "field::arts",
            "sound"
        ])
        self.assertEqual(self.user.demographic_profile, devel_art)

        self.user.set_demographic_profile(set(["art", "admin", "desktop"]))
        desktop_art_admin = set([
            "x11", "accessibility", "game", "junior", "office",
            "interface::x11", "field::arts", "sound", "admin", "hardware",
            "mail", "protocol", "network", "security", "web", "interface::web"
        ])
        self.assertEqual(self.user.demographic_profile, desktop_art_admin)

    def test_items(self):
        self.assertEqual(set(self.user.items()),
                         set(["gimp", "aaphoto", "eog", "emacs"]))

    def test_maximal_pkg_profile(self):
        old_pkg_profile = self.user.items()
        aaphoto_deps = [
            "libc6", "libgomp1", "libjasper1", "libjpeg62", "libpng12-0"
        ]
        libc6_deps = ["libc-bin", "libgcc1"]

        for pkg in aaphoto_deps + libc6_deps:
            self.user.item_score[pkg] = 1

        self.assertEqual(old_pkg_profile, self.user.maximal_pkg_profile())
Esempio n. 7
0
 def test_get_recommendation(self):
     user = User({"inkscape": 1, "gimp": 1, "eog": 1})
     result = self.rec.get_recommendation(user)
     self.assertIsInstance(result, RecommendationResult)
     self.assertGreater(len(result.item_score), 0)
class UserTests(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        cfg = Config()
        self.axi = xapian.Database(cfg.axi)
        packages = ["gimp", "aaphoto", "eog", "emacs", "dia", "ferret",
                    "festival", "file", "inkscape", "xpdf"]
        path = "apprecommender/tests/test_data/.sample_axi"
        self.sample_axi = SampleAptXapianIndex(packages, self.axi, path)
        self.user = User({"gimp": 1, "aaphoto": 1, "eog": 1, "emacs": 1})

    def test_hash(self):
        new_user = User(dict())
        self.assertIsNotNone(new_user.id)
        self.assertNotEqual(self.user.id, new_user.id)

    def test_profile_default(self):
        new_user = User(dict())
        desktop = set(["x11", "accessibility", "game", "junior", "office",
                       "interface::x11"])
        self.assertEqual(new_user.demographic_profile, desktop)

    def test_profile_desktop(self):
        self.user.set_demographic_profile(set(["desktop"]))
        desktop = set(["x11", "accessibility", "game", "junior", "office",
                       "interface::x11"])
        self.assertEqual(self.user.demographic_profile, desktop)

    def test_profile_admin(self):
        self.user.set_demographic_profile(set(["admin"]))
        admin = set(["admin", "hardware", "mail", "protocol",
                     "network", "security", "web", "interface::web"])
        self.assertEqual(self.user.demographic_profile, admin)

    def test_profile_devel(self):
        self.user.set_demographic_profile(set(["devel"]))
        devel = set(["devel", "role::devel-lib", "role::shared-lib"])
        self.assertEqual(self.user.demographic_profile, devel)

    def test_profile_art(self):
        self.user.set_demographic_profile(set(["art"]))
        art = set(["field::arts", "sound"])
        self.assertEqual(self.user.demographic_profile, art)

    def test_profile_science(self):
        self.user.set_demographic_profile(set(["science"]))
        science = set(["science", "biology", "field::astronomy",
                       "field::aviation", "field::biology",
                       "field::chemistry", "field::eletronics",
                       "field::finance", "field::geography",
                       "field::geology", "field::linguistics",
                       "field::mathematics", "field::medicine",
                       "field::meteorology", "field::physics",
                       "field::statistics"])
        self.assertEqual(self.user.demographic_profile, science)

    def test_multi_profile(self):
        self.user.set_demographic_profile(set(["devel", "art"]))
        devel_art = set(["devel", "role::devel-lib", "role::shared-lib",
                         "field::arts", "sound"])
        self.assertEqual(self.user.demographic_profile, devel_art)

        self.user.set_demographic_profile(set(["art", "admin", "desktop"]))
        desktop_art_admin = set(["x11", "accessibility", "game", "junior",
                                 "office", "interface::x11", "field::arts",
                                 "sound", "admin", "hardware", "mail",
                                 "protocol", "network", "security", "web",
                                 "interface::web"])
        self.assertEqual(self.user.demographic_profile, desktop_art_admin)

    def test_items(self):
        self.assertEqual(set(self.user.items()),
                         set(["gimp", "aaphoto", "eog", "emacs"]))

    def test_maximal_pkg_profile(self):
        old_pkg_profile = self.user.items()
        aaphoto_deps = ["libc6", "libgomp1", "libjasper1", "libjpeg62",
                        "libpng12-0"]
        libc6_deps = ["libc-bin", "libgcc1"]

        for pkg in aaphoto_deps + libc6_deps:
            self.user.item_score[pkg] = 1

        self.assertEqual(old_pkg_profile, self.user.maximal_pkg_profile())