def test_w_mulitple_activation_events_mulitple_super_e_and_sub_e_returned(self): super_e1 = G(Entity) super_e2 = G(Entity) sub_e1 = G(Entity) sub_e2 = G(Entity) G( EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 2, 1)) G( EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 2, 3)) G( EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 2, 4)) G( EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 2, 4, 12)) G( EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 3, 4, 12)) G( EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e2, sub_entity=sub_e1, time=datetime(2013, 1, 1)) G( EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e2, sub_entity=sub_e1, time=datetime(2013, 12, 1)) G( EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 2, 4)) G( EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 2, 20)) G( EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 3, 4)) G( EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 3, 4, 12)) G( EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 3, 4, 13)) G( EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e2, sub_entity=sub_e2, time=datetime(2013, 1, 1)) G( EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e2, sub_entity=sub_e2, time=datetime(2013, 12, 1)) res = get_sub_entities_at_times( [super_e1.id, super_e2.id], [datetime(2013, 2, 2), datetime(2013, 2, 4, 13), datetime(2013, 3, 5)]) self.assertEquals(res, { (super_e1.id, datetime(2013, 2, 2)): set([sub_e1.id]), (super_e1.id, datetime(2013, 2, 4, 13)): set([sub_e1.id, sub_e2.id]), (super_e1.id, datetime(2013, 3, 5)): set([sub_e2.id]), (super_e2.id, datetime(2013, 2, 2)): set([sub_e1.id, sub_e2.id]), (super_e2.id, datetime(2013, 2, 4, 13)): set([sub_e1.id, sub_e2.id]), (super_e2.id, datetime(2013, 3, 5)): set([sub_e1.id, sub_e2.id]), })
def test_no_events_w_input(self): res = get_sub_entities_at_times([1, 2], [datetime(2013, 4, 5), datetime(2013, 5, 6)]) self.assertEquals(res, { (1, datetime(2013, 4, 5)): set(), (1, datetime(2013, 5, 6)): set(), (2, datetime(2013, 4, 5)): set(), (2, datetime(2013, 5, 6)): set(), })
def test_w_events_no_results(self): se = G(Entity) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=se, time=datetime(2013, 2, 1)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=se, time=datetime(2013, 2, 2)) res = get_sub_entities_at_times([se.id], [datetime(2012, 4, 5), datetime(2012, 5, 6)]) self.assertEquals(res, { (se.id, datetime(2012, 4, 5)): set(), (se.id, datetime(2012, 5, 6)): set(), })
def test_no_events_w_input(self): res = get_sub_entities_at_times( [1, 2], [datetime(2013, 4, 5), datetime(2013, 5, 6)]) self.assertEquals( res, { (1, datetime(2013, 4, 5)): set(), (1, datetime(2013, 5, 6)): set(), (2, datetime(2013, 4, 5)): set(), (2, datetime(2013, 5, 6)): set(), })
def test_w_events_sub_entity_deactivated_before_date(self): super_e = G(Entity) sub_e = G(Entity) G( EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e, sub_entity=sub_e, time=datetime(2013, 2, 1)) G( EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e, sub_entity=sub_e, time=datetime(2013, 2, 3)) res = get_sub_entities_at_times([super_e.id], [datetime(2013, 2, 4)]) self.assertEquals(res, { (super_e.id, datetime(2013, 2, 4)): set(), })
def test_w_events_one_sub_e_returned(self): super_e = G(Entity) sub_e = G(Entity) G( EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e, sub_entity=sub_e, time=datetime(2013, 2, 1)) G( EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e, sub_entity=sub_e, time=datetime(2013, 2, 3)) res = get_sub_entities_at_times([super_e.id], [datetime(2013, 2, 2), datetime(2012, 5, 6)]) self.assertEquals(res, { (super_e.id, datetime(2013, 2, 2)): set([sub_e.id]), (super_e.id, datetime(2012, 5, 6)): set(), })
def test_w_events_sub_entity_deactivated_before_date(self): super_e = G(Entity) sub_e = G(Entity) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e, sub_entity=sub_e, time=datetime(2013, 2, 1)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e, sub_entity=sub_e, time=datetime(2013, 2, 3)) res = get_sub_entities_at_times([super_e.id], [datetime(2013, 2, 4)]) self.assertEquals(res, { (super_e.id, datetime(2013, 2, 4)): set(), })
def test_w_events_no_results(self): se = G(Entity) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=se, time=datetime(2013, 2, 1)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=se, time=datetime(2013, 2, 2)) res = get_sub_entities_at_times( [se.id], [datetime(2012, 4, 5), datetime(2012, 5, 6)]) self.assertEquals( res, { (se.id, datetime(2012, 4, 5)): set(), (se.id, datetime(2012, 5, 6)): set(), })
def test_w_events_one_sub_e_returned(self): super_e = G(Entity) sub_e = G(Entity) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e, sub_entity=sub_e, time=datetime(2013, 2, 1)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e, sub_entity=sub_e, time=datetime(2013, 2, 3)) res = get_sub_entities_at_times( [super_e.id], [datetime(2013, 2, 2), datetime(2012, 5, 6)]) self.assertEquals( res, { (super_e.id, datetime(2013, 2, 2)): set([sub_e.id]), (super_e.id, datetime(2012, 5, 6)): set(), })
def test_w_mulitple_activation_events_mulitple_super_e_and_sub_e_returned( self): super_e1 = G(Entity) super_e2 = G(Entity) sub_e1 = G(Entity) sub_e2 = G(Entity) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 2, 1)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 2, 3)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 2, 4)) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 2, 4, 12)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e1, time=datetime(2013, 3, 4, 12)) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e2, sub_entity=sub_e1, time=datetime(2013, 1, 1)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e2, sub_entity=sub_e1, time=datetime(2013, 12, 1)) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 2, 4)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 2, 20)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 3, 4)) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 3, 4, 12)) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e1, sub_entity=sub_e2, time=datetime(2013, 3, 4, 13)) G(EntityRelationshipActivationEvent, was_activated=True, super_entity=super_e2, sub_entity=sub_e2, time=datetime(2013, 1, 1)) G(EntityRelationshipActivationEvent, was_activated=False, super_entity=super_e2, sub_entity=sub_e2, time=datetime(2013, 12, 1)) res = get_sub_entities_at_times([super_e1.id, super_e2.id], [ datetime(2013, 2, 2), datetime(2013, 2, 4, 13), datetime(2013, 3, 5) ]) self.assertEquals( res, { (super_e1.id, datetime(2013, 2, 2)): set([sub_e1.id]), (super_e1.id, datetime(2013, 2, 4, 13)): set([sub_e1.id, sub_e2.id]), (super_e1.id, datetime(2013, 3, 5)): set([sub_e2.id]), (super_e2.id, datetime(2013, 2, 2)): set([sub_e1.id, sub_e2.id]), (super_e2.id, datetime(2013, 2, 4, 13)): set([sub_e1.id, sub_e2.id]), (super_e2.id, datetime(2013, 3, 5)): set([sub_e1.id, sub_e2.id]), })
def test_no_events_no_input(self): res = get_sub_entities_at_times([], []) self.assertEquals(res, {})
def test_no_events_no_input(self): res = get_sub_entities_at_times([], []) self.assertEquals(res, {})