Beispiel #1
0
    def test_process_group_documents(self):
        ctrl = AnalysisController()
        ctrl.prepare(self.profiles, {}, self.group_documents)
        ctrl.process_profiles()
        ctrl.process_group_documents()

        self.assert_participations(ctrl)
Beispiel #2
0
    def test_analyze_author(self):
        ctrl = AnalysisController()
        ctrl.prepare(self.profiles, {}, [])
        ctrl.process_profiles()

        # Find an existing profile as author of a doc
        self.assertEqual(len(ctrl.unified_name_to_participated_documents["hansmustermann"]), 0)
        ctrl.analyze_author("doc1", ("Hans", "Mustermann"))
        self.assertEqual(len(ctrl.unified_name_to_participated_documents["hansmustermann"]), 1)
        self.assertIn("doc1", ctrl.unified_name_to_participated_documents["hansmustermann"])

        # Find the same profile in another doc
        ctrl.analyze_author("doc2", ("Hans", "Mustermann"))
        self.assertEqual(len(ctrl.unified_name_to_participated_documents["hansmustermann"]), 2)
        self.assertIn("doc2", ctrl.unified_name_to_participated_documents["hansmustermann"])

        # Authored docs are still 0
        self.assertEqual(len(ctrl.unified_name_to_authored_documents["hansmustermann"]), 0)

        # Find an unknown profile as author of a doc
        self.assertNotIn("nichtexistent", ctrl.unified_name_to_participated_documents)
        ctrl.analyze_author("doc1", ("Nicht", "Existent"))
        self.assertEqual(len(ctrl.unified_name_to_participated_documents["nichtexistent"]), 1)
        self.assertIn("nichtexistent", ctrl.unified_name_to_unknown_profile)
        self.assertEqual(ctrl.unified_name_to_unknown_profile["nichtexistent"].name, "Nicht Existent")
        self.assertEqual(ctrl.unified_name_to_unknown_profile["nichtexistent"].unified_name, "nichtexistent")
Beispiel #3
0
    def test_process_profiles(self):
        ctrl = AnalysisController()
        ctrl.prepare(self.profiles, {}, [])
        ctrl.process_profiles()

        self.assertEqual(len(ctrl.unified_name_to_profiles), 3)

        # check that all unified names are stored as keys
        self.assertIn("hansmustermann", ctrl.unified_name_to_profiles)
        self.assertIn("maxmustermann", ctrl.unified_name_to_profiles)
        self.assertIn("heinrichmustermann", ctrl.unified_name_to_profiles)

        # check that the profiles are stored correctly
        self.assertEqual(ctrl.unified_name_to_profiles["hansmustermann"][0], self.profile1)
        self.assertEqual(ctrl.unified_name_to_profiles["hansmustermann"][1], self.profile4)
        self.assertEqual(ctrl.unified_name_to_profiles["maxmustermann"][0], self.profile2)
        self.assertEqual(ctrl.unified_name_to_profiles["heinrichmustermann"][0], self.profile3)

        # check that the document sets are created
        self.assertIn("hansmustermann", ctrl.unified_name_to_authored_documents)
        self.assertIn("hansmustermann", ctrl.unified_name_to_participated_documents)
        self.assertIn("maxmustermann", ctrl.unified_name_to_authored_documents)
        self.assertIn("maxmustermann", ctrl.unified_name_to_participated_documents)
        self.assertIn("heinrichmustermann", ctrl.unified_name_to_authored_documents)
        self.assertIn("heinrichmustermann", ctrl.unified_name_to_participated_documents)
Beispiel #4
0
    def test_process_group_documents(self):
        ctrl = AnalysisController()
        ctrl.prepare(self.profiles, {}, self.group_documents)
        ctrl.process_profiles()
        ctrl.process_group_documents()

        self.assert_participations(ctrl)
Beispiel #5
0
    def test_process_profiles(self):
        ctrl = AnalysisController()
        ctrl.prepare(self.profiles, {}, [])
        ctrl.process_profiles()

        self.assertEqual(len(ctrl.unified_name_to_profiles), 3)

        # check that all unified names are stored as keys
        self.assertIn("hansmustermann", ctrl.unified_name_to_profiles)
        self.assertIn("maxmustermann", ctrl.unified_name_to_profiles)
        self.assertIn("heinrichmustermann", ctrl.unified_name_to_profiles)

        # check that the profiles are stored correctly
        self.assertEqual(ctrl.unified_name_to_profiles["hansmustermann"][0],
                         self.profile1)
        self.assertEqual(ctrl.unified_name_to_profiles["hansmustermann"][1],
                         self.profile4)
        self.assertEqual(ctrl.unified_name_to_profiles["maxmustermann"][0],
                         self.profile2)
        self.assertEqual(
            ctrl.unified_name_to_profiles["heinrichmustermann"][0],
            self.profile3)

        # check that the document sets are created
        self.assertIn("hansmustermann",
                      ctrl.unified_name_to_authored_documents)
        self.assertIn("hansmustermann",
                      ctrl.unified_name_to_participated_documents)
        self.assertIn("maxmustermann", ctrl.unified_name_to_authored_documents)
        self.assertIn("maxmustermann",
                      ctrl.unified_name_to_participated_documents)
        self.assertIn("heinrichmustermann",
                      ctrl.unified_name_to_authored_documents)
        self.assertIn("heinrichmustermann",
                      ctrl.unified_name_to_participated_documents)
Beispiel #6
0
    def test_process_profile_documents(self):
        ctrl = AnalysisController()
        ctrl.prepare(self.profiles, self.profile_documents, [])
        ctrl.process_profiles()
        ctrl.process_profile_documents()

        # Check if authored_documents are set correctly
        self.assertEqual(len(ctrl.unified_name_to_authored_documents["hansmustermann"]), 1)
        self.assertEqual(len(ctrl.unified_name_to_authored_documents["maxmustermann"]), 1)
        self.assertEqual(len(ctrl.unified_name_to_authored_documents["heinrichmustermann"]), 1)
        self.assertIn("title1", ctrl.unified_name_to_authored_documents["hansmustermann"])
        self.assertIn("title2", ctrl.unified_name_to_authored_documents["maxmustermann"])
        self.assertIn("title3", ctrl.unified_name_to_authored_documents["heinrichmustermann"])

        self.assert_participations(ctrl)
Beispiel #7
0
    def test_analyze_author(self):
        ctrl = AnalysisController()
        ctrl.prepare(self.profiles, {}, [])
        ctrl.process_profiles()

        # Find an existing profile as author of a doc
        self.assertEqual(
            len(ctrl.unified_name_to_participated_documents["hansmustermann"]),
            0)
        ctrl.analyze_author("doc1", ("Hans", "Mustermann"))
        self.assertEqual(
            len(ctrl.unified_name_to_participated_documents["hansmustermann"]),
            1)
        self.assertIn(
            "doc1",
            ctrl.unified_name_to_participated_documents["hansmustermann"])

        # Find the same profile in another doc
        ctrl.analyze_author("doc2", ("Hans", "Mustermann"))
        self.assertEqual(
            len(ctrl.unified_name_to_participated_documents["hansmustermann"]),
            2)
        self.assertIn(
            "doc2",
            ctrl.unified_name_to_participated_documents["hansmustermann"])

        # Authored docs are still 0
        self.assertEqual(
            len(ctrl.unified_name_to_authored_documents["hansmustermann"]), 0)

        # Find an unknown profile as author of a doc
        self.assertNotIn("nichtexistent",
                         ctrl.unified_name_to_participated_documents)
        ctrl.analyze_author("doc1", ("Nicht", "Existent"))
        self.assertEqual(
            len(ctrl.unified_name_to_participated_documents["nichtexistent"]),
            1)
        self.assertIn("nichtexistent", ctrl.unified_name_to_unknown_profile)
        self.assertEqual(
            ctrl.unified_name_to_unknown_profile["nichtexistent"].name,
            "Nicht Existent")
        self.assertEqual(
            ctrl.unified_name_to_unknown_profile["nichtexistent"].unified_name,
            "nichtexistent")
Beispiel #8
0
    def test_process_profile_documents(self):
        ctrl = AnalysisController()
        ctrl.prepare(self.profiles, self.profile_documents, [])
        ctrl.process_profiles()
        ctrl.process_profile_documents()

        # Check if authored_documents are set correctly
        self.assertEqual(
            len(ctrl.unified_name_to_authored_documents["hansmustermann"]), 1)
        self.assertEqual(
            len(ctrl.unified_name_to_authored_documents["maxmustermann"]), 1)
        self.assertEqual(
            len(ctrl.unified_name_to_authored_documents["heinrichmustermann"]),
            1)
        self.assertIn(
            "title1",
            ctrl.unified_name_to_authored_documents["hansmustermann"])
        self.assertIn("title2",
                      ctrl.unified_name_to_authored_documents["maxmustermann"])
        self.assertIn(
            "title3",
            ctrl.unified_name_to_authored_documents["heinrichmustermann"])

        self.assert_participations(ctrl)