Skip to content

Commit

Permalink
Bulk Post support for phase 4 migrations (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 authored Apr 27, 2022
1 parent 837009b commit 8a6103f
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 12 deletions.
4 changes: 2 additions & 2 deletions fyle/platform/apis/v1beta/admin/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from ....internals.list_resources import ListResources
from ....internals.list_all_resources import ListAllResources
from ....internals.post_resources import PostResources
from ....internals.post_bulk_resources import PostBulkResources


class Categories(ListResources, ListAllResources, PostResources):
class Categories(ListResources, ListAllResources, PostResources, PostBulkResources):
"""Class for Categories APIs."""

CATEGORIES = '/categories'
Expand Down
4 changes: 2 additions & 2 deletions fyle/platform/apis/v1beta/admin/cost_centers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from ....internals.list_all_resources import ListAllResources
from ....internals.list_resources import ListResources
from ....internals.post_resources import PostResources
from ....internals.post_bulk_resources import PostBulkResources


class CostCenters(ListResources, ListAllResources, PostResources):
class CostCenters(ListResources, ListAllResources, PostResources, PostBulkResources):
"""Class for Cost Center APIs."""

COST_CENTERS = '/cost_centers'
Expand Down
1 change: 0 additions & 1 deletion fyle/platform/apis/v1beta/admin/expense_fields.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
V1 Beta Admin Expense Fields
"""

from ....internals.list_all_resources import ListAllResources
from ....internals.list_resources import ListResources
from ....internals.post_resources import PostResources
Expand Down
4 changes: 2 additions & 2 deletions fyle/platform/apis/v1beta/admin/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from ....internals.list_resources import ListResources
from ....internals.list_all_resources import ListAllResources
from ....internals.post_resources import PostResources
from ....internals.post_bulk_resources import PostBulkResources


class Projects(ListResources, ListAllResources, PostResources):
class Projects(ListResources, ListAllResources, PostResources, PostBulkResources):
"""Class for Projects APIs."""

PROJECTS = '/projects'
Expand Down
7 changes: 7 additions & 0 deletions fyle/platform/apis/v1beta/admin/reimbursements.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ class Reimbursements(ListResources, ListAllResources, PostResources, GetResource
"""Class for Reimbursements APIs."""

REIMBURSEMENTS = '/reimbursements'
BULK_POST_REIMBURSEMENTS = '/reimbursements/mark_paid/bulk'

def __init__(self, version, role):
super().__init__(version, role, Reimbursements.REIMBURSEMENTS)

def bulk_post_reimbursements(self, payload):
return self.api.make_post_request(
api_url=Reimbursements.BULK_POST_REIMBURSEMENTS,
payload=payload
)
4 changes: 2 additions & 2 deletions fyle/platform/apis/v1beta/spender/merchants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
V1 Beta Spender Merchants
"""
from ....internals.post_bulk_resources import PostBulkResources
from ....internals.list_all_resources import ListAllResources
from ....internals.list_resources import ListResources


class Merchants(ListResources, ListAllResources):
class Merchants(ListResources, ListAllResources, PostBulkResources):
"""Class for Merchant APIs."""

MERCHANTS = '/merchants'
Expand Down
16 changes: 16 additions & 0 deletions test/integration/admin/fixtures/mock_admin_data.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
{
"created_accounting_export": [
{
"client_id":"None",
"created_at":"2022-04-27T09:18:14.174532+00:00",
"description":"Win the trophy",
"exported_at":"2020-06-01T13:14:54.804000+00:00",
"file_ids":[
"fiFqjxHuSwX5"
],
"id":"aeCtoS8IircK",
"name":"Accounting exports tests",
"org_id":"or79Cob97KSh",
"updated_at":"2022-04-27T09:18:14.174532+00:00",
"url":"None"
}
],
"accounting_export" : [
{
"id": "ae2froib22i0",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/admin/test_admin_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_create_accounting_exports(fyle, mock_data):
"description": "Win the trophy",
}
})
mock_accounting_exports = mock_data.accounting_export.get()
mock_accounting_exports = mock_data.created_accounting_export.get()

if create_accounting_exports["data"]:
global account_export_id
Expand Down
1 change: 1 addition & 0 deletions test/integration/admin/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def get_mock_data_dict(filename):
def get_mock_data_from_file(filename):
mock_data_dict = get_mock_data_dict(filename)
mock_data = Mock()
mock_data.created_accounting_export.get.return_value = mock_data_dict['created_accounting_export']
mock_data.accounting_export.get.return_value = mock_data_dict['accounting_export']
mock_data.accounting_export.get.return_value = mock_data_dict['accounting_export_lineitems']
mock_data.categories.get.return_value = mock_data_dict['categories']
Expand Down
4 changes: 3 additions & 1 deletion test/integration/spender/fixtures/mock_spender_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"upload_url": "string"
},
"create_expense": {
"activity_details":"None",
"per_diem_num_days": "None",
"id": "txwownwrng",
"user_id": "uswjwgnwwgo",
"user": {
Expand All @@ -49,6 +51,7 @@
"source": "SLACK_APP",
"merchant": "Uber",
"currency": "USD",
"creator_user_id": "usqywo0f3nBY",
"amount": 1500,
"claim_amount": 1984.18,
"policy_amount": 1500,
Expand Down Expand Up @@ -102,7 +105,6 @@
"name": "Florida Rate",
"code": "C1234"
},
"num_days": 2,
"started_at": "2020-06-01T13:14:54.804+00:00",
"ended_at": "2020-06-01T13:14:54.804+00:00",
"travel_classes": [
Expand Down
2 changes: 1 addition & 1 deletion test/integration/spender/test_spender_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_create_expense(fyle, mock_data):
}
})
mock_files = mock_data.create_expense.get()
if create_expense["data"]:
if create_expense["data"]:
global expense_id
expense_id = create_expense["data"]["id"]
assert dict_compare_keys(create_expense["data"], mock_files) == [], 'response from fyle.v1beta.spender.expenses.create_expense() has stuff that mock_data doesnt'
Expand Down

0 comments on commit 8a6103f

Please sign in to comment.