<s> from . manager_case import ManagerTestCase <EOL> from iepy . data . models import EvidenceLabel <EOL> from . factories import ( <EOL> EntityFactory , EntityKindFactory , <EOL> RelationFactory , EvidenceCandidateFactory <EOL> ) <EOL> class TestEvidenceCandidate ( ManagerTestCase ) : <EOL> judge = "<STR_LIT>" <EOL> def setUp ( self ) : <EOL> self . k_person = EntityKindFactory ( name = '<STR_LIT>' ) <EOL> self . k_location = EntityKindFactory ( name = '<STR_LIT:location>' ) <EOL> self . e_john = EntityFactory ( key = '<STR_LIT>' , kind = self . k_person ) <EOL> self . e_bob = EntityFactory ( key = '<STR_LIT>' , kind = self . k_person ) <EOL> self . e_argentina = EntityFactory ( key = '<STR_LIT>' , kind = self . k_location ) <EOL> self . e_germany = EntityFactory ( key = '<STR_LIT>' , kind = self . k_location ) <EOL> self . e_australia = EntityFactory ( key = '<STR_LIT>' , kind = self . k_location ) <EOL> self . person_location_relation = RelationFactory ( <EOL> left_entity_kind = self . k_person , <EOL> right_entity_kind = self . k_location <EOL> ) <EOL> self . positive_label = EvidenceLabel . YESRELATION <EOL> self . negative_label = EvidenceLabel . NORELATION <EOL> def test_save_label ( self ) : <EOL> labels = list ( EvidenceLabel . objects . all ( ) ) <EOL> self . assertEqual ( len ( labels ) , <NUM_LIT:0> ) <EOL> candidate = EvidenceCandidateFactory ( ) <EOL> candidate . set_label ( self . person_location_relation , self . positive_label , self . judge ) <EOL> labels = list ( EvidenceLabel . objects . all ( ) ) <EOL> self . assertEqual ( len ( labels ) , <NUM_LIT:1> ) <EOL> label = labels [ <NUM_LIT:0> ] <EOL> self . assertEqual ( label . label , self . positive_label ) <EOL> self . assertEqual ( label . judge , self . judge ) <EOL> self . assertEqual ( label . evidence_candidate , candidate ) <EOL> def test_save_label_twice ( self ) : <EOL> labels = list ( EvidenceLabel . objects . all ( ) ) <EOL> self . assertEqual ( len ( labels ) , <NUM_LIT:0> ) <EOL> candidate = EvidenceCandidateFactory ( ) <EOL> candidate . set_label ( self . person_location_relation , self . positive_label , self . judge ) <EOL> labels = list ( EvidenceLabel . objects . all ( ) ) <EOL> self . assertEqual ( len ( labels ) , <NUM_LIT:1> ) <EOL> candidate . set_label ( self . person_location_relation , self . negative_label , self . judge ) <EOL> labels = list ( EvidenceLabel . objects . all ( ) ) <EOL> self . assertEqual ( len ( labels ) , <NUM_LIT:1> ) <EOL> label = labels [ <NUM_LIT:0> ] <EOL> self . assertEqual ( label . label , self . negative_label ) <EOL> self . assertEqual ( label . judge , self . judge ) <EOL> self . assertEqual ( label . evidence_candidate , candidate ) <EOL> def test_save_diferent_judges ( self ) : <EOL> labels = list ( EvidenceLabel . objects . all ( ) ) <EOL> self . assertEqual ( len ( labels ) , <NUM_LIT:0> ) <EOL> candidate = EvidenceCandidateFactory ( ) <EOL> candidate . set_label ( self . person_location_relation , self . positive_label , "<STR_LIT>" ) <EOL> labels = list ( EvidenceLabel . objects . all ( ) ) <EOL> self . assertEqual ( len ( labels ) , <NUM_LIT:1> ) <EOL> candidate . set_label ( self . person_location_relation , self . negative_label , "<STR_LIT>" ) <EOL> labels = list ( EvidenceLabel . objects . all ( ) ) <EOL> self . assertEqual ( len ( labels ) , <NUM_LIT:2> ) <EOL> label1 , label2 = labels <EOL> self . assertNotEqual ( label1 . judge , label2 . judge ) <EOL> self . assertNotEqual ( label1 . label , label2 . label ) </s>
