コード例 #1
0
    def requires(self):  # pragma: no cover
        for requirement in super(EnterpriseEnrollmentDataTask,
                                 self).requires():
            yield requirement

        # the process that generates the source table used by this query
        yield (
            ImportAuthUserTask(),
            ImportAuthUserProfileTask(),
            ImportEnterpriseCustomerTask(),
            ImportEnterpriseCustomerUserTask(),
            ImportEnterpriseCourseEnrollmentUserTask(),
            ImportDataSharingConsentTask(),
            ImportUserSocialAuthTask(),
            ImportStudentCourseEnrollmentTask(),
            ImportPersistentCourseGradeTask(),
            CoursePartitionTask(
                date=self.date,
                warehouse_path=self.warehouse_path,
                api_root_url=self.api_root_url,
                api_page_size=self.api_page_size,
            ),
            UserActivityTableTask(warehouse_path=self.warehouse_path,
                                  overwrite_n_days=0,
                                  date=self.date),
        )
コード例 #2
0
    def test_query_with_date(self):
        dt = '2014-07-01'
        kwargs = {
            'import_date': datetime.datetime.strptime(dt, '%Y-%m-%d').date()
        }
        task = ImportUserSocialAuthTask(**kwargs)
        query = task.query()
        expected_query = textwrap.dedent("""
            USE default;
            DROP TABLE IF EXISTS `social_auth_usersocialauth`;
            CREATE EXTERNAL TABLE `social_auth_usersocialauth` (
                `id` INT,`user_id` INT,`provider` STRING,`uid` STRING,`extra_data` STRING
            )
            PARTITIONED BY (dt STRING)

            LOCATION 's3://foo/bar/social_auth_usersocialauth';
            ALTER TABLE `social_auth_usersocialauth` ADD PARTITION (dt = '{dt}');
            """.format(dt=dt))
        self.assertEquals(query, expected_query)
コード例 #3
0
    def requires(self):  # pragma: no cover
        for requirement in super(EnterpriseUserDataTask, self).requires():
            yield requirement

        # the process that generates the source table used by this query
        yield (ImportAuthUserTask(), ImportAuthUserProfileTask(),
               ImportEnterpriseCustomerUserTask(), ImportUserSocialAuthTask(),
               UserActivityTableTask(warehouse_path=self.warehouse_path,
                                     overwrite_n_days=0,
                                     date=self.date))
コード例 #4
0
    def test_query_with_date(self):
        dt = '2014-07-01'
        kwargs = {'import_date': datetime.datetime.strptime(dt, '%Y-%m-%d').date()}
        task = ImportUserSocialAuthTask(**kwargs)
        query = task.query()
        expected_query = textwrap.dedent(
            """
            USE default;
            DROP TABLE IF EXISTS `social_auth_usersocialauth`;
            CREATE EXTERNAL TABLE `social_auth_usersocialauth` (
                `id` INT,`user_id` INT,`provider` STRING,`uid` STRING,`extra_data` STRING
            )
            PARTITIONED BY (dt STRING)

            LOCATION 's3://foo/bar/social_auth_usersocialauth';
            ALTER TABLE `social_auth_usersocialauth` ADD PARTITION (dt = '{dt}');
            """.format(dt=dt)
        )
        self.assertEquals(query, expected_query)
コード例 #5
0
    def requires(self):  # pragma: no cover
        for requirement in super(EnterpriseEnrollmentDataTask, self).requires():
            yield requirement

        # the process that generates the source table used by this query
        yield (
            ImportAuthUserTask(),
            ImportAuthUserProfileTask(),
            ImportEnterpriseCustomerTask(),
            ImportEnterpriseCustomerUserTask(),
            ImportEnterpriseCourseEnrollmentUserTask(),
            ImportDataSharingConsentTask(),
            ImportUserSocialAuthTask(),
            ImportStudentCourseEnrollmentTask(),
            ImportPersistentCourseGradeTask(),
            CoursePartitionTask(
                date=self.date,
                warehouse_path=self.warehouse_path,
                api_root_url=self.api_root_url,
                api_page_size=self.api_page_size,
            ),
            UserActivityTableTask(
                warehouse_path=self.warehouse_path,
                overwrite_n_days=0,
                date=self.date
            ),
            ExternalCourseEnrollmentSummaryPartitionTask(
                date=self.date
            ),
        )

        kwargs = {
            'credentials': self.otto_credentials,
            'database': self.otto_database,
        }
        yield (
            ImportProductCatalog(**kwargs),
            ImportCurrentOrderLineState(**kwargs),
            ImportCurrentOrderDiscountState(**kwargs),
            ImportVoucherTask(**kwargs),
            ImportStockRecordTask(**kwargs),
            ImportCurrentOrderState(**kwargs),
            ImportEcommerceUser(**kwargs),
            ImportConditionalOfferTask(**kwargs),
            ImportBenefitTask(**kwargs),
        )