def test_export_as_string_user_types(self): keyspace_name = 'test' keyspace = KeyspaceMetadata(keyspace_name, True, 'SimpleStrategy', dict(replication_factor=3)) keyspace.user_types['a'] = UserType(keyspace_name, 'a', ['one', 'two'], [self.mock_user_type('UserType', 'c'), self.mock_user_type('IntType', 'int')]) keyspace.user_types['b'] = UserType(keyspace_name, 'b', ['one', 'two', 'three'], [self.mock_user_type('UserType', 'd'), self.mock_user_type('IntType', 'int'), self.mock_user_type('UserType', 'a')]) keyspace.user_types['c'] = UserType(keyspace_name, 'c', ['one'], [self.mock_user_type('IntType', 'int')]) keyspace.user_types['d'] = UserType(keyspace_name, 'd', ['one'], [self.mock_user_type('UserType', 'c')]) self.assertEqual("""CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true; CREATE TYPE test.c ( one int ); CREATE TYPE test.a ( one c, two int ); CREATE TYPE test.d ( one c ); CREATE TYPE test.b ( one d, two int, three a );""", keyspace.export_as_string())
def test_export_as_string_user_types(self): keyspace_name = 'test' keyspace = KeyspaceMetadata(keyspace_name, True, 'SimpleStrategy', dict(replication_factor=3)) keyspace.user_types['a'] = UserType(keyspace_name, 'a', ['one', 'two'], ['c', 'int']) keyspace.user_types['b'] = UserType(keyspace_name, 'b', ['one', 'two', 'three'], ['d', 'int', 'a']) keyspace.user_types['c'] = UserType(keyspace_name, 'c', ['one'], ['int']) keyspace.user_types['d'] = UserType(keyspace_name, 'd', ['one'], ['c']) self.assertEqual( """CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true; CREATE TYPE test.c ( one int ); CREATE TYPE test.a ( one c, two int ); CREATE TYPE test.d ( one c ); CREATE TYPE test.b ( one d, two int, three a );""", keyspace.export_as_string())
def test_export_as_string_user_types(self): keyspace_name = "test" keyspace = KeyspaceMetadata(keyspace_name, True, "SimpleStrategy", dict(replication_factor=3)) keyspace.user_types["a"] = UserType(keyspace_name, "a", ["one", "two"], ["c", "int"]) keyspace.user_types["b"] = UserType(keyspace_name, "b", ["one", "two", "three"], ["d", "int", "a"]) keyspace.user_types["c"] = UserType(keyspace_name, "c", ["one"], ["int"]) keyspace.user_types["d"] = UserType(keyspace_name, "d", ["one"], ["c"]) self.assertEqual( """CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true; CREATE TYPE test.c ( one int ); CREATE TYPE test.a ( one c, two int ); CREATE TYPE test.d ( one c ); CREATE TYPE test.b ( one d, two int, three a );""", keyspace.export_as_string(), )
def test_keyspace_name(self): km = KeyspaceMetadata(self.name, False, 'SimpleStrategy', {'replication_factor': 1}) km.export_as_string()