def setUp( self ): self.event_sequencer = EventSequencer()
class EventSequencerTest(ScalyrTestCase): def setUp( self ): self.event_sequencer = EventSequencer() def test_sequence_id_but_no_number( self ): event = {} self.event_sequencer.add_sequence_fields( event, '1234', None ) self.assertFalse( 'si' in event ) self.assertFalse( 'sn' in event ) self.assertFalse( 'sd' in event ) def test_sequence_number_but_no_id( self ): event = {} self.event_sequencer.add_sequence_fields( event, None, 1234 ) self.assertFalse( 'si' in event ) self.assertFalse( 'sn' in event ) self.assertFalse( 'sd' in event ) def test_sequence_id_and_number( self ): expected_id = '1234' expected_number = 1234 event = {} self.event_sequencer.add_sequence_fields( event, expected_id, expected_number ) self.assertEquals( expected_id, event['si'] ) self.assertEquals( expected_number, event['sn'] ) self.assertFalse( 'sd' in event ) def test_same_sequence_id( self ): expected_id = '1234' expected_number = 1234 expected_delta = 1 event = {} self.event_sequencer.add_sequence_fields( event, expected_id, expected_number ) event = {} self.event_sequencer.add_sequence_fields( event, expected_id, expected_number + expected_delta ) self.assertFalse( 'si' in event ) self.assertFalse( 'sn' in event ) self.assertEqual( expected_delta, event['sd'] ) def test_different_sequence_id( self ): first_id = '1234' second_id = '1235' first_number = 1234 second_number = 1234 event = {} self.event_sequencer.add_sequence_fields( event, first_id, first_number ) event = {} self.event_sequencer.add_sequence_fields( event, first_id, first_number+1 ) event = {} self.event_sequencer.add_sequence_fields( event, second_id, second_number ) self.assertEquals( second_id, event['si'] ) self.assertEquals( second_number, event['sn'] ) self.assertFalse( 'sd' in event ) def test_memento( self ): first_id = '1234' second_id = '1235' first_number = 1234 second_number = 1234 event = {} self.event_sequencer.add_sequence_fields( event, first_id, first_number ) memento = self.event_sequencer.get_memento() event = {} self.event_sequencer.add_sequence_fields( event, second_id, second_number ) self.assertTrue( 'si' in event ) self.assertTrue( 'sn' in event ) self.assertFalse( 'sd' in event ) self.event_sequencer.restore_from_memento( memento ) event = {} self.event_sequencer.add_sequence_fields( event, first_id, first_number + 1 ) self.assertFalse( 'si' in event ) self.assertFalse( 'sn' in event ) self.assertTrue( 'sd' in event ) def test_reset( self ): expected_id = '1234' expected_number = 1234 expected_delta = 1 event = {} self.event_sequencer.add_sequence_fields( event, expected_id, expected_number ) self.event_sequencer.reset() event = {} self.event_sequencer.add_sequence_fields( event, expected_id, expected_number + expected_delta ) self.assertEqual( expected_id, event['si'] ) self.assertEqual( expected_number+expected_delta, event['sn'] ) self.assertFalse( 'sd' in event )
def setUp(self): super(EventSequencerTest, self).setUp() self.event_sequencer = EventSequencer()
class EventSequencerTest(ScalyrTestCase): def setUp(self): super(EventSequencerTest, self).setUp() self.event_sequencer = EventSequencer() def test_sequence_id_but_no_number(self): event = Event() self.event_sequencer.add_sequence_fields(event, "1234", None) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertIsNone(event.sequence_number_delta) def test_sequence_number_but_no_id(self): event = Event() self.event_sequencer.add_sequence_fields(event, None, 1234) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertIsNone(event.sequence_number_delta) def test_sequence_id_and_number(self): expected_id = "1234" expected_number = 1234 event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number) self.assertEquals(expected_id.encode("utf-8"), event.sequence_id) self.assertEquals(expected_number, event.sequence_number) self.assertIsNone(event.sequence_number_delta) def test_same_sequence_id(self): expected_id = "1234" expected_number = 1234 expected_delta = 1 event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number) event = Event() self.event_sequencer.add_sequence_fields( event, expected_id, expected_number + expected_delta) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertEqual(expected_delta, event.sequence_number_delta) def test_different_sequence_id(self): first_id = "1234" second_id = "1235" first_number = 1234 second_number = 1234 event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number) event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number + 1) event = Event() self.event_sequencer.add_sequence_fields(event, second_id, second_number) self.assertEquals(second_id.encode("utf-8"), event.sequence_id) self.assertEquals(second_number, event.sequence_number) self.assertIsNone(event.sequence_number_delta) def test_memento(self): first_id = "1234" second_id = "1235" first_number = 1234 second_number = 1234 event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number) memento = self.event_sequencer.get_memento() event = Event() self.event_sequencer.add_sequence_fields(event, second_id, second_number) self.assertIsNotNone(event.sequence_id) self.assertIsNotNone(event.sequence_number) self.assertIsNone(event.sequence_number_delta) self.event_sequencer.restore_from_memento(memento) event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number + 1) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertIsNotNone(event.sequence_number_delta) def test_reset(self): expected_id = "1234" expected_number = 1234 expected_delta = 1 event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number) self.event_sequencer.reset() event = Event() self.event_sequencer.add_sequence_fields( event, expected_id, expected_number + expected_delta) self.assertEqual(expected_id.encode("utf-8"), event.sequence_id) self.assertEqual(expected_number + expected_delta, event.sequence_number) self.assertIsNone(event.sequence_number_delta)
class EventSequencerTest(ScalyrTestCase): def setUp(self): self.event_sequencer = EventSequencer() @unittest.skip("Imron needs to fix this") def test_sequence_id_but_no_number(self): event = Event() self.event_sequencer.add_sequence_fields(event, '1234', None) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertIsNone(event.sequence_number_delta) @unittest.skip("Imron needs to fix this") def test_sequence_number_but_no_id(self): event = Event() self.event_sequencer.add_sequence_fields(event, None, 1234) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertIsNone(event.sequence_number_delta) @unittest.skip("Imron needs to fix this") def test_sequence_id_and_number(self): expected_id = '1234' expected_number = 1234 event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number) self.assertEquals(expected_id, event.sequence_id) self.assertEquals(expected_number, event.sequence_number) self.assertIsNone(event.sequence_number_delta) @unittest.skip("Imron needs to fix this") def test_same_sequence_id(self): expected_id = '1234' expected_number = 1234 expected_delta = 1 event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number) event = Event() self.event_sequencer.add_sequence_fields( event, expected_id, expected_number + expected_delta) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertEqual(expected_delta, event.sequence_number_delta) @unittest.skip("Imron needs to fix this") def test_different_sequence_id(self): first_id = '1234' second_id = '1235' first_number = 1234 second_number = 1234 event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number) event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number + 1) event = Event() self.event_sequencer.add_sequence_fields(event, second_id, second_number) self.assertEquals(second_id, event.sequence_id) self.assertEquals(second_number, event.sequence_number) self.assertIsNone(event.sequence_number_delta) @unittest.skip("Imron needs to fix this") def test_memento(self): first_id = '1234' second_id = '1235' first_number = 1234 second_number = 1234 event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number) memento = self.event_sequencer.get_memento() event = Event() self.event_sequencer.add_sequence_fields(event, second_id, second_number) self.assertIsNotNone(event.sequence_id) self.assertIsNotNone(event.sequence_number) self.assertIsNone(event.sequence_number_delta) self.event_sequencer.restore_from_memento(memento) event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number + 1) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertIsNotNone(event.sequence_number_delta) @unittest.skip("Imron needs to fix this") def test_reset(self): expected_id = '1234' expected_number = 1234 expected_delta = 1 event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number) self.event_sequencer.reset() event = Event() self.event_sequencer.add_sequence_fields( event, expected_id, expected_number + expected_delta) self.assertEqual(expected_id, event.sequence_id) self.assertEqual(expected_number + expected_delta, event.sequence_number) self.assertIsNone(event.sequence_number_delta)
class EventSequencerTest(ScalyrTestCase): def setUp(self): self.event_sequencer = EventSequencer() def test_sequence_id_but_no_number(self): event = Event() self.event_sequencer.add_sequence_fields(event, "1234", None) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertIsNone(event.sequence_number_delta) def test_sequence_number_but_no_id(self): event = Event() self.event_sequencer.add_sequence_fields(event, None, 1234) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertIsNone(event.sequence_number_delta) def test_sequence_id_and_number(self): expected_id = "1234" expected_number = 1234 event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number) self.assertEquals(expected_id, event.sequence_id) self.assertEquals(expected_number, event.sequence_number) self.assertIsNone(event.sequence_number_delta) def test_same_sequence_id(self): expected_id = "1234" expected_number = 1234 expected_delta = 1 event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number) event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number + expected_delta) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertEqual(expected_delta, event.sequence_number_delta) def test_different_sequence_id(self): first_id = "1234" second_id = "1235" first_number = 1234 second_number = 1234 event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number) event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number + 1) event = Event() self.event_sequencer.add_sequence_fields(event, second_id, second_number) self.assertEquals(second_id, event.sequence_id) self.assertEquals(second_number, event.sequence_number) self.assertIsNone(event.sequence_number_delta) def test_memento(self): first_id = "1234" second_id = "1235" first_number = 1234 second_number = 1234 event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number) memento = self.event_sequencer.get_memento() event = Event() self.event_sequencer.add_sequence_fields(event, second_id, second_number) self.assertIsNotNone(event.sequence_id) self.assertIsNotNone(event.sequence_number) self.assertIsNone(event.sequence_number_delta) self.event_sequencer.restore_from_memento(memento) event = Event() self.event_sequencer.add_sequence_fields(event, first_id, first_number + 1) self.assertIsNone(event.sequence_id) self.assertIsNone(event.sequence_number) self.assertIsNotNone(event.sequence_number_delta) def test_reset(self): expected_id = "1234" expected_number = 1234 expected_delta = 1 event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number) self.event_sequencer.reset() event = Event() self.event_sequencer.add_sequence_fields(event, expected_id, expected_number + expected_delta) self.assertEqual(expected_id, event.sequence_id) self.assertEqual(expected_number + expected_delta, event.sequence_number) self.assertIsNone(event.sequence_number_delta)