Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_LayerOld_sort_with_non_sortable_layers_raise_exception(self):
# ordered in random layer order, one layer is not in the stream
test_data = [
('766dd2d9abcf5a4cc87729e938c005b0714309659b197fca61e4fd9b775b6b7b', {'parent': 'c89045c0bfe8cd62c539d0cc227eaeab7f5445002b8a711c0d5f47ec7716ad51'}),
('c89045c0bfe8cd62c539d0cc227eaeab7f5445002b8a711c0d5f47ec7716ad51', {'parent': '045df3e66e28eadb9be8c9156f638a4f9cfe286a696dd0641153e0d76e3e6af1'}),
('045df3e66e28eadb9be8c9156f638a4f9cfe286a696dd0641153e0d76e3e6af1', {'parent': '0c752394b855e8f15d2dc1fba6f10f4386ff6c0ab6fc6a253285bcfbfdd214f5'}),
('3fc782251abe2cf96c2b1f95d3e4d20396774fa6522ec0e45a6cbf8e27edc381', {'parent': '99a8b82393f66ccd2d57ba1efaabadaf62f5ba0a1e778ed79bd69a055ef8680a'}),
('0c752394b855e8f15d2dc1fba6f10f4386ff6c0ab6fc6a253285bcfbfdd214f5', {'parent': '34e94e67e63a0f079d9336b3c2a52e814d138e5b3f1f614a0cfe273814ed7c0a'}),
('34e94e67e63a0f079d9336b3c2a52e814d138e5b3f1f614a0cfe273814ed7c0a', {'parent': '511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158'}),
('511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158', {'parent': None}),
]
layers = [LayerOld(lid, **data) for lid, data in test_data]
try:
LayerOld.sort(layers)
except NonSortableLayersError:
pass
('71ffe2a62eab626357768d5fd308b6daf8ab95e6b17aadf1dafa78462c5668da', {'parent': '5ab5d882784bcaf444e58392aedee94e1fb34b545ce435f75336d14f1a8b528d'}),
('a7500126890eded387ecf1a052888230b75e1968931b05f9018f4fece1cdc46e', {'parent': '71ffe2a62eab626357768d5fd308b6daf8ab95e6b17aadf1dafa78462c5668da'}),
('033c14f799ea4e6a1133fcb03c88c90150b83108d9bb42c415edb61d10e20ae9', {'parent': 'a7500126890eded387ecf1a052888230b75e1968931b05f9018f4fece1cdc46e'}),
('07cefaf30c761a3a4f09243d426ab4ac35dadcf83dba79a521257ffd1b81030a', {'parent': '033c14f799ea4e6a1133fcb03c88c90150b83108d9bb42c415edb61d10e20ae9'}),
('8770c17b47f7955a9b5f9a232a4f34cc62be2b2f00e2830e1459ef5c28ca33d7', {'parent': '07cefaf30c761a3a4f09243d426ab4ac35dadcf83dba79a521257ffd1b81030a'}),
('99a8b82393f66ccd2d57ba1efaabadaf62f5ba0a1e778ed79bd69a055ef8680a', {'parent': '8770c17b47f7955a9b5f9a232a4f34cc62be2b2f00e2830e1459ef5c28ca33d7'}),
('3fc782251abe2cf96c2b1f95d3e4d20396774fa6522ec0e45a6cbf8e27edc381', {'parent': '99a8b82393f66ccd2d57ba1efaabadaf62f5ba0a1e778ed79bd69a055ef8680a'}),
('373e0a00584542b3cf9453c023965a337489a6ee2e9624150e253d000162585e', {'parent': '3fc782251abe2cf96c2b1f95d3e4d20396774fa6522ec0e45a6cbf8e27edc381'}),
('06da4b2f8a21203a5fd14fa4404edd554bc6397637f063362e5a1afc12d04528', {'parent': '373e0a00584542b3cf9453c023965a337489a6ee2e9624150e253d000162585e'}),
('51fc1e86eeb95ed136bd1819d3801190fc81e2bd6a214ae9053561ae9c7c64a0', {'parent': '06da4b2f8a21203a5fd14fa4404edd554bc6397637f063362e5a1afc12d04528'}),
]
# sort in layer id order, which is a random for our purpose
shuffled = sorted(test_data)
layers = [LayerOld(lid, **data) for lid, data in shuffled]
result = LayerOld.sort(layers)
result = [(l.layer_id, {'parent': l.parent_id}) for l in result]
expected = test_data
assert expected == result
last = {'parent': None}
for lid, pid in result:
assert pid == last
last = {'parent': lid}