Пример #1
0
 def test_credentials_but_no_secrets(self):
     with self.assertRaises(TypeError):
         cluster_from_config(
             {
                 "cassandra.contact_points": "127.0.0.1",
                 "cassandra.credentials_secret": "secret/foo/bar",
             }
         )
Пример #2
0
    def test_port(self):
        cluster = cluster_from_config({
            "cassandra.contact_points": "127.0.1.1",
            "cassandra.port": "9999",
        })

        self.assertEqual(cluster.port, 9999)
Пример #3
0
    def test_kwarg_passthrough(self):
        cluster = cluster_from_config(
            {
                "cassandra.contact_points": "127.0.0.1",
            }, protocol_version=3)

        self.assertEqual(cluster.protocol_version, 3)
Пример #4
0
    def test_contact_points(self):
        cluster = cluster_from_config({
            "cassandra.contact_points":
            "127.0.1.1, 127.0.1.2",
        })

        self.assertEqual(cluster.contact_points, ["127.0.1.1", "127.0.1.2"])
Пример #5
0
    def test_alternate_prefix(self):
        cluster = cluster_from_config(
            {
                "noodle.contact_points": "127.0.1.1, 127.0.1.2",
            },
            prefix="noodle.")

        self.assertEqual(cluster.contact_points, ["127.0.1.1", "127.0.1.2"])
Пример #6
0
 def test_credentials(self):
     secrets = mock.Mock(autospec=SecretsStore)
     cluster = cluster_from_config(
         {
             "cassandra.contact_points": "127.0.0.1",
             "cassandra.credentials_secret": "secret/foo/bar",
         },
         secrets=secrets,
     )
     self.assertIsNotNone(cluster.auth_provider)
def create_schema(app_config):
    """Create schema in the database.

    Run this with:

        baseplate-script example.ini {{cookiecutter.module_name}}.models.cql:create_schema

    """
    keyspace = '{{ cookiecutter.project_slug }}'
    cluster = cluster_from_config(app_config)
    session = cluster.connect()
    conn = connection.Connection(session)
    create_keyspace_simple(conn, keyspace, 1)
    session = cluster.connect(keyspace)
    conn = connection.Connection(session)
    models = [
        MyModel,
    ]
    for model in models:
        sync_table(conn, model)
Пример #8
0
    def test_alternate_prefix(self):
        cluster = cluster_from_config({
            "noodle.contact_points": "127.0.1.1, 127.0.1.2",
        }, prefix="noodle.")

        self.assertEqual(cluster.contact_points, ["127.0.1.1", "127.0.1.2"])
Пример #9
0
    def test_kwarg_passthrough(self):
        cluster = cluster_from_config({
            "cassandra.contact_points": "127.0.0.1",
        }, protocol_version=3)

        self.assertEqual(cluster.protocol_version, 3)
Пример #10
0
    def test_contact_points(self):
        cluster = cluster_from_config({
            "cassandra.contact_points": "127.0.1.1, 127.0.1.2",
        })

        self.assertEqual(cluster.contact_points, ["127.0.1.1", "127.0.1.2"])
Пример #11
0
 def test_empty_config(self):
     with self.assertRaises(ConfigurationError):
         cluster_from_config({})