Esempio n. 1
0
    def test_flatten(self):
        with tbz.loader() as l:
            company = l.query( tbz.SalesReps )\
                       .filter( tbz.SalesReps.sfdc_alias == 'integ' )\
                       .one()

            aeich = l.query( tbz.SalesReps )\
                     .filter( tbz.SalesReps.sfdc_alias == 'aeich' )\
                     .one()

        rows = touchbiz.touchbiz_by_account_id(1002)

        row = touchbiz.flatten(rows[0])
        self.assertEqual(row.created, datetime(2014, 4, 8))
        self.assertEqual(row.tier, 'trial')
        self.assertEqual(row.retention, 15)
        self.assertEqual(row.volume, 0)
        self.assertEqual(row.rate, 0)
        self.assertEqual(row.owner, company.sfdc_alias)

        row = touchbiz.flatten(rows[1])
        self.assertEqual(row.created, datetime(2014, 9, 22, 1))
        self.assertEqual(row.tier, 'development')
        self.assertEqual(row.retention, 7)
        self.assertEqual(row.volume, 1000000000)
        self.assertEqual(row.rate, 49)
        self.assertEqual(row.owner, company.sfdc_alias)

        row = touchbiz.flatten(rows[2])
        self.assertEqual(row.created, 'pending')
        self.assertEqual(row.tier, 'Production')
        self.assertEqual(row.retention, 15)
        self.assertEqual(row.volume, '200000000000')
        self.assertEqual(row.rate, 109)
        self.assertEqual(row.owner, aeich.sfdc_alias)
Esempio n. 2
0
    def test_apply_pending_applicable(self):
        with adb.loader() as l:
            sub_entries = l.query( adb.AccountStateUncompressed )\
                           .filter( adb.AccountStateUncompressed.acct_id == 1004 )\
                           .all()

        with tbz.loader() as l:
            company = l.query( tbz.SalesReps )\
                       .filter( tbz.SalesReps.sfdc_alias == 'integ' )\
                       .one()

            aeich = l.query( tbz.SalesReps )\
                     .filter( tbz.SalesReps.sfdc_alias == 'aeich' )\
                     .one()


            tb_entries = l.query( tbz.Touchbiz )\
                          .filter( tbz.Touchbiz.acct_id == 1004 )\
                          .all()

        applied = touchbiz.apply_touchbiz(sub_entries, tb_entries)

        self.assertEqual(len(applied), 3)
        self.assertEqual(applied[0].owner.sfdc_alias, company.sfdc_alias)
        self.assertEqual(applied[0].status, 'won')
        self.assertEqual(applied[1].owner.sfdc_alias, aeich.sfdc_alias)
        self.assertEqual(applied[1].status, 'won')
        self.assertEqual(applied[2].owner.sfdc_alias, aeich.sfdc_alias)
        self.assertEqual(applied[2].status, 'pending')
Esempio n. 3
0
    def test_touchbiz_by_account(self):
        with tbz.loader() as l:
            company = l.query( tbz.SalesReps )\
                       .filter( tbz.SalesReps.sfdc_alias == 'integ' )\
                       .one()

            aeich = l.query( tbz.SalesReps )\
                     .filter( tbz.SalesReps.sfdc_alias == 'aeich' )\
                     .one()

        rows = touchbiz.touchbiz_by_account('touchbiztest')

        self.assertEqual(len(rows), 4)
        self.assertEqual(rows[0].owner.sfdc_alias, company.sfdc_alias)
        self.assertEqual(rows[1].owner.sfdc_alias, company.sfdc_alias)
        self.assertEqual(rows[2].owner.sfdc_alias, aeich.sfdc_alias)
        self.assertEqual(rows[3].owner.sfdc_alias, aeich.sfdc_alias)
Esempio n. 4
0
    def test_dictify(self):
        with tbz.loader() as l:
            company = l.query( tbz.SalesReps )\
                       .filter( tbz.SalesReps.sfdc_alias == 'integ' )\
                       .one()

            aeich = l.query( tbz.SalesReps )\
                     .filter( tbz.SalesReps.sfdc_alias == 'aeich' )\
                     .one()

        columns = ('tRate', 'tGB', 'tDays', 'owner.sfdc_alias', 'owner.email')
        rows = touchbiz.dictify(touchbiz.touchbiz_by_account_id(1000), columns)

        self.assertEqual(len(rows), 4)
        self.assertEqual(rows[0]['tRate'], 0)
        self.assertEqual(rows[0]['tGB'], 0)
        self.assertEqual(rows[0]['tDays'], 15)
        self.assertEqual(rows[0]['owner.sfdc_alias'], company.sfdc_alias)
        self.assertEqual(rows[0]['owner.email'], company.email)

        self.assertEqual(rows[1]['tRate'], 0)
        self.assertEqual(rows[1]['tGB'], 200000000)
        self.assertEqual(rows[1]['tDays'], 7)
        self.assertEqual(rows[1]['owner.sfdc_alias'], company.sfdc_alias)
        self.assertEqual(rows[1]['owner.email'], company.email)

        self.assertEqual(rows[2]['tRate'], 49)
        self.assertEqual(rows[2]['tGB'], 1000000000)
        self.assertEqual(rows[2]['tDays'], 7)
        self.assertEqual(rows[2]['owner.sfdc_alias'], aeich.sfdc_alias)
        self.assertEqual(rows[2]['owner.email'], aeich.email)

        self.assertEqual(rows[3]['tRate'], 99)
        self.assertEqual(rows[3]['tGB'], 2000000000)
        self.assertEqual(rows[3]['tDays'], 15)
        self.assertEqual(rows[3]['owner.sfdc_alias'], aeich.sfdc_alias)
        self.assertEqual(rows[3]['owner.email'], aeich.email)
Esempio n. 5
0
    def test_tuplify(self):
        with tbz.loader() as l:
            company = l.query( tbz.SalesReps )\
                       .filter( tbz.SalesReps.sfdc_alias == 'integ' )\
                       .one()

            aeich = l.query( tbz.SalesReps )\
                     .filter( tbz.SalesReps.sfdc_alias == 'aeich' )\
                     .one()

        columns = ('tRate', 'tGB', 'tDays', 'owner.sfdc_alias', 'owner.email')
        rows = touchbiz.tuplify(touchbiz.touchbiz_by_account_id(1000), columns)

        self.assertEqual(len(rows), 4)
        self.assertEqual(rows[0][0], ('tRate', 0))
        self.assertEqual(rows[0][1], ('tGB', 0))
        self.assertEqual(rows[0][2], ('tDays', 15))
        self.assertEqual(rows[0][3], ('owner.sfdc_alias', company.sfdc_alias))
        self.assertEqual(rows[0][4], ('owner.email', company.email))

        self.assertEqual(rows[1][0], ('tRate', 0))
        self.assertEqual(rows[1][1], ('tGB', 200000000))
        self.assertEqual(rows[1][2], ('tDays', 7))
        self.assertEqual(rows[1][3], ('owner.sfdc_alias', company.sfdc_alias))
        self.assertEqual(rows[1][4], ('owner.email', company.email))

        self.assertEqual(rows[2][0], ('tRate', 49))
        self.assertEqual(rows[2][1], ('tGB', 1000000000))
        self.assertEqual(rows[2][2], ('tDays', 7))
        self.assertEqual(rows[2][3], ('owner.sfdc_alias', aeich.sfdc_alias))
        self.assertEqual(rows[2][4], ('owner.email', aeich.email))

        self.assertEqual(rows[3][0], ('tRate', 99))
        self.assertEqual(rows[3][1], ('tGB', 2000000000))
        self.assertEqual(rows[3][2], ('tDays', 15))
        self.assertEqual(rows[3][3], ('owner.sfdc_alias', aeich.sfdc_alias))
        self.assertEqual(rows[3][4], ('owner.email', aeich.email))
    def test_migrate(self):
        src = DataSource(adb.Owners, adb.loader)
        dest = DataDestination(tbz.Touchbiz, tbz.engine)

        migrator = AccountOwnersMigrator(src,
                                         dest,
                                         default_rep='Hoover Loggly')
        migrator.migrate()

        with tbz.loader() as l:
            touchbiz = l.query(tbz.Touchbiz).order_by(
                tbz.Touchbiz.acct_id).all()

        self.assertEqual(len(touchbiz), 5)

        entry = touchbiz[0]
        self.assertEqual(entry.acct_id, 1000)
        self.assertEqual(entry.sales_rep_id, 2)
        self.assertEqual(entry.created, datetime(2014, 4, 8, 7))
        self.assertEqual(entry.modified, datetime(2014, 4, 8, 7))
        self.assertEqual(entry.tier, '')
        self.assertEqual(entry.retention, 0)
        self.assertEqual(entry.volume, '0')
        self.assertEqual(entry.sub_rate, 0)
        self.assertEqual(entry.billing_period, '')

        entry = touchbiz[1]
        self.assertEqual(entry.acct_id, 1000)
        self.assertEqual(entry.sales_rep_id, 5)
        self.assertEqual(entry.created, datetime(2014, 4, 10, 7))
        self.assertEqual(entry.modified, datetime(2014, 4, 10, 7))
        self.assertEqual(entry.tier, '')
        self.assertEqual(entry.retention, 0)
        self.assertEqual(entry.volume, '0')
        self.assertEqual(entry.sub_rate, 0)
        self.assertEqual(entry.billing_period, '')

        entry = touchbiz[2]
        self.assertEqual(entry.acct_id, 1001)
        self.assertEqual(entry.sales_rep_id, 1)
        self.assertEqual(entry.created, datetime(2014, 5, 5, 7))
        self.assertEqual(entry.modified, datetime(2014, 5, 5, 7))
        self.assertEqual(entry.tier, '')
        self.assertEqual(entry.retention, 0)
        self.assertEqual(entry.volume, '0')
        self.assertEqual(entry.sub_rate, 0)
        self.assertEqual(entry.billing_period, '')

        entry = touchbiz[3]
        self.assertEqual(entry.acct_id, 1004)
        self.assertEqual(entry.sales_rep_id, 5)
        self.assertEqual(entry.created, datetime(2014, 10, 10, 7))
        self.assertEqual(entry.modified, datetime(2014, 10, 10, 7))
        self.assertEqual(entry.tier, '')
        self.assertEqual(entry.retention, 0)
        self.assertEqual(entry.volume, '0')
        self.assertEqual(entry.sub_rate, 0)
        self.assertEqual(entry.billing_period, '')

        entry = touchbiz[4]
        self.assertEqual(entry.acct_id, 1004)
        self.assertEqual(entry.sales_rep_id, 2)
        self.assertEqual(entry.created, datetime(2015, 1, 6, 8, 1))
        self.assertEqual(entry.modified, datetime(2015, 1, 6, 8, 1))
        self.assertEqual(entry.tier, '')
        self.assertEqual(entry.retention, 0)
        self.assertEqual(entry.volume, '0')
        self.assertEqual(entry.sub_rate, 0)
        self.assertEqual(entry.billing_period, '')