Skip to content

Commit

Permalink
Merge pull request #2660 from vorasmit/test-cases
Browse files Browse the repository at this point in the history
test: change of test utility
  • Loading branch information
vorasmit authored Oct 14, 2024
2 parents e9ad30a + 98e77f4 commit a113675
Show file tree
Hide file tree
Showing 41 changed files with 134 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/server-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
BRANCH_TO_CLONE: ${{ env.BRANCH }}

- name: Run Tests
run: cd ~/frappe-bench/ && bench --site test_site run-tests --app ${{ env.APP_NAME }} --coverage
run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app ${{ env.APP_NAME }} --with-coverage
env:
TYPE: server

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import re

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestAccountsSettings(FrappeTestCase):
class TestAccountsSettings(IntegrationTestCase):
def test_validate_change_in_enable_audit_trail_and_validate_delete_linked_ledger_entries(
self,
):
Expand Down
13 changes: 11 additions & 2 deletions india_compliance/audit_trail/overrides/test_property_setter.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import re

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestPropertySetter(FrappeTestCase):
class TestPropertySetter(IntegrationTestCase):
def test_validate_property_setter_where_audit_trail_enabled_and_doc_is_protected(
self,
):
frappe.db.set_single_value("Accounts Settings", "enable_audit_trail", 1)
frappe.db.delete(
"Property Setter",
{
"doctype_or_field": "DocType",
"doc_type": "Purchase Invoice",
"property": "track_changes",
},
)

doc = frappe.get_doc(
{
"doctype": "Property Setter",
Expand Down
4 changes: 2 additions & 2 deletions india_compliance/audit_trail/overrides/test_version.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import re

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase

from india_compliance.gst_india.utils.tests import create_sales_invoice


class TestVersion(FrappeTestCase):
class TestVersion(IntegrationTestCase):
def test_validate_version_where_audit_trail_enabled(self):
# enable audit trail
frappe.db.set_single_value("Accounts Settings", "enable_audit_trail", 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
from frappe.utils import today

from india_compliance.gst_india.doctype.bill_of_entry.bill_of_entry import (
Expand All @@ -18,9 +18,12 @@
from india_compliance.gst_india.utils.tests import create_purchase_invoice


class TestBillofEntry(FrappeTestCase):
class TestBillofEntry(IntegrationTestCase):
@classmethod
def setUpClass(cls):
# don't create test objects
frappe.local.test_objects["Bill of Entry"] = []

super().setUpClass()
frappe.db.set_single_value("GST Settings", "enable_overseas_transactions", 1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TesteInvoiceLog(FrappeTestCase):
class TesteInvoiceLog(IntegrationTestCase):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TesteWaybillLog(FrappeTestCase):
class TesteWaybillLog(IntegrationTestCase):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
import re

import frappe
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.tests import IntegrationTestCase, change_settings

from india_compliance.gst_india.doctype.gst_hsn_code.gst_hsn_code import (
update_taxes_in_item_master,
)


class TestGSTHSNCode(FrappeTestCase):
class TestGSTHSNCode(IntegrationTestCase):
@classmethod
def setUpClass(cls):
# don't create test objects
frappe.local.test_objects["GST HSN Code"] = []

super().setUpClass()

@change_settings("GST Settings", {"validate_hsn_code": 0})
def test_validate_hsn_when_validate_hsn_code_disabled(self):
doc = frappe.get_doc({"doctype": "GST HSN Code", "hsn_code": "1"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestGSTInwardSupply(FrappeTestCase):
class TestGSTInwardSupply(IntegrationTestCase):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestGSTReturnLog(FrappeTestCase):
class TestGSTReturnLog(IntegrationTestCase):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
import re

import frappe
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.tests import IntegrationTestCase, change_settings
from frappe.utils.data import getdate


class TestGSTSettings(FrappeTestCase):
class TestGSTSettings(IntegrationTestCase):
@classmethod
def setUpClass(cls):
# don't create test objects
frappe.local.test_objects["GST Settings"] = []

super().setUpClass()

@change_settings("GST Settings", {"enable_api": 1})
def test_api_key_enabled(self):
Expand Down
12 changes: 10 additions & 2 deletions india_compliance/gst_india/doctype/gstin/test_gstin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import responses
from responses import matchers

from frappe.tests.utils import FrappeTestCase, change_settings
import frappe
from frappe.tests import IntegrationTestCase, change_settings

from india_compliance.gst_india.doctype.gstin.gstin import validate_gst_transporter_id

Expand All @@ -24,7 +25,14 @@
}


class TestGSTIN(FrappeTestCase):
class TestGSTIN(IntegrationTestCase):
@classmethod
def setUpClass(cls):
# don't create test objects
frappe.local.test_objects["GSTIN"] = []

super().setUpClass()

@responses.activate
@change_settings("GST Settings", {"validate_gstin_status": 1, "sandbox_mode": 0})
def test_validate_gst_transporter_id(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestGSTR1Beta(FrappeTestCase):
class TestGSTR1Beta(IntegrationTestCase):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json

import frappe
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.tests import IntegrationTestCase, change_settings
from frappe.utils import getdate

from india_compliance.gst_india.utils.tests import (
Expand All @@ -13,7 +13,7 @@
)


class TestGSTR3BReport(FrappeTestCase):
class TestGSTR3BReport(IntegrationTestCase):
def setUp(self):
frappe.set_user("Administrator")
filters = {"company": "_Test Indian Registered Company"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestGSTRImportLog(FrappeTestCase):
class TestGSTRImportLog(IntegrationTestCase):
pass
4 changes: 2 additions & 2 deletions india_compliance/gst_india/doctype/pan/test_pan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestPAN(FrappeTestCase):
class TestPAN(IntegrationTestCase):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import datetime

import frappe
from frappe.test_runner import make_test_objects
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
from frappe.tests.utils import make_test_objects

from india_compliance.gst_india.doctype.bill_of_entry.bill_of_entry import (
make_bill_of_entry,
Expand Down Expand Up @@ -50,9 +50,12 @@
}


class TestPurchaseReconciliationTool(FrappeTestCase):
class TestPurchaseReconciliationTool(IntegrationTestCase):
@classmethod
def setUpClass(cls):
# don't create test objects
frappe.local.test_objects["Purchase Reconciliation Tool"] = []

super().setUpClass()

# create 2023-2024 fiscal year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from contextlib import contextmanager

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
from erpnext.accounts.doctype.payment_entry.payment_entry import (
get_outstanding_reference_documents,
)
Expand Down Expand Up @@ -47,7 +47,7 @@ def toggle_seperate_advance_accounting():
)


class TestAdvancePaymentEntry(FrappeTestCase):
class TestAdvancePaymentEntry(IntegrationTestCase):
EXPECTED_GL = [
{"account": "Cash - _TIRC", "debit": 590.0, "credit": 0.0},
{"account": "Debtors - _TIRC", "debit": 0.0, "credit": 500.0},
Expand Down
4 changes: 2 additions & 2 deletions india_compliance/gst_india/overrides/test_company.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase

from india_compliance.gst_india.overrides.company import get_tax_defaults


class TestCompanyFixtures(FrappeTestCase):
class TestCompanyFixtures(IntegrationTestCase):
@classmethod
def setUpClass(cls):
frappe.db.savepoint("before_test_company")
Expand Down
4 changes: 2 additions & 2 deletions india_compliance/gst_india/overrides/test_ineligible_itc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from contextlib import contextmanager

import frappe
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.tests import IntegrationTestCase, change_settings
from frappe.utils import today
from erpnext.controllers.sales_and_purchase_return import make_return_doc
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import (
Expand Down Expand Up @@ -101,7 +101,7 @@ def toggle_provisional_accounting():
)


class TestIneligibleITC(FrappeTestCase):
class TestIneligibleITC(IntegrationTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase

from india_compliance.gst_india.overrides.transaction import get_valid_accounts
from india_compliance.gst_india.utils import get_gst_accounts_by_type
Expand All @@ -10,7 +10,7 @@
# Validation of GST Rate


class TestTransaction(FrappeTestCase):
class TestTransaction(IntegrationTestCase):
def test_item_tax_template_for_foreign_company(self):
doc = create_item_tax_template(
company="_Test Foreign Company", gst_rate=0, gst_treatment="Exempt"
Expand Down
4 changes: 2 additions & 2 deletions india_compliance/gst_india/overrides/test_party.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestUtils(FrappeTestCase):
class TestUtils(IntegrationTestCase):
def test_validate_new_party(self):
party = frappe.new_doc(
"Customer", customer_name="Resilient Tech", gstin="24AUTPV8831F1ZZ"
Expand Down
4 changes: 2 additions & 2 deletions india_compliance/gst_india/overrides/test_purchase_invoice.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import frappe
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.tests import IntegrationTestCase, change_settings
from erpnext.accounts.doctype.account.test_account import create_account

from india_compliance.gst_india.utils.tests import append_item, create_purchase_invoice


class TestPurchaseInvoice(FrappeTestCase):
class TestPurchaseInvoice(IntegrationTestCase):
@change_settings("GST Settings", {"enable_overseas_transactions": 1})
def test_itc_classification(self):
pinv = create_purchase_invoice(
Expand Down
5 changes: 2 additions & 3 deletions india_compliance/gst_india/overrides/test_sales_invoice.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import unittest

import frappe
from frappe.tests import IntegrationTestCase

from india_compliance.gst_india.utils import validate_invoice_number


class TestSalesInvoice(unittest.TestCase):
class TestSalesInvoice(IntegrationTestCase):
def test_validate_invoice_number(self):
posting_date = "2021-05-01"

Expand Down
4 changes: 2 additions & 2 deletions india_compliance/gst_india/overrides/test_setup_wizard.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestSetupWizard(FrappeTestCase):
class TestSetupWizard(IntegrationTestCase):
def test_setup_wizard_with_valid_gstin(self):
setup_company = "Wind Power LLP"
company = frappe.get_doc("Company", setup_company)
Expand Down
Loading

0 comments on commit a113675

Please sign in to comment.