Example #1
0
    def test_connection_param_validation(self):
        """
        Test to validate that invalid parameter combinations for registering connections via session are not tolerated
        @since 3.8
        @jira_ticket PYTHON-649
        @expected_result queries should execute appropriately

        @test_category object_mapper
        """
        cluster = Cluster([DSE_IP])
        session = cluster.connect()
        with self.assertRaises(CQLEngineException):
            conn.register_connection("bad_coonection1",
                                     session=session,
                                     consistency="not_null")
        with self.assertRaises(CQLEngineException):
            conn.register_connection("bad_coonection2",
                                     session=session,
                                     lazy_connect="not_null")
        with self.assertRaises(CQLEngineException):
            conn.register_connection("bad_coonection3",
                                     session=session,
                                     retry_connect="not_null")
        with self.assertRaises(CQLEngineException):
            conn.register_connection("bad_coonection4",
                                     session=session,
                                     cluster_options="not_null")
        with self.assertRaises(CQLEngineException):
            conn.register_connection("bad_coonection5",
                                     hosts="not_null",
                                     session=session)
        cluster.shutdown()

        cluster.shutdown()
Example #2
0
 def setUpClass(cls):
     super(ManagementConnectionTests, cls).setUpClass()
     conn.unregister_connection('default')
     conn.register_connection('fake_cluster', ['127.0.0.100'],
                              lazy_connect=True,
                              retry_connect=True,
                              default=True)
     conn.register_connection('cluster', [DSE_IP])
Example #3
0
    def setUpClass(cls):
        conn.register_connection('cluster', [DSE_IP])
        test_queryset.TestModel.__queryset__ = ModelQuerySetNew
        test_queryset.IndexedTestModel.__queryset__ = ModelQuerySetNew
        test_queryset.IndexedCollectionsTestModel.__queryset__ = ModelQuerySetNew
        test_queryset.TestMultiClusteringModel.__queryset__ = ModelQuerySetNew

        super(BaseConnectionTestNoDefault, cls).setUpClass()
        conn.unregister_connection('default')
Example #4
0
    def setUpClass(cls):
        super(ContextQueryConnectionTests, cls).setUpClass()
        create_keyspace_simple('ks1', 1)

        conn.unregister_connection('default')
        conn.register_connection('fake_cluster', ['127.0.0.100'],
                                 lazy_connect=True,
                                 retry_connect=True,
                                 default=True)
        conn.register_connection('cluster', [DSE_IP])

        with ContextQuery(TestModel, connection='cluster') as tm:
            sync_table(tm)
Example #5
0
    def setUpClass(cls):
        super(BatchQueryConnectionTests, cls).setUpClass()

        create_keyspace_simple('ks1', 1)
        sync_table(TestModel)
        sync_table(AnotherTestModel)

        conn.unregister_connection('default')
        conn.register_connection('fake_cluster', ['127.0.0.100'],
                                 lazy_connect=True,
                                 retry_connect=True,
                                 default=True)
        conn.register_connection('cluster', [DSE_IP])
Example #6
0
    def test_connection_from_hosts(self):
        """
        Test to ensure that you can register a connection from a list of hosts
        @since 3.8
        @jira_ticket PYTHON-692
        @expected_result queries should execute appropriately

        @test_category object_mapper
        """
        connection_name = 'from_hosts'
        conn.register_connection(connection_name, hosts=[DSE_IP])
        self.assertIsNotNone(
            conn.get_connection(connection_name).cluster.metadata.get_host(
                DSE_IP))
        self.addCleanup(conn.unregister_connection, connection_name)
Example #7
0
    def test_connection_creation_from_session(self):
        """
        Test to ensure that you can register a connection from a session
        @since 2.0
        @jira_ticket PYTHON-649
        @expected_result queries should execute appropriately

        @test_category object_mapper
        """
        cluster = Cluster([DSE_IP])
        session = cluster.connect()
        connection_name = 'from_session'
        conn.register_connection(connection_name, session=session)
        self.assertIsNotNone(
            conn.get_connection(connection_name).cluster.metadata.get_host(
                DSE_IP))
        self.addCleanup(conn.unregister_connection, connection_name)
        cluster.shutdown()