Ejemplo n.º 1
0
    def test_get_asset(self,
                       name,
                       exp_value,
                       exp_code,
                       side_effect=None,
                       called=True):
        resource_entry = views.AssetEntry(permitted_methods=('GET', ))
        self.am_instance.get_asset_info.return_value = exp_value

        if side_effect is not None:
            side_effect(self)

        request = self.factory.get(
            '/charging/api/assetsManagement/assets/1111',
            HTTP_ACCEPT='application/json')
        request.user = self.user

        response = resource_entry.read(request, '1111')
        self.assertEquals(response.status_code, exp_code)
        self.assertEqual(response.get('Content-type'),
                         'application/json; charset=utf-8')

        body_response = json.loads(response.content)
        self.assertEquals(body_response, exp_value)

        if called:
            self.am_instance.get_asset_info.assert_called_once_with('1111')
        else:
            self.assertEquals(self.am_instance.get_asset_info.call_count, 0)
Ejemplo n.º 2
0
from wstore.reports import views as reports_views

urlpatterns = [
    # API
    url(r'^charging/api/assetManagement/assets/?$',
        offering_views.AssetCollection(permitted_methods=('GET', ))),
    url(r'^charging/api/assetManagement/assets/uploadJob/?$',
        offering_views.UploadCollection(permitted_methods=('POST', ))),
    url(r'^charging/api/assetManagement/assets/validateJob/?$',
        offering_views.ValidateCollection(permitted_methods=('POST', ))),
    url(
        r'^charging/api/assetManagement/assets/offeringJob/?$',
        offering_views.ValidateOfferingCollection(
            permitted_methods=('POST', ))),
    url(r'^charging/api/assetManagement/assets/(?P<asset_id>\w+)/?$',
        offering_views.AssetEntry(permitted_methods=('GET', ))),
    url(
        r'^charging/api/assetManagement/assets/(?P<asset_id>\w+)/upgradeJob/?$',
        offering_views.UpgradeCollection(permitted_methods=('POST', ))),
    url(r'^charging/api/assetManagement/assets/product/(?P<product_id>\w+)/?$',
        offering_views.AssetEntryFromProduct(permitted_methods=('GET', ))),
    url(r'^charging/api/assetManagement/assetTypes/?$',
        plugins_views.PluginCollection(permitted_methods=('GET', ))),
    url(r'^charging/api/assetManagement/assetTypes/(?P<plugin_id>[\w -]+)/?$',
        plugins_views.PluginEntry(permitted_methods=('GET', ))),
    url(r'^charging/api/assetManagement/chargePeriods/?$',
        admin_views.ChargePeriodCollection(permitted_methods=('GET', ))),
    url(r'^charging/api/assetManagement/currencyCodes/?$',
        admin_views.CurrencyCodeCollection(permitted_methods=('GET', ))),
    url(r'^charging/api/orderManagement/orders/?$',
        ordering_views.OrderingCollection(permitted_methods=('POST', ))),
Ejemplo n.º 3
0
from wstore.charging_engine import views as charging_views
from wstore.charging_engine.accounting import views as accounting_views
from wstore.reports import views as reports_views
from wstore.product import views as product_views

urlpatterns = patterns('',
    # API
    url(r'^charging/api/token/?$', token_views.TokenCollection(permitted_methods=('POST',))),
    url(r'^charging/api/token/refresh?$', token_views.TokenRefresh(permitted_methods=('POST',))),
    url(r'^charging/api/token/read?$', token_views.TokenRead(permitted_methods=('POST',))),
    url(r'^charging/api/assetManagement/assets/createProduct?$', product_views.ProductSpecification(permitted_methods=('POST',))),
    url(r'^charging/api/assetManagement/assets/?$', offering_views.AssetCollection(permitted_methods=('GET',))),
    url(r'^charging/api/assetManagement/assets/uploadJob/?$', offering_views.UploadCollection(permitted_methods=('POST',))),
    url(r'^charging/api/assetManagement/assets/validateJob/?$', offering_views.ValidateCollection(permitted_methods=('POST',))),
    url(r'^charging/api/assetManagement/assets/offeringJob/?$', offering_views.ValidateOfferingCollection(permitted_methods=('POST',))),
    url(r'^charging/api/assetManagement/assets/(?P<asset_id>\w+)/?$', offering_views.AssetEntry(permitted_methods=('GET',))),
    url(r'^charging/api/assetManagement/assets/(?P<asset_id>\w+)/upgradeJob/?$', offering_views.UpgradeCollection(permitted_methods=('POST',))),
    url(r'^charging/api/assetManagement/assets/product/(?P<product_id>\w+)/?$', offering_views.AssetEntryFromProduct(permitted_methods=('GET',))),
    url(r'^charging/api/assetManagement/assetTypes/?$', plugins_views.PluginCollection(permitted_methods=('GET', ))),
    url(r'^charging/api/assetManagement/assetTypes/(?P<plugin_id>[\w -]+)/?$', plugins_views.PluginEntry(permitted_methods=('GET',))),

    url(r'^charging/api/orderManagement/orders/?$', ordering_views.OrderingCollection(permitted_methods=('POST',))),
    url(r'^charging/api/orderManagement/orders/accept/?$', charging_views.PayPalConfirmation(permitted_methods=('POST',))),
    url(r'^charging/api/orderManagement/orders/cancel/?$', charging_views.PayPalCancellation(permitted_methods=('POST',))),
    url(r'^charging/api/orderManagement/orders/refund/?$', charging_views.PayPalRefund(permitted_methods=('POST',))),
    url(r'^charging/api/orderManagement/products/?$', ordering_views.InventoryCollection(permitted_methods=('POST',))),
    url(r'^charging/api/orderManagement/products/renewJob/?$', ordering_views.RenovationCollection(permitted_methods=('POST',))),
    url(r'^charging/api/orderManagement/accounting/?$', accounting_views.ServiceRecordCollection(permitted_methods=('POST',))),
    url(r'^charging/api/orderManagement/accounting/refresh/?$', accounting_views.SDRRefreshCollection(permitted_methods=('POST',))),
    url(r'^charging/api/reportManagement/created/?$', reports_views.ReportReceiver(permitted_methods=('POST',)))
)