def test_merge_sequence(self):
     checkpoints_topics = [
         (DjangoPillowCheckpoint(sequence=0,
                                 sequence_format='text'), 'form'),
         (DjangoPillowCheckpoint(sequence=2,
                                 sequence_format='text'), 'sql-form'),
     ]
     sequence = get_merged_sequence(checkpoints_topics)
     self.assertEqual(sequence, {'form': 0, 'sql-form': 2})
def test_migate_sequence(self, format, feed, old_seq, new_seq, error=None):
    checkpoint = DjangoPillowCheckpoint(sequence=old_seq,
                                        sequence_format=format)
    if error:
        with self.assertRaises(error):
            migrate_kafka_sequence(feed, checkpoint)
    else:
        migrated = migrate_kafka_sequence(feed, checkpoint)
        self.assertEqual(new_seq, migrated)
 def test_merge_sequence_mixed_format(self):
     checkpoints_topics = [
         (DjangoPillowCheckpoint(sequence=5,
                                 sequence_format='text'), 'form'),
         (DjangoPillowCheckpoint(sequence='8',
                                 sequence_format='text'), 'form'),
         (DjangoPillowCheckpoint(sequence='{"form": 2, "sql-form": 3}',
                                 sequence_format='json'), None),
         (DjangoPillowCheckpoint(sequence='{"case": 9, "sql-case": 7}',
                                 sequence_format='json'), None),
     ]
     sequence = get_merged_sequence(checkpoints_topics)
     self.assertEqual(sequence, {
         'form': 2,
         'sql-form': 3,
         'case': 9,
         'sql-case': 7
     })
 def get_or_create_wrapped(self, verify_unchanged=False):
     return DjangoPillowCheckpoint(
         checkpoint_id=self.checkpoint_id,
         sequence=self.couch_db.info()['update_seq'],
     )
Exemple #5
0
 def get_or_create(self, verify_unchanged=False):
     result = self._get_or_create(verify_unchanged)
     return DocGetOrCreateResult(DjangoPillowCheckpoint.to_dict(result.document), result.created)