예제 #1
0
    def get_route_context(self):
        route = frappe._dict()
        route.update({
            "doc":
            self,
            "page_or_generator":
            "Generator",
            "ref_doctype":
            self.doctype,
            "idx":
            self.idx,
            "docname":
            self.name,
            "page_name":
            self.get_page_name(),
            "controller":
            get_module_name(self.doctype, self.meta.module),
        })

        route.update(self.website)

        if not route.page_title:
            route.page_title = self.get(self.website.page_title_field
                                        or "name")

        return route
예제 #2
0
def run_tests_for_doctype(doctypes,
                          verbose=False,
                          tests=(),
                          force=False,
                          profile=False):
    modules = []
    if not isinstance(doctypes, (list, tuple)):
        doctypes = [doctypes]

    for doctype in doctypes:
        module = frappe.db.get_value("DocType", doctype, "module")
        if not module:
            print('Invalid doctype {0}'.format(doctype))
            sys.exit(1)

        test_module = get_module_name(doctype, module, "test_")
        if force:
            for name in frappe.db.sql_list("select name from `tab%s`" %
                                           doctype):
                frappe.delete_doc(doctype, name, force=True)
        make_test_records(doctype, verbose=verbose, force=force)
        modules.append(importlib.import_module(test_module))

    return _run_unittest(modules,
                         verbose=verbose,
                         tests=tests,
                         profile=profile)
예제 #3
0
    def insert_route(self):
        if self.modified:
            # for sitemap.xml
            lastmod = frappe.utils.get_datetime(
                self.modified).strftime("%Y-%m-%d")
        else:
            lastmod = now()

        route = frappe.new_doc("Website Route")
        route.update({
            "page_or_generator":
            "Generator",
            "ref_doctype":
            self.doctype,
            "idx":
            self.idx,
            "docname":
            self.name,
            "page_name":
            self.get_page_name(),
            "controller":
            get_module_name(self.doctype, self.meta.module),
            "lastmod":
            lastmod,
            "parent_website_route":
            self.get_parent_website_route(),
            "page_title":
            self.get_page_title()
        })

        self.update_permissions(route)
        route.ignore_links = True
        route.insert(ignore_permissions=True)
예제 #4
0
    def get_website_route(self):
        route = frappe._dict()
        route.update({
            "doc":
            self,
            "page_or_generator":
            "Generator",
            "ref_doctype":
            self.doctype,
            "idx":
            self.idx,
            "docname":
            self.name,
            "page_name":
            self.get_page_name(),
            "controller":
            get_module_name(self.doctype, self.meta.module),
            "template":
            self.template,
            "parent_website_route":
            self.get("parent_website_route", ""),
            "page_title":
            getattr(self, "page_title", None)
            or self.get(self.page_title_field)
        })

        self.update_permissions(route)

        return route
예제 #5
0
def run_tests_for_doctype(doctype, verbose=False, tests=(), force=False):
    module = frappe.db.get_value("DocType", doctype, "module")
    test_module = get_module_name(doctype, module, "test_")
    if force:
        for name in frappe.db.sql_list("select name from `tab%s`" % doctype):
            frappe.delete_doc(doctype, name, force=True)
    make_test_records(doctype, verbose=verbose, force=force)
    module = frappe.get_module(test_module)
    return _run_unittest(module, verbose=verbose, tests=tests)
예제 #6
0
def run_tests_for_doctype(doctype, verbose=False, tests=(), force=False):
	module = frappe.db.get_value("DocType", doctype, "module")
	test_module = get_module_name(doctype, module, "test_")
	if force:
		for name in frappe.db.sql_list("select name from `tab%s`" % doctype):
			frappe.delete_doc(doctype, name, force=True)
	make_test_records(doctype, verbose=verbose, force=force)
	module = frappe.get_module(test_module)
	return _run_unittest(module, verbose=verbose, tests=tests)
예제 #7
0
def run_tests_for_doctype(doctype, verbose=False, tests=(), force=False, profile=False):
	module = frappe.db.get_value("DocType", doctype, "module")
	if not module:
		print 'Invalid doctype {0}'.format(doctype)
		sys.exit(1)

	test_module = get_module_name(doctype, module, "test_")
	if force:
		for name in frappe.db.sql_list("select name from `tab%s`" % doctype):
			frappe.delete_doc(doctype, name, force=True)
	make_test_records(doctype, verbose=verbose, force=force)
	module = frappe.get_module(test_module)
	return _run_unittest(module, verbose=verbose, tests=tests, profile=profile)
예제 #8
0
def run_tests_for_doctype(doctype,
                          verbose=False,
                          tests=(),
                          force=False,
                          profile=False):
    module = frappe.db.get_value("DocType", doctype, "module")
    if not module:
        print 'Invalid doctype {0}'.format(doctype)
        sys.exit(1)

    test_module = get_module_name(doctype, module, "test_")
    if force:
        for name in frappe.db.sql_list("select name from `tab%s`" % doctype):
            frappe.delete_doc(doctype, name, force=True)
    make_test_records(doctype, verbose=verbose, force=force)
    module = frappe.get_module(test_module)
    return _run_unittest(module, verbose=verbose, tests=tests, profile=profile)
예제 #9
0
	def get_page_info(self):
		route = frappe._dict()
		route.update({
			"doc": self,
			"page_or_generator": "Generator",
			"ref_doctype":self.doctype,
			"idx": self.idx,
			"docname": self.name,
			"controller": get_module_name(self.doctype, self.meta.module),
		})

		route.update(self.get_website_properties())

		if not route.page_title:
			route.page_title = self.get(self.get_title_field())

		return route
예제 #10
0
	def get_website_route(self):
		route = frappe._dict()
		route.update({
			"doc": self,
			"page_or_generator": "Generator",
			"ref_doctype":self.doctype,
			"idx": self.idx,
			"docname": self.name,
			"page_name": self.get_page_name(),
			"controller": get_module_name(self.doctype, self.meta.module),
			"template": self.template,
			"parent_website_route": self.get("parent_website_route", ""),
			"page_title": self.get(self.page_title_field)
		})

		self.update_permissions(route)

		return route
예제 #11
0
def run_tests_for_doctype(doctypes, verbose=False, tests=(), force=False, profile=False):
	modules = []
	if not isinstance(doctypes, (list, tuple)):
		doctypes = [doctypes]

	for doctype in doctypes:
		module = frappe.db.get_value("DocType", doctype, "module")
		if not module:
			print('Invalid doctype {0}'.format(doctype))
			sys.exit(1)

		test_module = get_module_name(doctype, module, "test_")
		if force:
			for name in frappe.db.sql_list("select name from `tab%s`" % doctype):
				frappe.delete_doc(doctype, name, force=True)
		make_test_records(doctype, verbose=verbose, force=force)
		modules.append(importlib.import_module(test_module))

	return _run_unittest(modules, verbose=verbose, tests=tests, profile=profile)
예제 #12
0
def run_tests_for_doctype(doctype, verbose=False, tests=()):
	module = frappe.db.get_value("DocType", doctype, "module")
	test_module = get_module_name(doctype, module, "test_")
	make_test_records(doctype, verbose=verbose)
	module = frappe.get_module(test_module)
	return _run_unittest(module, verbose=verbose, tests=tests)
예제 #13
0
def run_tests_for_doctype(doctype, verbose=False, tests=()):
	module = frappe.db.get_value("DocType", doctype, "module")
	test_module = get_module_name(doctype, module, "test_")
	make_test_records(doctype, verbose=verbose)
	module = frappe.get_module(test_module)
	return _run_unittest(module, verbose=verbose, tests=tests)