summaryrefslogtreecommitdiff
path: root/test/test_partition_movements.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_partition_movements.py')
-rw-r--r--test/test_partition_movements.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test_partition_movements.py b/test/test_partition_movements.py
new file mode 100644
index 0000000..bc990bf
--- /dev/null
+++ b/test/test_partition_movements.py
@@ -0,0 +1,23 @@
+from kafka.structs import TopicPartition
+
+from kafka.coordinator.assignors.sticky.partition_movements import PartitionMovements
+
+
+def test_empty_movements_are_sticky():
+ partition_movements = PartitionMovements()
+ assert partition_movements.are_sticky()
+
+
+def test_sticky_movements():
+ partition_movements = PartitionMovements()
+ partition_movements.move_partition(TopicPartition('t', 1), 'C1', 'C2')
+ partition_movements.move_partition(TopicPartition('t', 1), 'C2', 'C3')
+ partition_movements.move_partition(TopicPartition('t', 1), 'C3', 'C1')
+ assert partition_movements.are_sticky()
+
+
+def test_should_detect_non_sticky_assignment():
+ partition_movements = PartitionMovements()
+ partition_movements.move_partition(TopicPartition('t', 1), 'C1', 'C2')
+ partition_movements.move_partition(TopicPartition('t', 2), 'C2', 'C1')
+ assert not partition_movements.are_sticky()