From 8a6103fcd032c5c3e80e0f21dd49ffd52cf6b3ac Mon Sep 17 00:00:00 2001 From: Nilesh Pant <58652823+NileshPant1999@users.noreply.github.com> Date: Wed, 27 Apr 2022 16:53:14 +0530 Subject: [PATCH] Bulk Post support for phase 4 migrations (#59) --- fyle/platform/apis/v1beta/admin/categories.py | 4 ++-- fyle/platform/apis/v1beta/admin/cost_centers.py | 4 ++-- .../platform/apis/v1beta/admin/expense_fields.py | 1 - fyle/platform/apis/v1beta/admin/projects.py | 4 ++-- .../platform/apis/v1beta/admin/reimbursements.py | 7 +++++++ fyle/platform/apis/v1beta/spender/merchants.py | 4 ++-- .../admin/fixtures/mock_admin_data.json | 16 ++++++++++++++++ test/integration/admin/test_admin_apis.py | 2 +- test/integration/admin/utilities.py | 1 + .../spender/fixtures/mock_spender_data.json | 4 +++- test/integration/spender/test_spender_apis.py | 2 +- 11 files changed, 37 insertions(+), 12 deletions(-) diff --git a/fyle/platform/apis/v1beta/admin/categories.py b/fyle/platform/apis/v1beta/admin/categories.py index e2c148c..d293a85 100644 --- a/fyle/platform/apis/v1beta/admin/categories.py +++ b/fyle/platform/apis/v1beta/admin/categories.py @@ -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' diff --git a/fyle/platform/apis/v1beta/admin/cost_centers.py b/fyle/platform/apis/v1beta/admin/cost_centers.py index 4fe9c0c..159de50 100644 --- a/fyle/platform/apis/v1beta/admin/cost_centers.py +++ b/fyle/platform/apis/v1beta/admin/cost_centers.py @@ -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' diff --git a/fyle/platform/apis/v1beta/admin/expense_fields.py b/fyle/platform/apis/v1beta/admin/expense_fields.py index 83d3935..b91857c 100644 --- a/fyle/platform/apis/v1beta/admin/expense_fields.py +++ b/fyle/platform/apis/v1beta/admin/expense_fields.py @@ -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 diff --git a/fyle/platform/apis/v1beta/admin/projects.py b/fyle/platform/apis/v1beta/admin/projects.py index 940369b..bb77b79 100644 --- a/fyle/platform/apis/v1beta/admin/projects.py +++ b/fyle/platform/apis/v1beta/admin/projects.py @@ -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' diff --git a/fyle/platform/apis/v1beta/admin/reimbursements.py b/fyle/platform/apis/v1beta/admin/reimbursements.py index e028004..3628826 100644 --- a/fyle/platform/apis/v1beta/admin/reimbursements.py +++ b/fyle/platform/apis/v1beta/admin/reimbursements.py @@ -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 + ) diff --git a/fyle/platform/apis/v1beta/spender/merchants.py b/fyle/platform/apis/v1beta/spender/merchants.py index 7d7841c..6bbbafe 100644 --- a/fyle/platform/apis/v1beta/spender/merchants.py +++ b/fyle/platform/apis/v1beta/spender/merchants.py @@ -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' diff --git a/test/integration/admin/fixtures/mock_admin_data.json b/test/integration/admin/fixtures/mock_admin_data.json index 922acf1..e026513 100644 --- a/test/integration/admin/fixtures/mock_admin_data.json +++ b/test/integration/admin/fixtures/mock_admin_data.json @@ -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", diff --git a/test/integration/admin/test_admin_apis.py b/test/integration/admin/test_admin_apis.py index 8ae2e21..d56dbe3 100644 --- a/test/integration/admin/test_admin_apis.py +++ b/test/integration/admin/test_admin_apis.py @@ -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 diff --git a/test/integration/admin/utilities.py b/test/integration/admin/utilities.py index 0f26dfc..1d8783a 100644 --- a/test/integration/admin/utilities.py +++ b/test/integration/admin/utilities.py @@ -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'] diff --git a/test/integration/spender/fixtures/mock_spender_data.json b/test/integration/spender/fixtures/mock_spender_data.json index 2b11fc3..af98881 100644 --- a/test/integration/spender/fixtures/mock_spender_data.json +++ b/test/integration/spender/fixtures/mock_spender_data.json @@ -35,6 +35,8 @@ "upload_url": "string" }, "create_expense": { + "activity_details":"None", + "per_diem_num_days": "None", "id": "txwownwrng", "user_id": "uswjwgnwwgo", "user": { @@ -49,6 +51,7 @@ "source": "SLACK_APP", "merchant": "Uber", "currency": "USD", + "creator_user_id": "usqywo0f3nBY", "amount": 1500, "claim_amount": 1984.18, "policy_amount": 1500, @@ -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": [ diff --git a/test/integration/spender/test_spender_apis.py b/test/integration/spender/test_spender_apis.py index 471f9eb..ce24b83 100644 --- a/test/integration/spender/test_spender_apis.py +++ b/test/integration/spender/test_spender_apis.py @@ -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'