test: making naming tests re-runnable
These were modifying TODO schema ._. WAD
This commit is contained in:
parent
15dbcacd56
commit
ebcb568e9d
1 changed files with 11 additions and 26 deletions
|
|
@ -11,10 +11,11 @@ from frappe.model.naming import (
|
|||
getseries,
|
||||
revert_series_if_last,
|
||||
)
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
from frappe.utils import now_datetime
|
||||
|
||||
|
||||
class TestNaming(unittest.TestCase):
|
||||
class TestNaming(FrappeTestCase):
|
||||
def setUp(self):
|
||||
frappe.db.delete("Note")
|
||||
|
||||
|
|
@ -52,16 +53,13 @@ class TestNaming(unittest.TestCase):
|
|||
self.assertEqual(country.name, country.country_name)
|
||||
|
||||
def test_child_table_naming(self):
|
||||
child_dt_with_naming = new_doctype(
|
||||
"childtable_with_autonaming", istable=1, autoname="field:some_fieldname"
|
||||
).insert()
|
||||
child_dt_with_naming = new_doctype(istable=1, autoname="field:some_fieldname").insert()
|
||||
dt_with_child_autoname = new_doctype(
|
||||
"dt_with_childtable_naming",
|
||||
fields=[
|
||||
{
|
||||
"label": "table with naming",
|
||||
"fieldname": "table_with_naming",
|
||||
"options": "childtable_with_autonaming",
|
||||
"options": child_dt_with_naming.name,
|
||||
"fieldtype": "Table",
|
||||
}
|
||||
],
|
||||
|
|
@ -69,7 +67,7 @@ class TestNaming(unittest.TestCase):
|
|||
|
||||
name = frappe.generate_hash(length=10)
|
||||
|
||||
doc = frappe.new_doc("dt_with_childtable_naming")
|
||||
doc = frappe.new_doc(dt_with_child_autoname.name)
|
||||
doc.append("table_with_naming", {"some_fieldname": name})
|
||||
doc.save()
|
||||
self.assertEqual(doc.table_with_naming[0].name, name)
|
||||
|
|
@ -89,31 +87,18 @@ class TestNaming(unittest.TestCase):
|
|||
"""
|
||||
Test if braced params are replaced in format autoname
|
||||
"""
|
||||
doctype = "ToDo"
|
||||
|
||||
todo_doctype = frappe.get_doc("DocType", doctype)
|
||||
todo_doctype.autoname = "format:TODO-{MM}-{status}-{##}"
|
||||
todo_doctype.save()
|
||||
doctype = new_doctype(autoname="format:TODO-{MM}-{some_fieldname}-{##}").insert()
|
||||
|
||||
description = "Format"
|
||||
|
||||
todo = frappe.new_doc(doctype)
|
||||
todo.description = description
|
||||
todo.insert()
|
||||
doc = frappe.new_doc(doctype.name)
|
||||
doc.some_fieldname = description
|
||||
doc.insert()
|
||||
|
||||
series = getseries("", 2)
|
||||
series = int(series) - 1
|
||||
|
||||
series = str(int(series) - 1)
|
||||
|
||||
if len(series) < 2:
|
||||
series = "0" + series
|
||||
|
||||
self.assertEqual(
|
||||
todo.name,
|
||||
"TODO-{month}-{status}-{series}".format(
|
||||
month=now_datetime().strftime("%m"), status=todo.status, series=series
|
||||
),
|
||||
)
|
||||
self.assertEqual(doc.name, f"TODO-{now_datetime().strftime('%m')}-{description}-{series:02}")
|
||||
|
||||
def test_format_autoname_for_consecutive_week_number(self):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue