當前位置: 首頁>>代碼示例>>Python>>正文


Python company.CompanyModel類代碼示例

本文整理匯總了Python中billy.models.company.CompanyModel的典型用法代碼示例。如果您正苦於以下問題:Python CompanyModel類的具體用法?Python CompanyModel怎麽用?Python CompanyModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CompanyModel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

 def setUp(self):
     from billy.models.company import CompanyModel
     from billy.models.customer import CustomerModel
     from billy.models.plan import PlanModel
     self.settings = {
         'billy.processor_factory': DummyProcessor
     }
     super(TestSubscriptionViews, self).setUp()
     company_model = CompanyModel(self.testapp.session)
     customer_model = CustomerModel(self.testapp.session)
     plan_model = PlanModel(self.testapp.session)
     with db_transaction.manager:
         self.company_guid = company_model.create(
             processor_key='MOCK_PROCESSOR_KEY',
         )
         self.customer_guid = customer_model.create(
             company_guid=self.company_guid
         )
         self.plan_guid = plan_model.create(
             company_guid=self.company_guid,
             frequency=plan_model.FREQ_WEEKLY,
             plan_type=plan_model.TYPE_CHARGE,
             amount=10,
         )
     company = company_model.get(self.company_guid)
     self.api_key = str(company.api_key)
開發者ID:mjallday,項目名稱:billy,代碼行數:26,代碼來源:test_subscription.py

示例2: test_get_subscription_of_other_company

    def test_get_subscription_of_other_company(self):
        from billy.models.company import CompanyModel
        from billy.models.customer import CustomerModel
        from billy.models.plan import PlanModel

        company_model = CompanyModel(self.testapp.session)
        customer_model = CustomerModel(self.testapp.session)
        plan_model = PlanModel(self.testapp.session)
        with db_transaction.manager:
            other_company_guid = company_model.create(processor_key="MOCK_PROCESSOR_KEY")
            other_customer_guid = customer_model.create(company_guid=other_company_guid)
            other_plan_guid = plan_model.create(
                company_guid=other_company_guid,
                frequency=plan_model.FREQ_WEEKLY,
                plan_type=plan_model.TYPE_CHARGE,
                amount=10,
            )
        other_company = company_model.get(other_company_guid)
        other_api_key = str(other_company.api_key)

        res = self.testapp.post(
            "/v1/subscriptions",
            dict(customer_guid=other_customer_guid, plan_guid=other_plan_guid),
            extra_environ=dict(REMOTE_USER=other_api_key),
            status=200,
        )
        other_guid = res.json["guid"]

        self.testapp.get(
            "/v1/subscriptions/{}".format(other_guid), extra_environ=dict(REMOTE_USER=self.api_key), status=403
        )
開發者ID:JeffersonK,項目名稱:billy,代碼行數:31,代碼來源:test_subscription.py

示例3: test_create_subscription_to_other_company_plan

    def test_create_subscription_to_other_company_plan(self):
        from billy.models.company import CompanyModel
        from billy.models.plan import PlanModel

        company_model = CompanyModel(self.testapp.session)
        plan_model = PlanModel(self.testapp.session)
        with db_transaction.manager:
            other_company_guid = company_model.create(
                processor_key='MOCK_PROCESSOR_KEY',
            )
            other_plan_guid = plan_model.create(
                company_guid=other_company_guid,
                frequency=plan_model.FREQ_WEEKLY,
                plan_type=plan_model.TYPE_CHARGE,
                amount=10,
            )

        self.testapp.post(
            '/v1/subscriptions', 
            dict(
                customer_guid=self.customer_guid,
                plan_guid=other_plan_guid,
            ),
            extra_environ=dict(REMOTE_USER=self.api_key), 
            status=403,
        )
開發者ID:mjallday,項目名稱:billy,代碼行數:26,代碼來源:test_subscription.py

示例4: setUp

 def setUp(self):
     from billy.models.company import CompanyModel
     super(TestPlanViews, self).setUp()
     model = CompanyModel(self.testapp.session)
     with db_transaction.manager:
         self.company_guid = model.create(processor_key='MOCK_PROCESSOR_KEY')
     company = model.get(self.company_guid)
     self.api_key = str(company.api_key)
開發者ID:mjallday,項目名稱:billy,代碼行數:8,代碼來源:test_plan.py

示例5: auth_api_key

def auth_api_key(request):
    """Authenticate API KEY and return corresponding company

    """
    model = CompanyModel(request.session)
    company = model.get_by_api_key(unicode(request.remote_user))
    if company is None:
        raise HTTPForbidden('Invalid API key {}'.format(request.remote_user))
    return company
開發者ID:JeffersonK,項目名稱:billy,代碼行數:9,代碼來源:auth.py

示例6: company_list_post

def company_list_post(request):
    """Create a new company

    """
    form = validate_form(CompanyCreateForm, request)
    processor_key = form.data['processor_key']

    model = CompanyModel(request.session)
    # TODO: do validation here
    with db_transaction.manager:
        guid = model.create(processor_key=processor_key)
    company = model.get(guid)
    return company
開發者ID:JeffersonK,項目名稱:billy,代碼行數:13,代碼來源:views.py

示例7: company_get

def company_get(request):
    """Get and return a company

    """
    api_company = auth_api_key(request)
    model = CompanyModel(request.session)
    guid = request.matchdict['company_guid']
    company = model.get(guid)
    if company is None:
        return HTTPNotFound('No such company {}'.format(guid))
    if guid != api_company.guid:
        return HTTPForbidden('You have no premission to access company {}'.format(guid))
    return company
開發者ID:JeffersonK,項目名稱:billy,代碼行數:13,代碼來源:views.py

示例8: test_company

 def test_company(self):
     from billy.models.company import CompanyModel
     from billy.renderers import company_adapter
     company_model = CompanyModel(self.testapp.session)
     company = company_model.get(self.company_guid)
     json_data = company_adapter(company, self.dummy_request)
     expected = dict(
         guid=company.guid,
         api_key=company.api_key,
         created_at=company.created_at.isoformat(),
         updated_at=company.updated_at.isoformat(),
     )
     self.assertEqual(json_data, expected)
開發者ID:JeffersonK,項目名稱:billy,代碼行數:13,代碼來源:test_renderer.py

示例9: setUp

 def setUp(self):
     from billy.models.company import CompanyModel
     from billy.models.customer import CustomerModel
     from billy.models.plan import PlanModel
     from billy.models.subscription import SubscriptionModel
     from billy.models.transaction import TransactionModel
     super(TestBalancedProcessorModel, self).setUp()
     # build the basic scenario for transaction model
     self.company_model = CompanyModel(self.session)
     self.customer_model = CustomerModel(self.session)
     self.plan_model = PlanModel(self.session)
     self.subscription_model = SubscriptionModel(self.session)
     self.transaction_model = TransactionModel(self.session)
     with db_transaction.manager:
         self.company_guid = self.company_model.create('my_secret_key')
         self.plan_guid = self.plan_model.create(
             company_guid=self.company_guid,
             plan_type=self.plan_model.TYPE_CHARGE,
             amount=10,
             frequency=self.plan_model.FREQ_MONTHLY,
         )
         self.customer_guid = self.customer_model.create(
             company_guid=self.company_guid,
         )
         self.subscription_guid = self.subscription_model.create(
             customer_guid=self.customer_guid,
             plan_guid=self.plan_guid,
             payment_uri='/v1/credit_card/tester',
         )
開發者ID:JeffersonK,項目名稱:billy,代碼行數:29,代碼來源:test_processors.py

示例10: test_create_subscription_to_other_company_customer

    def test_create_subscription_to_other_company_customer(self):
        from billy.models.company import CompanyModel
        from billy.models.customer import CustomerModel

        company_model = CompanyModel(self.testapp.session)
        customer_model = CustomerModel(self.testapp.session)
        with db_transaction.manager:
            other_company_guid = company_model.create(processor_key="MOCK_PROCESSOR_KEY")
            other_customer_guid = customer_model.create(company_guid=other_company_guid)

        self.testapp.post(
            "/v1/subscriptions",
            dict(customer_guid=other_customer_guid, plan_guid=self.plan_guid),
            extra_environ=dict(REMOTE_USER=self.api_key),
            status=403,
        )
開發者ID:JeffersonK,項目名稱:billy,代碼行數:16,代碼來源:test_subscription.py

示例11: setUp

 def setUp(self):
     from billy.models.company import CompanyModel
     super(TestPlanModel, self).setUp()
     # build the basic scenario for plan model
     self.company_model = CompanyModel(self.session)
     with transaction.manager:
         self.company_guid = self.company_model.create('my_secret_key')
開發者ID:mjallday,項目名稱:billy,代碼行數:7,代碼來源:test_plan.py

示例12: setUp

 def setUp(self):
     from billy.models.company import CompanyModel
     from billy.models.customer import CustomerModel
     from billy.models.plan import PlanModel
     super(TestSubscriptionModel, self).setUp()
     # build the basic scenario for plan model
     self.company_model = CompanyModel(self.session)
     self.customer_model = CustomerModel(self.session)
     self.plan_model = PlanModel(self.session)
     with db_transaction.manager:
         self.company_guid = self.company_model.create('my_secret_key')
         self.daily_plan_guid = self.plan_model.create(
             company_guid=self.company_guid,
             plan_type=self.plan_model.TYPE_CHARGE,
             amount=1000,  # 10 dollars
             frequency=self.plan_model.FREQ_DAILY,
         )
         self.weekly_plan_guid = self.plan_model.create(
             company_guid=self.company_guid,
             plan_type=self.plan_model.TYPE_CHARGE,
             amount=1000,
             frequency=self.plan_model.FREQ_WEEKLY,
         )
         self.monthly_plan_guid = self.plan_model.create(
             company_guid=self.company_guid,
             plan_type=self.plan_model.TYPE_CHARGE,
             amount=1000,
             frequency=self.plan_model.FREQ_MONTHLY,
         )
         self.customer_tom_guid = self.customer_model.create(
             company_guid=self.company_guid,
         )
開發者ID:JeffersonK,項目名稱:billy,代碼行數:32,代碼來源:test_subscription.py

示例13: test_cancel_subscription_to_other_company

    def test_cancel_subscription_to_other_company(self):
        from billy.models.subscription import SubscriptionModel
        from billy.models.company import CompanyModel

        subscription_model = SubscriptionModel(self.testapp.session)
        company_model = CompanyModel(self.testapp.session)

        with db_transaction.manager:
            subscription_guid = subscription_model.create(customer_guid=self.customer_guid, plan_guid=self.plan_guid)
            other_company_guid = company_model.create(processor_key="MOCK_PROCESSOR_KEY")
            other_company = company_model.get(other_company_guid)
            other_api_key = str(other_company.api_key)

        self.testapp.post(
            "/v1/subscriptions/{}/cancel".format(subscription_guid),
            extra_environ=dict(REMOTE_USER=other_api_key),
            status=403,
        )
開發者ID:JeffersonK,項目名稱:billy,代碼行數:18,代碼來源:test_subscription.py

示例14: test_get_customer_of_other_company

 def test_get_customer_of_other_company(self):
     from billy.models.company import CompanyModel
     model = CompanyModel(self.testapp.session)
     with db_transaction.manager:
         other_company_guid = model.create(processor_key='MOCK_PROCESSOR_KEY')
     other_company = model.get(other_company_guid)
     other_api_key = str(other_company.api_key)
     res = self.testapp.post(
         '/v1/customers', 
         extra_environ=dict(REMOTE_USER=other_api_key), 
         status=200,
     )
     guid = res.json['guid']
     res = self.testapp.get(
         '/v1/customers/{}'.format(guid), 
         extra_environ=dict(REMOTE_USER=self.api_key), 
         status=403,
     )
開發者ID:JeffersonK,項目名稱:billy,代碼行數:18,代碼來源:test_customer.py

示例15: test_server_info_with_transaction

    def test_server_info_with_transaction(self):
        from billy.models.company import CompanyModel
        from billy.models.customer import CustomerModel
        from billy.models.plan import PlanModel
        from billy.models.subscription import SubscriptionModel
        from billy.models.transaction import TransactionModel

        company_model = CompanyModel(self.testapp.session)
        customer_model = CustomerModel(self.testapp.session)
        plan_model = PlanModel(self.testapp.session)
        subscription_model = SubscriptionModel(self.testapp.session)
        transaction_model = TransactionModel(self.testapp.session)

        with db_transaction.manager:
            company_guid = company_model.create(
                processor_key='MOCK_PROCESSOR_KEY',
            )
            customer_guid = customer_model.create(
                company_guid=company_guid
            )
            plan_guid = plan_model.create(
                company_guid=company_guid,
                frequency=plan_model.FREQ_WEEKLY,
                plan_type=plan_model.TYPE_CHARGE,
                amount=10,
            )
            subscription_guid = subscription_model.create(
                customer_guid=customer_guid,
                plan_guid=plan_guid,
            )
            transaction_guid = transaction_model.create(
                subscription_guid=subscription_guid,
                transaction_type=transaction_model.TYPE_CHARGE,
                amount=10,
                payment_uri='/v1/cards/tester',
                scheduled_at=datetime.datetime.utcnow(),
            )

        transaction = transaction_model.get(transaction_guid)

        res = self.testapp.get('/', status=200)
        self.assertEqual(res.json['last_transaction_created_at'], 
                         transaction.created_at.isoformat())
開發者ID:JeffersonK,項目名稱:billy,代碼行數:43,代碼來源:test_server_info.py


注:本文中的billy.models.company.CompanyModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。