diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e63443a0..00ccf11e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,11 @@ +2.1.1 +===== +In Progress + +Bug Fixes +--------- +* Fix NetworkTopologyStrategy.export_for_schema (PYTHON-120) + 2.1.0 ===== August 7, 2014 diff --git a/cassandra/metadata.py b/cassandra/metadata.py index 6d4a759d..cd793ea1 100644 --- a/cassandra/metadata.py +++ b/cassandra/metadata.py @@ -546,7 +546,7 @@ class NetworkTopologyStrategy(ReplicationStrategy): suitable for use in a CREATE KEYSPACE statement. """ ret = "{'class': 'NetworkTopologyStrategy'" - for dc, repl_factor in self.dc_replication_factors: + for dc, repl_factor in sorted(self.dc_replication_factors.items()): ret += ", '%s': '%d'" % (dc, repl_factor) return ret + "}" diff --git a/tests/unit/test_metadata.py b/tests/unit/test_metadata.py index 28d56cff..95c8841e 100644 --- a/tests/unit/test_metadata.py +++ b/tests/unit/test_metadata.py @@ -127,8 +127,9 @@ class TestStrategies(unittest.TestCase): self.assertEqual(set(replica_map[MD5Token(0)]), set([host])) def test_nts_export_for_schema(self): - # TODO: Cover NetworkTopologyStrategy.export_for_schema() - pass + strategy = NetworkTopologyStrategy({'dc1': '1', 'dc2': '2'}) + self.assertEqual("{'class': 'NetworkTopologyStrategy', 'dc1': '1', 'dc2': '2'}", + strategy.export_for_schema()) def test_simple_strategy_make_token_replica_map(self): host1 = Host('1', SimpleConvictionPolicy)