예제 #1
0
 def generate_stance(self, stance_importance, relation_importance):
     """Generates stances for testing with sort keys"""
     stance = Stance()
     stance.importance = stance_importance
     relation = Relation()
     relation.importance = relation_importance
     stance.relation = relation
     stance.sort_key = stance_sort_key.LOYALTY
     return stance
예제 #2
0
    def test_infer_single_relation_stances(self):
        """ Verifies a single group's stances are extracted."""
        relation = Relation()
        relation.group = self.GROUP1
        result = member_analyze._infer_single_relation_stances(relation)

        self.assertEqual(len(result), len(self.group1.stances))
        for stance1, stance2 in zip(result, self.group1.stances):
            # Ensure that the source relation is added as the source.
            self.assertEqual(stance1.relation, relation)
            self.assertTrue(stance1.total_match(stance2))
예제 #3
0
    def generate_stance_array(self):
        """Generates the stance array for the _compare_stance tests"""
        stance1 = Stance()
        stance1.importance = importance.B
        relation1 = Relation()
        relation1.importance = importance.C
        stance1.relation = relation1

        stance2 = Stance()
        stance2.importance = importance.B
        relation2 = Relation()
        relation2.importance = importance.A
        stance2.relation = relation2

        stance3 = Stance()
        stance3.importance = importance.C
        relation3 = Relation()
        relation3.importance = importance.B
        stance3.relation = relation3

        stance4 = Stance()
        stance4.importance = importance.D
        relation4 = Relation()
        relation4.importance = importance.A
        stance4.relation = relation4
        return [stance1, stance2, stance3, stance4]
예제 #4
0
 def test_infer_single_relation_stances_invalid_relation(self):
     """ Verifies functionality when the group provided is invalid."""
     relation = Relation()
     relation.group = "I DON'T EXIST"
     result = member_analyze._infer_single_relation_stances(relation)
     self.assertEqual(result, [])