Beispiel #1
0
    def from_crawler(cls, crawler):
        """Gets settings for the pipeline from the crawler.
        @param crawler: crawler
        """
        settings = crawler.settings

        # get relevant settings for the pipeline
        connection_settings = settings.get('RETHINKDB_CONNECTION', {})
        table_name = settings.get('RETHINKDB_TABLE', None)
        insert_options = settings.get('RETHINKDB_INSERT_OPTIONS', {})

        # creates driver instance
        driver = RethinkDBDriver(connection_settings)

        return cls(driver, table_name, insert_options)
Beispiel #2
0
    def setUp(self):
        # mocks
        self.stmt_mock = Mock(spec=RqlQuery)
        self.table_query_mock = Mock(spec=RqlQuery)

        # global patch for the official driver
        self.r_patcher = patch('scrapy_rethinkdb.driver.r')
        self.r = self.r_patcher.start()

        # default driver under test and connection call expected
        self.driver = RethinkDBDriver({'param1': 1, 'param2': 2})
        self.connection_call = call(param1=1, param2=2)

        #table name
        self.table_name = 'table'