-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be221fb
commit 140a47c
Showing
4 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from apps.internal.actions import get_accounting_fields, get_exported_entry | ||
from tests.test_quickbooks_online.fixtures import data | ||
|
||
|
||
def test_get_accounting_fields(db, mocker): | ||
query_params = { | ||
'org_id': 'or79Cob97KSh', | ||
'resource_type': 'employees', | ||
} | ||
mocker.patch( | ||
'qbosdk.apis.Employees.get_all_generator', | ||
return_value=[data['employee_response']] | ||
) | ||
|
||
fields = get_accounting_fields(query_params) | ||
assert fields is not None | ||
|
||
|
||
def test_get_exported_entry(db, mocker): | ||
query_params = { | ||
'org_id': 'or79Cob97KSh', | ||
'resource_type': 'bills', | ||
'internal_id': '1' | ||
} | ||
mocker.patch( | ||
'qbosdk.apis.Bills.get_by_id', | ||
return_value={'summa': 'hehe'} | ||
) | ||
|
||
entry = get_exported_entry(query_params) | ||
assert entry is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
from django.urls import reverse | ||
|
||
from apps.workspaces.permissions import IsAuthenticatedForInternalAPI | ||
|
||
from tests.test_quickbooks_online.fixtures import data | ||
|
||
|
||
@pytest.mark.django_db(databases=['default']) | ||
@patch.object(IsAuthenticatedForInternalAPI, 'has_permission', return_value=True) | ||
def test_qbo_fields_view(db, api_client, mocker): | ||
url = reverse('accounting-fields') | ||
|
||
response = api_client.get(url) | ||
assert response.status_code == 400 | ||
|
||
response = api_client.get(url, {'org_id': 'or79Cob97KSh'}) | ||
assert response.status_code == 400 | ||
|
||
mocker.patch( | ||
'qbosdk.apis.Employees.get_all_generator', | ||
return_value=[data['employee_response']] | ||
) | ||
|
||
response = api_client.get(url, {'org_id': 'or79Cob97KSh', 'resource_type': 'employees'}) | ||
assert response.status_code == 200 | ||
|
||
|
||
@pytest.mark.django_db(databases=['default']) | ||
@patch.object(IsAuthenticatedForInternalAPI, 'has_permission', return_value=True) | ||
def test_exported_entry_view(db, api_client, mocker): | ||
url = reverse('exported-entry') | ||
|
||
response = api_client.get(url) | ||
assert response.status_code == 400 | ||
|
||
response = api_client.get(url, {'org_id': 'or79Cob97KSh'}) | ||
assert response.status_code == 400 | ||
|
||
response = api_client.get(url, {'org_id': 'or79Cob97KSh', 'resource_type': 'bills'}) | ||
assert response.status_code == 400 | ||
|
||
mocker.patch( | ||
'qbosdk.apis.Bills.get_by_id', | ||
return_value={'summa': 'hehe'} | ||
) | ||
|
||
response = api_client.get(url, {'org_id': 'or79Cob97KSh', 'resource_type': 'bills', 'internal_id': '1'}) | ||
assert response.status_code == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters