├── .gitignore ├── MANIFEST.in ├── README.md ├── barista ├── __init__.py ├── barista │ ├── __init__.py │ ├── doctype │ │ ├── __init__.py │ │ ├── assertion │ │ │ ├── __init__.py │ │ │ ├── assertion.json │ │ │ └── assertion.py │ │ ├── assertion_result │ │ │ ├── __init__.py │ │ │ ├── assertion_result.json │ │ │ └── assertion_result.py │ │ ├── function_parameter │ │ │ ├── __init__.py │ │ │ ├── function_parameter.json │ │ │ └── function_parameter.py │ │ ├── test_case │ │ │ ├── __init__.py │ │ │ ├── test_case.js │ │ │ ├── test_case.json │ │ │ ├── test_case.py │ │ │ ├── test_case_dashboard.py │ │ │ ├── test_case_execution.py │ │ │ ├── test_test_case.js │ │ │ └── test_test_case.py │ │ ├── test_data │ │ │ ├── __init__.py │ │ │ ├── test_data.js │ │ │ ├── test_data.json │ │ │ ├── test_data.py │ │ │ ├── test_data_dashboard.py │ │ │ ├── test_data_generator.py │ │ │ ├── test_test_data.js │ │ │ └── test_test_data.py │ │ ├── test_result │ │ │ ├── __init__.py │ │ │ ├── test_result.js │ │ │ ├── test_result.json │ │ │ ├── test_result.py │ │ │ ├── test_test_result.js │ │ │ └── test_test_result.py │ │ ├── test_run_log │ │ │ ├── __init__.py │ │ │ ├── test_run_log.js │ │ │ ├── test_run_log.json │ │ │ ├── test_run_log.py │ │ │ ├── test_run_log_dashboard.py │ │ │ ├── test_test_run_log.js │ │ │ └── test_test_run_log.py │ │ ├── test_suite │ │ │ ├── __init__.py │ │ │ ├── run_test.py │ │ │ ├── test_suite.js │ │ │ ├── test_suite.json │ │ │ ├── test_suite.py │ │ │ ├── test_suite_dashboard.py │ │ │ ├── test_test_suite.js │ │ │ └── test_test_suite.py │ │ ├── testcase_item │ │ │ ├── __init__.py │ │ │ ├── test_testcase_item.js │ │ │ ├── test_testcase_item.py │ │ │ ├── testcase_item.js │ │ │ ├── testcase_item.json │ │ │ └── testcase_item.py │ │ ├── testdata_item │ │ │ ├── __init__.py │ │ │ ├── test_testdata_item.js │ │ │ ├── test_testdata_item.py │ │ │ ├── testdata_item.js │ │ │ ├── testdata_item.json │ │ │ └── testdata_item.py │ │ └── testdatafield │ │ │ ├── __init__.py │ │ │ ├── test_testdatafield.js │ │ │ ├── test_testdatafield.py │ │ │ ├── testdatafield.js │ │ │ ├── testdatafield.json │ │ │ └── testdatafield.py │ ├── page │ │ ├── __init__.py │ │ └── test_coverage │ │ │ ├── __init__.py │ │ │ ├── test_coverage.js │ │ │ └── test_coverage.json │ └── report │ │ ├── __init__.py │ │ ├── assertion_effectiveness │ │ ├── __init__.py │ │ └── assertion_effectiveness.json │ │ ├── assertion_type_wise_test_cases │ │ ├── __init__.py │ │ └── assertion_type_wise_test_cases.json │ │ ├── error_statistics │ │ ├── __init__.py │ │ └── error_statistics.json │ │ ├── test_execution_statistics │ │ ├── __init__.py │ │ └── test_execution_statistics.json │ │ ├── test_run_log_test_data_statistics │ │ ├── __init__.py │ │ └── test_run_log_test_data_statistics.json │ │ └── types_of_test_case_on_doctype │ │ ├── __init__.py │ │ └── types_of_test_case_on_doctype.json ├── commands.py ├── config │ ├── __init__.py │ ├── barista.py │ ├── desktop.py │ └── docs.py ├── hooks.py ├── modules.txt ├── patches.txt ├── public │ └── sample-file.html └── templates │ ├── __init__.py │ └── pages │ └── __init__.py ├── examples ├── Create User John Doe │ ├── test_case.json │ ├── test_data.json │ └── test_suite.json └── README.md ├── images ├── dashboard.png ├── sample-manual-testcase.png ├── tc.gif ├── td.gif └── test-result.gif ├── license.txt ├── requirements.txt └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.egg-info 4 | *.swp 5 | tags 6 | barista/docs/current 7 | barista/public/test-coverage/ 8 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include requirements.txt 3 | include *.json 4 | include *.md 5 | include *.py 6 | include *.txt 7 | recursive-include barista *.css 8 | recursive-include barista *.csv 9 | recursive-include barista *.html 10 | recursive-include barista *.ico 11 | recursive-include barista *.js 12 | recursive-include barista *.json 13 | recursive-include barista *.md 14 | recursive-include barista *.png 15 | recursive-include barista *.py 16 | recursive-include barista *.svg 17 | recursive-include barista *.txt 18 | recursive-exclude barista *.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | While developing an application using a framework like Frappe which adds most of the required paraphernalia automatically the developer is mainly required to code the business logic. And hence making functional testing one of the most important aspects. 2 | 3 | 4 | We have developed a frappe application, named BARISTA, which automates testing of server-side code for all our frappe apps. 5 | 6 | 7 | 8 |

Overview

9 | 10 | 11 | 12 | A simple manual test would require a test suite, usually a spreadsheet, on which the tester adds test cases. Each test case defines: 13 | 14 | * Test case Name and description 15 | 16 | * Test case Steps – Each test case would layout detailed steps to create the test data with field values and required action to test. 17 | 18 | * Expected result - Based on the field values, expected result is specified for the tester to validate. 19 | 20 | * Actual result - Following the steps the tester runs the test case and publishes the actual test result. 21 | 22 | * Finally the test case is passed or failed based on actual results. 23 | ![Manual testing sample](/images/sample-manual-testcase.png) 24 | 25 | 26 | Similarly in Barista there are four doctypes: 27 | 28 | * **Test Suite** – declare a test suite here and select the set of test cases to run under that suite. One or more test suites can be executed based on the test scope. 29 | 30 | * **Test Data** – declare the application doctype here and required field values. Barista will create the record using values mentioned here while executing the test case. It also lets you select option to generate random value for the field. 31 | 32 | * **Test Case** – Select the test data, specify the action to be triggerred like save, workflow change etc. and define assertions here like validate value of a field which is expected to change or expected error message etc. 33 | 34 | * **Test Result** – Barista executes the test cases in a suite and publishes the result of each test case. Whether a test case passed or failed and what is the actual result for defect analysis. 35 | 36 | ![Dashboard](/images/dashboard.png) 37 | 38 | 39 |

How it works

40 | 41 | 42 | 43 | Barista is installed on the same bench where the application to be tested is installed. This gives it access to the metadata of the application and its methods. While execution, it first creates the test record using values provided on test data and saves document name for further execution and assertion validation. It then triggers the action on the test data using respective frappe methods like save(). Finally, fetches all assertions (child table in Test case) of the test case and validates with the actual record. 44 | 45 | 46 | 47 | **Create test data** 48 | 49 | 50 | Simply select the doctype on which the test case has to execute. Declare required field values which will be used to create the record/document while executing the test case. 51 | 52 | 53 | ![test-data](/images/td.gif) 54 | 55 | 56 | **Create test case** 57 | 58 | 59 | 60 | Test case creation has three steps: 61 | 62 | 63 | 64 | * Select the action like create a document or update or change workflow state etc. 65 | 66 | * Select the test data on which the above action will be triggered. 67 | 68 | * Declare assertions to validate. When test cases are executed each assertion is validated and if any assertion fails, Barista marks test case status as failed with the details of the actual result found. Assertions can validate field value of a doctype, validate a record, validate workflow state, validate error and error message or validate response of a method. 69 | 70 | **Create test case** 71 | 72 | 73 | 74 | Test case creation has three steps: 75 | 76 | 77 | 78 | * Select the action like create a document or update or change workflow state etc. 79 | 80 | * Select the test data on which the above action will be triggered. 81 | 82 | * Declare assertions to validate. When test cases are executed each assertion is validated and if any assertion fails, Barista marks test case status as failed with the details of the actual result found. Assertions can validate field value of a doctype, validate a record, validate workflow state, validate error and error message or validate response of a method. 83 | 84 | ![test-result](/images/tc.gif) 85 | 86 | **Execute and view the results** 87 | 88 | 89 | Barista executes all test cases and saves the test results for further analysis. 90 | 91 | **Execute and view the results** 92 | 93 | 94 | Barista executes all test cases and saves the test results for further analysis. 95 | 96 | ![test-result](/images/test-result.gif) 97 | 98 |

Test Effectiveness

99 | 100 | 101 | 102 | **Overall Code Coverage** 103 | 104 | 105 | 106 | Barista uses Coverage.py to track the coverage while test execution and publishes the detailed report which can be used to ensure test effectiveness. Higher the coverage higher is the effectiveness of the test. 107 | 108 | 109 | **Incremental code coverage** 110 | 111 | 112 | 113 | Code coverage of the new change which is going to be released is important information to verify. To achieve this we are integrating with repositories like Gitlab from where we can get details of the change in a merge request and cross verify it with the test code coverage. This can ensure the change which is getting released has been tested and is part of the test cases. 114 | 115 | 116 | 117 | 118 | **Overall Code Coverage** 119 | 120 | 121 | 122 | Barista uses Coverage.py to track the coverage while test execution and publishes the detailed report which can be used to ensure test effectiveness. Higher the coverage higher is the effectiveness of the test. 123 | 124 | 125 | **Incremental code coverage** 126 | 127 | 128 | 129 | Code coverage of the new change which is going to be released is important information to verify. To achieve this we are integrating with repositories like Gitlab from where we can get details of the change in a merge request and cross verify it with the test code coverage. This can ensure the change which is getting released has been tested and is part of the test cases. 130 | 131 | 132 | -------------------------------------------------------------------------------- /barista/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | import time 4 | import sys 5 | import frappe 6 | from barista.barista.doctype.test_suite.run_test import RunTest, resolve_run_name 7 | 8 | 9 | __version__ = '0.0.1' 10 | 11 | 12 | def run(app_name, suites=[], reset_testdata=False, clear_testresult=False, run_name='Pass-1'): 13 | # sys.stdout = open('barista_log.txt', 'w') 14 | # bench execute barista.run --kwargs "{'app_name':'velocityduos','suites':[],'reset_testdata':0,'clear_testresult':0,'run_name':'Release 1'}" 15 | # bench execute barista.run --kwargs "{'app_name':'velocityduos'}" 16 | 17 | if reset_testdata and bool(reset_testdata): 18 | reset_test_data(suites, clear_testresult) 19 | 20 | run_name = resolve_run_name(run_name) 21 | print('Test Run Name >>> ', run_name) 22 | RunTest().run_complete_suite(app_name, suites, run_name) 23 | 24 | # sys.stdout.close() 25 | 26 | 27 | ''' 28 | def resolve_run_name1(run_name): 29 | if run_name and run_name.strip() != '': 30 | 31 | run_name_parts1 = run_name.split('-') 32 | if len(run_name_parts1): 33 | existing_run_name = frappe.db.sql_list(f""" 34 | SELECT max(test_run_name) 35 | FROM 36 | ( 37 | SELECT max(test_run_name) as 'test_run_name' 38 | FROM `tabTest Run Log` 39 | WHERE test_run_name LIKE '%{run_name_parts1[0]}%' 40 | UNION ALL 41 | SELECT max(test_run_name) AS 'test_run_name' 42 | FROM `tabTest Result` 43 | WHERE test_run_name LIKE '%{run_name_parts1[0]}%' 44 | ) st 45 | """) 46 | if len(existing_run_name): 47 | if existing_run_name[0]: 48 | existing_run_name = existing_run_name[0] 49 | run_name_parts = existing_run_name.split('-') 50 | run_name = f'{run_name_parts1[0]}-{safe_cast(run_name_parts.pop(),int,0)+1}' 51 | 52 | run_name_parts2 = run_name.split(' ') 53 | if len(run_name_parts2): 54 | existing_run_name = frappe.db.sql_list(f""" 55 | SELECT max(test_run_name) 56 | FROM 57 | ( 58 | SELECT max(test_run_name) as 'test_run_name' 59 | FROM `tabTest Run Log` 60 | WHERE test_run_name LIKE '%{run_name_parts2[0]}%' 61 | UNION ALL 62 | SELECT max(test_run_name) AS 'test_run_name' 63 | FROM `tabTest Result` 64 | WHERE test_run_name LIKE '%{run_name_parts2[0]}%' ) st 65 | """) 66 | if len(existing_run_name): 67 | if existing_run_name[0]: 68 | existing_run_name = existing_run_name[0] 69 | run_name_parts = existing_run_name.split(' ') 70 | run_name = f'{run_name_parts2[0]} {safe_cast(run_name_parts.pop(),int,0)+1}' 71 | else: 72 | # if run_name is not provided use default run_name as Run 1 73 | existing_run_name = frappe.db.sql_list(""" 74 | SELECT max(test_run_name) 75 | FROM 76 | (SELECT max(test_run_name) AS 'test_run_name' 77 | FROM `tabTest Run Log` 78 | # WHERE test_run_name LIKE '%Run%' 79 | UNION ALL 80 | SELECT max(test_run_name) AS 'test_run_name' 81 | FROM `tabTest Result` 82 | # WHERE test_run_name LIKE '%Run%' 83 | ) st 84 | """) 85 | if len(existing_run_name): 86 | if existing_run_name[0]: 87 | existing_run_name = existing_run_name[0] 88 | run_name_parts = existing_run_name.split(' ') 89 | run_name = f'Run {safe_cast(run_name_parts.pop(),int,0)+1}' 90 | else: 91 | run_name = 'Run 1' 92 | 93 | return run_name 94 | ''' 95 | 96 | 97 | def reset_test_data(suites=[], clear_testresult=False): 98 | # bench execute barista.reset_test_data --kwargs "{'suites':[]}" 99 | 100 | if len(suites) == 0: 101 | test_data_lst = frappe.db.sql_list(""" 102 | SELECT td.name 103 | FROM `tabTest Data` td 104 | WHERE td.status='CREATED' or td.test_record_name is not NULL 105 | """) 106 | clear_test_data(test_data_lst) 107 | else: 108 | for suite in suites: 109 | test_data_lst = frappe.db.sql_list(""" 110 | SELECT ti.test_data 111 | FROM `tabTestdata Item` ti 112 | INNER JOIN `tabTest Suite` ts ON ts.name=ti.parent 113 | INNER JOIN `tabTest Data` td ON td.name=ti.test_data 114 | WHERE (td.status='CREATED' or td.test_record_name is not NULL) 115 | AND ts.name=%(suite)s 116 | UNION 117 | select td.name as 'test_data' from `tabTest Data` td inner join `tabTest Case` tc on td.name=tc.test_data inner join `tabTestcase Item` ti on ti.testcase=tc.name inner join `tabTest Suite` ts on ts.name=ti.parent where (td.status='CREATED' or td.test_record_name is not NULL) 118 | AND ts.name=%(suite)s 119 | """, {'suite': suite}) 120 | clear_test_data(test_data_lst, suite) 121 | 122 | if clear_testresult and bool(clear_testresult): 123 | clear_test_result() 124 | 125 | 126 | def clear_test_result(): 127 | print('Clearing Test Result...') 128 | frappe.db.sql('''TRUNCATE `tabTest Result`''', auto_commit=1) 129 | 130 | 131 | def clear_test_data(test_data_lst, suite=None): 132 | total = len(test_data_lst) 133 | i = 0 134 | 135 | if suite: 136 | print(f'Resetting Test Data for this Test Suite ---> {suite}') 137 | 138 | # if total != 0: 139 | # printProgressBar(0, total, prefix='Progress:', 140 | # suffix='Complete') 141 | # else: 142 | # printProgressBar(total+1, total, prefix='Progress:', 143 | # suffix='Complete') 144 | 145 | for test_data in test_data_lst: 146 | 147 | time.sleep(0.1) 148 | 149 | doctype = frappe.db.get_value('Test Data', test_data, 'doctype_name') 150 | is_single = frappe.db.get_value('DocType', doctype, 'issingle') 151 | 152 | record = frappe.db.get_value( 153 | 'Test Data', test_data, 'test_record_name') 154 | 155 | if is_single == 0: 156 | frappe.db.sql( 157 | f""" 158 | DELETE 159 | FROM `tab{doctype}` 160 | WHERE name='{record}' 161 | """, debug=1, auto_commit=1) 162 | 163 | frappe.db.set_value('Test Data', test_data, 'status', 'PENDING') 164 | frappe.db.set_value('Test Data', test_data, 'test_record_name', None) 165 | 166 | # printProgressBar(i + 1, total, prefix='Progress:', 167 | # suffix='Complete') 168 | 169 | frappe.db.commit() 170 | 171 | 172 | def ping(): 173 | # bench execute barista.ping 174 | 175 | total = 10 176 | 177 | # Initial call to print 0% progress 178 | printProgressBar(0, total, prefix='Progress:', 179 | suffix='Complete') 180 | for i in range(total): 181 | # Do stuff... 182 | time.sleep(0.1) 183 | # Update Progress Bar 184 | printProgressBar(i + 1, total, prefix='Progress:', 185 | suffix='Complete') 186 | 187 | 188 | def printProgressBar(iteration, total, prefix='', suffix='', decimals=1, length=50, fill='█', printEnd="\r"): 189 | # Print iterations progress 190 | """ 191 | Call in a loop to create terminal progress bar 192 | @params: 193 | iteration - Required : current iteration (Int) 194 | total - Required : total iterations (Int) 195 | prefix - Optional : prefix string (Str) 196 | suffix - Optional : suffix string (Str) 197 | decimals - Optional : positive number of decimals in percent complete (Int) 198 | length - Optional : character length of bar (Int) 199 | fill - Optional : bar fill character (Str) 200 | printEnd - Optional : end character (e.g. "\r", "\r\n") (Str) 201 | """ 202 | if total == 0: 203 | total = 1 204 | 205 | step = int(100 * (iteration / int(total))) 206 | filledLength = int(length * iteration // total) 207 | bar = fill * filledLength + '-' * (length - filledLength) 208 | 209 | print(f'''\r{prefix} |{bar}| {step}% {suffix}''', end=printEnd) 210 | # Print New Line on Complete 211 | if iteration == total: 212 | print() 213 | 214 | 215 | def get_commands(): 216 | from .commands import commands as barista_commands 217 | 218 | return list(barista_commands) 219 | 220 | 221 | commands = get_commands() 222 | -------------------------------------------------------------------------------- /barista/barista/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/assertion/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/assertion/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/assertion/assertion.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 0, 7 | "autoname": "", 8 | "beta": 0, 9 | "creation": "2019-12-17 17:39:44.639480", 10 | "custom": 0, 11 | "docstatus": 0, 12 | "doctype": "DocType", 13 | "document_type": "", 14 | "editable_grid": 0, 15 | "engine": "InnoDB", 16 | "fields": [ 17 | { 18 | "allow_bulk_edit": 0, 19 | "allow_in_quick_entry": 0, 20 | "allow_on_submit": 0, 21 | "bold": 0, 22 | "collapsible": 0, 23 | "columns": 0, 24 | "fetch_if_empty": 0, 25 | "fieldname": "assertion_type", 26 | "fieldtype": "Select", 27 | "hidden": 0, 28 | "ignore_user_permissions": 0, 29 | "ignore_xss_filter": 0, 30 | "in_filter": 0, 31 | "in_global_search": 0, 32 | "in_list_view": 1, 33 | "in_standard_filter": 0, 34 | "label": "Assertion Type", 35 | "length": 0, 36 | "no_copy": 0, 37 | "options": "Field Value\nRecord Validation\nWorkflow\nResponse\nError", 38 | "permlevel": 0, 39 | "precision": "", 40 | "print_hide": 0, 41 | "print_hide_if_no_value": 0, 42 | "read_only": 0, 43 | "remember_last_selected_value": 0, 44 | "report_hide": 0, 45 | "reqd": 0, 46 | "search_index": 0, 47 | "set_only_once": 0, 48 | "translatable": 0, 49 | "unique": 0 50 | }, 51 | { 52 | "allow_bulk_edit": 0, 53 | "allow_in_quick_entry": 0, 54 | "allow_on_submit": 0, 55 | "bold": 0, 56 | "collapsible": 0, 57 | "columns": 0, 58 | "default": "", 59 | "depends_on": "eval:(doc.assertion_type != \"RESPONSE\" || doc.assertion_type != \"ERROR\")", 60 | "fetch_from": "doctype_name.module", 61 | "fetch_if_empty": 1, 62 | "fieldname": "module", 63 | "fieldtype": "Link", 64 | "hidden": 0, 65 | "ignore_user_permissions": 0, 66 | "ignore_xss_filter": 0, 67 | "in_filter": 0, 68 | "in_global_search": 0, 69 | "in_list_view": 0, 70 | "in_standard_filter": 0, 71 | "label": "Module", 72 | "length": 0, 73 | "no_copy": 0, 74 | "options": "Module Def", 75 | "permlevel": 0, 76 | "precision": "", 77 | "print_hide": 0, 78 | "print_hide_if_no_value": 0, 79 | "read_only": 1, 80 | "remember_last_selected_value": 0, 81 | "report_hide": 0, 82 | "reqd": 0, 83 | "search_index": 0, 84 | "set_only_once": 0, 85 | "translatable": 0, 86 | "unique": 0 87 | }, 88 | { 89 | "allow_bulk_edit": 0, 90 | "allow_in_quick_entry": 0, 91 | "allow_on_submit": 0, 92 | "bold": 0, 93 | "collapsible": 0, 94 | "columns": 0, 95 | "depends_on": "eval:(doc.assertion_type != \"RESPONSE\" || doc.assertion_type != \"ERROR\")", 96 | "fetch_if_empty": 0, 97 | "fieldname": "doctype_name", 98 | "fieldtype": "Link", 99 | "hidden": 0, 100 | "ignore_user_permissions": 0, 101 | "ignore_xss_filter": 0, 102 | "in_filter": 0, 103 | "in_global_search": 0, 104 | "in_list_view": 1, 105 | "in_standard_filter": 0, 106 | "label": "Doctype Name", 107 | "length": 0, 108 | "no_copy": 0, 109 | "options": "DocType", 110 | "permlevel": 0, 111 | "precision": "", 112 | "print_hide": 0, 113 | "print_hide_if_no_value": 0, 114 | "read_only": 0, 115 | "remember_last_selected_value": 0, 116 | "report_hide": 0, 117 | "reqd": 0, 118 | "search_index": 0, 119 | "set_only_once": 0, 120 | "translatable": 0, 121 | "unique": 0 122 | }, 123 | { 124 | "allow_bulk_edit": 0, 125 | "allow_in_quick_entry": 0, 126 | "allow_on_submit": 0, 127 | "bold": 0, 128 | "collapsible": 0, 129 | "columns": 0, 130 | "fetch_if_empty": 0, 131 | "fieldname": "column_break_11", 132 | "fieldtype": "Column Break", 133 | "hidden": 0, 134 | "ignore_user_permissions": 0, 135 | "ignore_xss_filter": 0, 136 | "in_filter": 0, 137 | "in_global_search": 0, 138 | "in_list_view": 0, 139 | "in_standard_filter": 0, 140 | "length": 0, 141 | "no_copy": 0, 142 | "permlevel": 0, 143 | "precision": "", 144 | "print_hide": 0, 145 | "print_hide_if_no_value": 0, 146 | "read_only": 0, 147 | "remember_last_selected_value": 0, 148 | "report_hide": 0, 149 | "reqd": 0, 150 | "search_index": 0, 151 | "set_only_once": 0, 152 | "translatable": 0, 153 | "unique": 0 154 | }, 155 | { 156 | "allow_bulk_edit": 0, 157 | "allow_in_quick_entry": 0, 158 | "allow_on_submit": 0, 159 | "bold": 0, 160 | "collapsible": 0, 161 | "columns": 0, 162 | "depends_on": "eval:(doc.assertion_type != \"Response\" || doc.assertion_type != \"Error\")", 163 | "fetch_if_empty": 0, 164 | "fieldname": "reference_field", 165 | "fieldtype": "Select", 166 | "hidden": 0, 167 | "ignore_user_permissions": 0, 168 | "ignore_xss_filter": 0, 169 | "in_filter": 0, 170 | "in_global_search": 0, 171 | "in_list_view": 1, 172 | "in_standard_filter": 0, 173 | "label": "Reference Field", 174 | "length": 0, 175 | "no_copy": 0, 176 | "permlevel": 0, 177 | "precision": "", 178 | "print_hide": 0, 179 | "print_hide_if_no_value": 0, 180 | "read_only": 0, 181 | "remember_last_selected_value": 0, 182 | "report_hide": 0, 183 | "reqd": 0, 184 | "search_index": 0, 185 | "set_only_once": 0, 186 | "translatable": 0, 187 | "unique": 0 188 | }, 189 | { 190 | "allow_bulk_edit": 0, 191 | "allow_in_quick_entry": 0, 192 | "allow_on_submit": 0, 193 | "bold": 0, 194 | "collapsible": 0, 195 | "columns": 0, 196 | "depends_on": "eval:(doc.assertion_type == \"Field Value\" || doc.assertion_type == \"Record Validation\")", 197 | "fetch_if_empty": 0, 198 | "fieldname": "docfield_name", 199 | "fieldtype": "Data", 200 | "hidden": 0, 201 | "ignore_user_permissions": 0, 202 | "ignore_xss_filter": 0, 203 | "in_filter": 0, 204 | "in_global_search": 0, 205 | "in_list_view": 1, 206 | "in_standard_filter": 0, 207 | "label": "Docfield Name", 208 | "length": 0, 209 | "no_copy": 0, 210 | "options": "", 211 | "permlevel": 0, 212 | "precision": "", 213 | "print_hide": 0, 214 | "print_hide_if_no_value": 0, 215 | "read_only": 0, 216 | "remember_last_selected_value": 0, 217 | "report_hide": 0, 218 | "reqd": 0, 219 | "search_index": 0, 220 | "set_only_once": 0, 221 | "translatable": 0, 222 | "unique": 0 223 | }, 224 | { 225 | "allow_bulk_edit": 0, 226 | "allow_in_quick_entry": 0, 227 | "allow_on_submit": 0, 228 | "bold": 0, 229 | "collapsible": 0, 230 | "columns": 0, 231 | "depends_on": "eval:(doc.assertion_type == \"Error\")", 232 | "fetch_if_empty": 0, 233 | "fieldname": "error_message", 234 | "fieldtype": "Data", 235 | "hidden": 0, 236 | "ignore_user_permissions": 0, 237 | "ignore_xss_filter": 0, 238 | "in_filter": 0, 239 | "in_global_search": 0, 240 | "in_list_view": 0, 241 | "in_standard_filter": 0, 242 | "label": "Error Message", 243 | "length": 0, 244 | "no_copy": 0, 245 | "permlevel": 0, 246 | "precision": "", 247 | "print_hide": 0, 248 | "print_hide_if_no_value": 0, 249 | "read_only": 0, 250 | "remember_last_selected_value": 0, 251 | "report_hide": 0, 252 | "reqd": 0, 253 | "search_index": 0, 254 | "set_only_once": 0, 255 | "translatable": 0, 256 | "unique": 0 257 | }, 258 | { 259 | "allow_bulk_edit": 0, 260 | "allow_in_quick_entry": 0, 261 | "allow_on_submit": 0, 262 | "bold": 0, 263 | "collapsible": 0, 264 | "columns": 0, 265 | "default": "Fixed Value", 266 | "depends_on": "eval:(doc.assertion_type==='Field Value' || doc.assertion_type==='Response' )", 267 | "fetch_if_empty": 0, 268 | "fieldname": "value_type", 269 | "fieldtype": "Select", 270 | "hidden": 0, 271 | "ignore_user_permissions": 0, 272 | "ignore_xss_filter": 0, 273 | "in_filter": 0, 274 | "in_global_search": 0, 275 | "in_list_view": 0, 276 | "in_standard_filter": 0, 277 | "label": "Value Type", 278 | "length": 0, 279 | "no_copy": 0, 280 | "options": "Fixed Value\nCode", 281 | "permlevel": 0, 282 | "precision": "", 283 | "print_hide": 0, 284 | "print_hide_if_no_value": 0, 285 | "read_only": 0, 286 | "remember_last_selected_value": 0, 287 | "report_hide": 0, 288 | "reqd": 0, 289 | "search_index": 0, 290 | "set_only_once": 0, 291 | "translatable": 0, 292 | "unique": 0 293 | }, 294 | { 295 | "allow_bulk_edit": 0, 296 | "allow_in_quick_entry": 0, 297 | "allow_on_submit": 0, 298 | "bold": 0, 299 | "collapsible": 0, 300 | "columns": 0, 301 | "depends_on": "eval:(doc.assertion_type == \"Response\" && doc.value_type=='Fixed Value')", 302 | "fetch_if_empty": 0, 303 | "fieldname": "response_regex", 304 | "fieldtype": "Data", 305 | "hidden": 0, 306 | "ignore_user_permissions": 0, 307 | "ignore_xss_filter": 0, 308 | "in_filter": 0, 309 | "in_global_search": 0, 310 | "in_list_view": 0, 311 | "in_standard_filter": 0, 312 | "label": "Response regex", 313 | "length": 0, 314 | "no_copy": 0, 315 | "permlevel": 0, 316 | "precision": "", 317 | "print_hide": 0, 318 | "print_hide_if_no_value": 0, 319 | "read_only": 0, 320 | "remember_last_selected_value": 0, 321 | "report_hide": 0, 322 | "reqd": 0, 323 | "search_index": 0, 324 | "set_only_once": 0, 325 | "translatable": 0, 326 | "unique": 0 327 | }, 328 | { 329 | "allow_bulk_edit": 0, 330 | "allow_in_quick_entry": 0, 331 | "allow_on_submit": 0, 332 | "bold": 0, 333 | "collapsible": 0, 334 | "columns": 0, 335 | "depends_on": "eval:(doc.assertion_type == \"Field Value\" && doc.value_type=='Fixed Value')", 336 | "fetch_if_empty": 0, 337 | "fieldname": "docfield_value", 338 | "fieldtype": "Data", 339 | "hidden": 0, 340 | "ignore_user_permissions": 0, 341 | "ignore_xss_filter": 0, 342 | "in_filter": 0, 343 | "in_global_search": 0, 344 | "in_list_view": 0, 345 | "in_standard_filter": 0, 346 | "label": "Docfield Value", 347 | "length": 0, 348 | "no_copy": 0, 349 | "permlevel": 0, 350 | "precision": "", 351 | "print_hide": 0, 352 | "print_hide_if_no_value": 0, 353 | "read_only": 0, 354 | "remember_last_selected_value": 0, 355 | "report_hide": 0, 356 | "reqd": 0, 357 | "search_index": 0, 358 | "set_only_once": 0, 359 | "translatable": 0, 360 | "unique": 0 361 | }, 362 | { 363 | "allow_bulk_edit": 0, 364 | "allow_in_quick_entry": 0, 365 | "allow_on_submit": 0, 366 | "bold": 0, 367 | "collapsible": 0, 368 | "columns": 0, 369 | "depends_on": "eval:doc.assertion_type == \"Workflow\"", 370 | "fetch_if_empty": 0, 371 | "fieldname": "workflow_state", 372 | "fieldtype": "Link", 373 | "hidden": 0, 374 | "ignore_user_permissions": 0, 375 | "ignore_xss_filter": 0, 376 | "in_filter": 0, 377 | "in_global_search": 0, 378 | "in_list_view": 0, 379 | "in_standard_filter": 0, 380 | "label": "Workflow State", 381 | "length": 0, 382 | "no_copy": 0, 383 | "options": "Workflow State", 384 | "permlevel": 0, 385 | "precision": "", 386 | "print_hide": 0, 387 | "print_hide_if_no_value": 0, 388 | "read_only": 0, 389 | "remember_last_selected_value": 0, 390 | "report_hide": 0, 391 | "reqd": 0, 392 | "search_index": 0, 393 | "set_only_once": 0, 394 | "translatable": 0, 395 | "unique": 0 396 | }, 397 | { 398 | "allow_bulk_edit": 0, 399 | "allow_in_quick_entry": 0, 400 | "allow_on_submit": 0, 401 | "bold": 0, 402 | "collapsible": 0, 403 | "columns": 0, 404 | "depends_on": "eval:doc.assertion_type == \"Workflow\"", 405 | "fetch_if_empty": 0, 406 | "fieldname": "workflow_action", 407 | "fieldtype": "Link", 408 | "hidden": 0, 409 | "ignore_user_permissions": 0, 410 | "ignore_xss_filter": 0, 411 | "in_filter": 0, 412 | "in_global_search": 0, 413 | "in_list_view": 0, 414 | "in_standard_filter": 0, 415 | "label": "Workflow Action", 416 | "length": 0, 417 | "no_copy": 0, 418 | "options": "Workflow Action", 419 | "permlevel": 0, 420 | "precision": "", 421 | "print_hide": 0, 422 | "print_hide_if_no_value": 0, 423 | "read_only": 1, 424 | "remember_last_selected_value": 0, 425 | "report_hide": 0, 426 | "reqd": 0, 427 | "search_index": 0, 428 | "set_only_once": 0, 429 | "translatable": 0, 430 | "unique": 0 431 | }, 432 | { 433 | "allow_bulk_edit": 0, 434 | "allow_in_quick_entry": 0, 435 | "allow_on_submit": 0, 436 | "bold": 0, 437 | "collapsible": 0, 438 | "columns": 0, 439 | "depends_on": "eval:(\ndoc.value_type=='Code' && (doc.assertion_type=='Field Value' || doc.assertion_type=='Response' )\n)", 440 | "description": "Use 'result' variable in your code for checking any condition.", 441 | "fetch_if_empty": 0, 442 | "fieldname": "code", 443 | "fieldtype": "Code", 444 | "hidden": 0, 445 | "ignore_user_permissions": 0, 446 | "ignore_xss_filter": 0, 447 | "in_filter": 0, 448 | "in_global_search": 0, 449 | "in_list_view": 0, 450 | "in_standard_filter": 0, 451 | "label": "Code", 452 | "length": 0, 453 | "no_copy": 0, 454 | "permlevel": 0, 455 | "precision": "", 456 | "print_hide": 0, 457 | "print_hide_if_no_value": 0, 458 | "read_only": 0, 459 | "remember_last_selected_value": 0, 460 | "report_hide": 0, 461 | "reqd": 0, 462 | "search_index": 0, 463 | "set_only_once": 0, 464 | "translatable": 0, 465 | "unique": 0 466 | }, 467 | { 468 | "allow_bulk_edit": 0, 469 | "allow_in_quick_entry": 0, 470 | "allow_on_submit": 0, 471 | "bold": 0, 472 | "collapsible": 0, 473 | "columns": 0, 474 | "default": "1", 475 | "depends_on": "eval:(doc.assertion_type==='Record Validation')", 476 | "fetch_if_empty": 0, 477 | "fieldname": "record_count", 478 | "fieldtype": "Int", 479 | "hidden": 0, 480 | "ignore_user_permissions": 0, 481 | "ignore_xss_filter": 0, 482 | "in_filter": 0, 483 | "in_global_search": 0, 484 | "in_list_view": 0, 485 | "in_standard_filter": 0, 486 | "label": "Record Count", 487 | "length": 0, 488 | "no_copy": 0, 489 | "permlevel": 0, 490 | "precision": "", 491 | "print_hide": 0, 492 | "print_hide_if_no_value": 0, 493 | "read_only": 0, 494 | "remember_last_selected_value": 0, 495 | "report_hide": 0, 496 | "reqd": 0, 497 | "search_index": 0, 498 | "set_only_once": 0, 499 | "translatable": 0, 500 | "unique": 0 501 | } 502 | ], 503 | "has_web_view": 0, 504 | "hide_heading": 0, 505 | "hide_toolbar": 0, 506 | "idx": 0, 507 | "image_view": 0, 508 | "in_create": 0, 509 | "is_submittable": 0, 510 | "issingle": 0, 511 | "istable": 1, 512 | "max_attachments": 0, 513 | "modified": "2020-05-14 16:10:29.391437", 514 | "modified_by": "Administrator", 515 | "module": "Barista", 516 | "name": "Assertion", 517 | "name_case": "", 518 | "owner": "Administrator", 519 | "permissions": [], 520 | "quick_entry": 1, 521 | "read_only": 0, 522 | "read_only_onload": 0, 523 | "show_name_in_global_search": 0, 524 | "sort_field": "modified", 525 | "sort_order": "DESC", 526 | "track_changes": 1, 527 | "track_seen": 0, 528 | "track_views": 0 529 | } -------------------------------------------------------------------------------- /barista/barista/doctype/assertion/assertion.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | 9 | class Assertion(Document): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/assertion_result/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/assertion_result/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/assertion_result/assertion_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 0, 7 | "autoname": "", 8 | "beta": 0, 9 | "creation": "2019-12-17 20:47:15.899384", 10 | "custom": 0, 11 | "docstatus": 0, 12 | "doctype": "DocType", 13 | "document_type": "", 14 | "editable_grid": 1, 15 | "engine": "InnoDB", 16 | "fields": [ 17 | { 18 | "allow_bulk_edit": 0, 19 | "allow_in_quick_entry": 0, 20 | "allow_on_submit": 0, 21 | "bold": 0, 22 | "collapsible": 0, 23 | "columns": 0, 24 | "fetch_if_empty": 0, 25 | "fieldname": "assertion", 26 | "fieldtype": "Link", 27 | "hidden": 1, 28 | "ignore_user_permissions": 0, 29 | "ignore_xss_filter": 0, 30 | "in_filter": 0, 31 | "in_global_search": 0, 32 | "in_list_view": 1, 33 | "in_standard_filter": 0, 34 | "label": "Assertion", 35 | "length": 0, 36 | "no_copy": 0, 37 | "options": "Assertion", 38 | "permlevel": 0, 39 | "precision": "", 40 | "print_hide": 0, 41 | "print_hide_if_no_value": 0, 42 | "read_only": 1, 43 | "remember_last_selected_value": 0, 44 | "report_hide": 0, 45 | "reqd": 0, 46 | "search_index": 0, 47 | "set_only_once": 0, 48 | "translatable": 0, 49 | "unique": 0 50 | }, 51 | { 52 | "allow_bulk_edit": 0, 53 | "allow_in_quick_entry": 0, 54 | "allow_on_submit": 0, 55 | "bold": 0, 56 | "collapsible": 0, 57 | "columns": 0, 58 | "fetch_if_empty": 0, 59 | "fieldname": "assertion_status", 60 | "fieldtype": "Select", 61 | "hidden": 0, 62 | "ignore_user_permissions": 0, 63 | "ignore_xss_filter": 0, 64 | "in_filter": 0, 65 | "in_global_search": 0, 66 | "in_list_view": 1, 67 | "in_standard_filter": 0, 68 | "label": "Assertion Status", 69 | "length": 0, 70 | "no_copy": 0, 71 | "options": "Failed\nPassed\nPending", 72 | "permlevel": 0, 73 | "precision": "", 74 | "print_hide": 0, 75 | "print_hide_if_no_value": 0, 76 | "read_only": 1, 77 | "remember_last_selected_value": 0, 78 | "report_hide": 0, 79 | "reqd": 0, 80 | "search_index": 0, 81 | "set_only_once": 0, 82 | "translatable": 0, 83 | "unique": 0 84 | }, 85 | { 86 | "allow_bulk_edit": 0, 87 | "allow_in_quick_entry": 0, 88 | "allow_on_submit": 0, 89 | "bold": 0, 90 | "collapsible": 0, 91 | "columns": 0, 92 | "fetch_if_empty": 0, 93 | "fieldname": "assertion_result", 94 | "fieldtype": "Small Text", 95 | "hidden": 0, 96 | "ignore_user_permissions": 0, 97 | "ignore_xss_filter": 0, 98 | "in_filter": 0, 99 | "in_global_search": 0, 100 | "in_list_view": 1, 101 | "in_standard_filter": 0, 102 | "label": "Assertion Result", 103 | "length": 0, 104 | "no_copy": 0, 105 | "permlevel": 0, 106 | "precision": "", 107 | "print_hide": 0, 108 | "print_hide_if_no_value": 0, 109 | "read_only": 1, 110 | "remember_last_selected_value": 0, 111 | "report_hide": 0, 112 | "reqd": 0, 113 | "search_index": 0, 114 | "set_only_once": 0, 115 | "translatable": 0, 116 | "unique": 0 117 | }, 118 | { 119 | "allow_bulk_edit": 0, 120 | "allow_in_quick_entry": 0, 121 | "allow_on_submit": 0, 122 | "bold": 0, 123 | "collapsible": 0, 124 | "columns": 0, 125 | "fetch_if_empty": 0, 126 | "fieldname": "column_break_4", 127 | "fieldtype": "Column Break", 128 | "hidden": 0, 129 | "ignore_user_permissions": 0, 130 | "ignore_xss_filter": 0, 131 | "in_filter": 0, 132 | "in_global_search": 0, 133 | "in_list_view": 0, 134 | "in_standard_filter": 0, 135 | "length": 0, 136 | "no_copy": 0, 137 | "permlevel": 0, 138 | "precision": "", 139 | "print_hide": 0, 140 | "print_hide_if_no_value": 0, 141 | "read_only": 0, 142 | "remember_last_selected_value": 0, 143 | "report_hide": 0, 144 | "reqd": 0, 145 | "search_index": 0, 146 | "set_only_once": 0, 147 | "translatable": 0, 148 | "unique": 0 149 | }, 150 | { 151 | "allow_bulk_edit": 0, 152 | "allow_in_quick_entry": 0, 153 | "allow_on_submit": 0, 154 | "bold": 0, 155 | "collapsible": 0, 156 | "columns": 0, 157 | "fetch_from": "assertion.assertion_type", 158 | "fetch_if_empty": 1, 159 | "fieldname": "assertion_type", 160 | "fieldtype": "Data", 161 | "hidden": 0, 162 | "ignore_user_permissions": 0, 163 | "ignore_xss_filter": 0, 164 | "in_filter": 0, 165 | "in_global_search": 0, 166 | "in_list_view": 0, 167 | "in_standard_filter": 0, 168 | "label": "Assertion Type", 169 | "length": 0, 170 | "no_copy": 0, 171 | "permlevel": 0, 172 | "precision": "", 173 | "print_hide": 0, 174 | "print_hide_if_no_value": 0, 175 | "read_only": 1, 176 | "remember_last_selected_value": 0, 177 | "report_hide": 0, 178 | "reqd": 0, 179 | "search_index": 0, 180 | "set_only_once": 0, 181 | "translatable": 0, 182 | "unique": 0 183 | }, 184 | { 185 | "allow_bulk_edit": 0, 186 | "allow_in_quick_entry": 0, 187 | "allow_on_submit": 0, 188 | "bold": 0, 189 | "collapsible": 0, 190 | "columns": 0, 191 | "fetch_from": "assertion.docfield_name", 192 | "fetch_if_empty": 1, 193 | "fieldname": "docfield_name", 194 | "fieldtype": "Data", 195 | "hidden": 0, 196 | "ignore_user_permissions": 0, 197 | "ignore_xss_filter": 0, 198 | "in_filter": 0, 199 | "in_global_search": 0, 200 | "in_list_view": 0, 201 | "in_standard_filter": 0, 202 | "label": "Docfield Name", 203 | "length": 0, 204 | "no_copy": 0, 205 | "permlevel": 0, 206 | "precision": "", 207 | "print_hide": 0, 208 | "print_hide_if_no_value": 0, 209 | "read_only": 1, 210 | "remember_last_selected_value": 0, 211 | "report_hide": 0, 212 | "reqd": 0, 213 | "search_index": 0, 214 | "set_only_once": 0, 215 | "translatable": 0, 216 | "unique": 0 217 | } 218 | ], 219 | "has_web_view": 0, 220 | "hide_heading": 0, 221 | "hide_toolbar": 0, 222 | "idx": 0, 223 | "image_view": 0, 224 | "in_create": 0, 225 | "is_submittable": 0, 226 | "issingle": 0, 227 | "istable": 1, 228 | "max_attachments": 0, 229 | "modified": "2020-04-14 23:34:16.662662", 230 | "modified_by": "Administrator", 231 | "module": "Barista", 232 | "name": "Assertion Result", 233 | "name_case": "", 234 | "owner": "Administrator", 235 | "permissions": [], 236 | "quick_entry": 1, 237 | "read_only": 0, 238 | "read_only_onload": 0, 239 | "show_name_in_global_search": 0, 240 | "sort_field": "modified", 241 | "sort_order": "DESC", 242 | "track_changes": 1, 243 | "track_seen": 0, 244 | "track_views": 0 245 | } -------------------------------------------------------------------------------- /barista/barista/doctype/assertion_result/assertion_result.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | 9 | class AssertionResult(Document): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/function_parameter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/function_parameter/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/function_parameter/function_parameter.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 0, 7 | "beta": 0, 8 | "creation": "2020-03-02 17:27:48.714245", 9 | "custom": 0, 10 | "docstatus": 0, 11 | "doctype": "DocType", 12 | "document_type": "", 13 | "editable_grid": 1, 14 | "engine": "InnoDB", 15 | "fields": [ 16 | { 17 | "allow_bulk_edit": 0, 18 | "allow_in_quick_entry": 0, 19 | "allow_on_submit": 0, 20 | "bold": 0, 21 | "collapsible": 0, 22 | "columns": 0, 23 | "fetch_if_empty": 0, 24 | "fieldname": "parameter", 25 | "fieldtype": "Data", 26 | "hidden": 0, 27 | "ignore_user_permissions": 0, 28 | "ignore_xss_filter": 0, 29 | "in_filter": 0, 30 | "in_global_search": 0, 31 | "in_list_view": 1, 32 | "in_standard_filter": 0, 33 | "label": "Parameter Name", 34 | "length": 0, 35 | "no_copy": 0, 36 | "permlevel": 0, 37 | "precision": "", 38 | "print_hide": 0, 39 | "print_hide_if_no_value": 0, 40 | "read_only": 0, 41 | "remember_last_selected_value": 0, 42 | "report_hide": 0, 43 | "reqd": 1, 44 | "search_index": 0, 45 | "set_only_once": 0, 46 | "translatable": 0, 47 | "unique": 0 48 | }, 49 | { 50 | "allow_bulk_edit": 0, 51 | "allow_in_quick_entry": 0, 52 | "allow_on_submit": 0, 53 | "bold": 0, 54 | "collapsible": 0, 55 | "columns": 0, 56 | "depends_on": "eval:(doc.value===undefined || doc.value==='')", 57 | "fetch_if_empty": 0, 58 | "fieldname": "test_data", 59 | "fieldtype": "Link", 60 | "hidden": 0, 61 | "ignore_user_permissions": 0, 62 | "ignore_xss_filter": 0, 63 | "in_filter": 0, 64 | "in_global_search": 0, 65 | "in_list_view": 1, 66 | "in_standard_filter": 0, 67 | "label": "Test Data", 68 | "length": 0, 69 | "no_copy": 0, 70 | "options": "Test Data", 71 | "permlevel": 0, 72 | "precision": "", 73 | "print_hide": 0, 74 | "print_hide_if_no_value": 0, 75 | "read_only": 0, 76 | "remember_last_selected_value": 0, 77 | "report_hide": 0, 78 | "reqd": 0, 79 | "search_index": 0, 80 | "set_only_once": 0, 81 | "translatable": 0, 82 | "unique": 0 83 | }, 84 | { 85 | "allow_bulk_edit": 0, 86 | "allow_in_quick_entry": 0, 87 | "allow_on_submit": 0, 88 | "bold": 0, 89 | "collapsible": 0, 90 | "columns": 0, 91 | "depends_on": "eval:(doc.test_data !== undefined && doc.test_data !== '' && doc.is_object===0)", 92 | "fetch_if_empty": 0, 93 | "fieldname": "field", 94 | "fieldtype": "Select", 95 | "hidden": 0, 96 | "ignore_user_permissions": 0, 97 | "ignore_xss_filter": 0, 98 | "in_filter": 0, 99 | "in_global_search": 0, 100 | "in_list_view": 1, 101 | "in_standard_filter": 0, 102 | "label": "Doctype Field", 103 | "length": 0, 104 | "no_copy": 0, 105 | "permlevel": 0, 106 | "precision": "", 107 | "print_hide": 0, 108 | "print_hide_if_no_value": 0, 109 | "read_only": 0, 110 | "remember_last_selected_value": 0, 111 | "report_hide": 0, 112 | "reqd": 0, 113 | "search_index": 0, 114 | "set_only_once": 0, 115 | "translatable": 0, 116 | "unique": 0 117 | }, 118 | { 119 | "allow_bulk_edit": 0, 120 | "allow_in_quick_entry": 0, 121 | "allow_on_submit": 0, 122 | "bold": 0, 123 | "collapsible": 0, 124 | "columns": 0, 125 | "default": "0", 126 | "depends_on": "eval:(doc.test_data !== undefined && doc.test_data !== '')", 127 | "fetch_if_empty": 0, 128 | "fieldname": "is_object", 129 | "fieldtype": "Check", 130 | "hidden": 0, 131 | "ignore_user_permissions": 0, 132 | "ignore_xss_filter": 0, 133 | "in_filter": 0, 134 | "in_global_search": 0, 135 | "in_list_view": 1, 136 | "in_standard_filter": 0, 137 | "label": "Pass whole doc as object", 138 | "length": 0, 139 | "no_copy": 0, 140 | "permlevel": 0, 141 | "precision": "", 142 | "print_hide": 0, 143 | "print_hide_if_no_value": 0, 144 | "read_only": 0, 145 | "remember_last_selected_value": 0, 146 | "report_hide": 0, 147 | "reqd": 0, 148 | "search_index": 0, 149 | "set_only_once": 0, 150 | "translatable": 0, 151 | "unique": 0 152 | }, 153 | { 154 | "allow_bulk_edit": 0, 155 | "allow_in_quick_entry": 0, 156 | "allow_on_submit": 0, 157 | "bold": 0, 158 | "collapsible": 0, 159 | "columns": 0, 160 | "fetch_if_empty": 0, 161 | "fieldname": "column_break_5", 162 | "fieldtype": "Column Break", 163 | "hidden": 0, 164 | "ignore_user_permissions": 0, 165 | "ignore_xss_filter": 0, 166 | "in_filter": 0, 167 | "in_global_search": 0, 168 | "in_list_view": 0, 169 | "in_standard_filter": 0, 170 | "length": 0, 171 | "no_copy": 0, 172 | "permlevel": 0, 173 | "precision": "", 174 | "print_hide": 0, 175 | "print_hide_if_no_value": 0, 176 | "read_only": 0, 177 | "remember_last_selected_value": 0, 178 | "report_hide": 0, 179 | "reqd": 0, 180 | "search_index": 0, 181 | "set_only_once": 0, 182 | "translatable": 0, 183 | "unique": 0 184 | }, 185 | { 186 | "allow_bulk_edit": 0, 187 | "allow_in_quick_entry": 0, 188 | "allow_on_submit": 0, 189 | "bold": 0, 190 | "collapsible": 0, 191 | "columns": 0, 192 | "depends_on": "eval:(doc.test_data===undefined || doc.test_data==='')", 193 | "fetch_if_empty": 0, 194 | "fieldname": "value", 195 | "fieldtype": "Long Text", 196 | "hidden": 0, 197 | "ignore_user_permissions": 0, 198 | "ignore_xss_filter": 0, 199 | "in_filter": 0, 200 | "in_global_search": 0, 201 | "in_list_view": 0, 202 | "in_standard_filter": 0, 203 | "label": "Parameter Value", 204 | "length": 0, 205 | "no_copy": 0, 206 | "permlevel": 0, 207 | "precision": "", 208 | "print_hide": 0, 209 | "print_hide_if_no_value": 0, 210 | "read_only": 0, 211 | "remember_last_selected_value": 0, 212 | "report_hide": 0, 213 | "reqd": 0, 214 | "search_index": 0, 215 | "set_only_once": 0, 216 | "translatable": 0, 217 | "unique": 0 218 | } 219 | ], 220 | "has_web_view": 0, 221 | "hide_heading": 0, 222 | "hide_toolbar": 0, 223 | "idx": 0, 224 | "image_view": 0, 225 | "in_create": 0, 226 | "is_submittable": 0, 227 | "issingle": 0, 228 | "istable": 1, 229 | "max_attachments": 0, 230 | "modified": "2020-05-14 18:44:27.203669", 231 | "modified_by": "Administrator", 232 | "module": "Barista", 233 | "name": "Function Parameter", 234 | "name_case": "", 235 | "owner": "Administrator", 236 | "permissions": [], 237 | "quick_entry": 0, 238 | "read_only": 0, 239 | "read_only_onload": 0, 240 | "show_name_in_global_search": 0, 241 | "sort_field": "modified", 242 | "sort_order": "DESC", 243 | "track_changes": 1, 244 | "track_seen": 0, 245 | "track_views": 0 246 | } -------------------------------------------------------------------------------- /barista/barista/doctype/function_parameter/function_parameter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2020, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | 9 | class FunctionParameter(Document): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_case/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/test_case/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/test_case/test_case.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, elasticrun and contributors 2 | // For license information, please see license.txt 3 | 4 | frappe.ui.form.on('Test Case', { 5 | refresh: function (frm) { 6 | $('textarea[data-fieldname=function_name').css('height', '30px'); 7 | if (cur_frm.doc.doctype_name) { 8 | var row = locals[cdt][cdn]; 9 | row.doctype_name = cur_frm.doc.doctype_name; 10 | cur_frm.refresh_fields(); 11 | frappe.model.with_doctype(cur_frm.doc.doctype_name, function () { 12 | var options = $.map(frappe.get_meta(cur_frm.doc.doctype_name).fields, 13 | function (d) { 14 | if (d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype) === -1) { 15 | return d.fieldname; 16 | } else if (d.fieldname && d.fieldtype == 'Table') { 17 | return d.fieldname; 18 | } 19 | return null; 20 | } 21 | ); 22 | options.push("docstatus"); 23 | frappe.meta.get_docfield("Testdatafield", "docfield_fieldname", cur_frm.doc.name).options = options; 24 | }); 25 | } 26 | cur_frm.set_query("test_data", function (doc) { 27 | if (cur_frm.doc.testcase_doctype) { 28 | if (cur_frm.doc.is_test_data_on_different_doctype == 1) { 29 | return { 30 | filters: {} 31 | } 32 | } 33 | else { 34 | return { 35 | filters: { 36 | "doctype_name": cur_frm.doc.testcase_doctype 37 | } 38 | } 39 | } 40 | } 41 | 42 | else { 43 | frappe.throw("Please Choose TestCase Doctype first") 44 | } 45 | }); 46 | 47 | if (cur_frm.doc.assertion && cur_frm.doc.assertion.length > 0 && cur_frm.doc.assertion[0].doctype_name) { 48 | var doctype_name = cur_frm.doc.assertion[0].doctype_name; 49 | frappe.model.with_doctype(doctype_name, function () { 50 | var options = $.map(frappe.get_meta(doctype_name).fields, 51 | function (d) { 52 | if (d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype) === -1) { 53 | return d.fieldname; 54 | } else if (d.fieldname && d.fieldtype == 'Table') { 55 | return d.fieldname; 56 | } 57 | return null; 58 | } 59 | ); 60 | options.push("docstatus"); 61 | options.push("name"); 62 | 63 | frappe.meta.get_docfield("Assertion", "reference_field", cur_frm.doc.name).options = options; 64 | frappe.meta.get_docfield("Assertion", "docfield_name", cur_frm.doc.name).options = options; 65 | }); 66 | cur_frm.refresh_fields(); 67 | } 68 | $("[data-fieldname=dummy_chkbox]").find("i.disabled-check").css("display", "none"); 69 | $("[data-fieldname=dummy_chkbox]").find("label").css("min-height", "16px"); 70 | 71 | if (cur_frm.doc.testcase_doctype) { 72 | addTestCaseDocFields(cur_frm); 73 | } 74 | 75 | if (cur_frm.doc.test_data) { 76 | addTestDataDocFields(cur_frm); 77 | } 78 | }, 79 | testcase_doctype: function (cur_frm) { 80 | if (cur_frm.doc.testcase_doctype) { 81 | addTestCaseDocFields(cur_frm); 82 | } 83 | }, 84 | test_data: function (cur_frm) { 85 | if (cur_frm.doc.test_data) { 86 | addTestDataDocFields(cur_frm); 87 | } 88 | } 89 | 90 | 91 | 92 | }); 93 | 94 | frappe.ui.form.on('Testdatafield', { 95 | refresh: function (frm, cdt, cdn) { 96 | 97 | }, 98 | update_fields_add: function (frm, cdt, cdn) { 99 | if (cur_frm.doc.testcase_doctype) { 100 | var row = locals[cdt][cdn]; 101 | row.doctype_name = cur_frm.doc.testcase_doctype; 102 | cur_frm.refresh_fields(); 103 | var options = []; 104 | frappe.model.with_doctype(cur_frm.doc.testcase_doctype, function () { 105 | var options = $.map(frappe.get_meta(cur_frm.doc.testcase_doctype).fields, 106 | function (d) { 107 | if (d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype) === -1) { 108 | return d.fieldname; 109 | } else if (d.fieldname && d.fieldtype == 'Table') { 110 | return d.fieldname; 111 | } 112 | 113 | return null; 114 | } 115 | ); 116 | options.push("docstatus"); 117 | options.push("name"); 118 | frappe.meta.get_docfield("Testdatafield", "docfield_fieldname", cur_frm.doc.name).options = options; 119 | }); 120 | } else { 121 | cur_frm.refresh_fields(); 122 | frappe.throw("Please Add the Doctype Name to Proceed") 123 | } 124 | } 125 | }); 126 | 127 | frappe.ui.form.on("Assertion", { 128 | refresh: function (frm, cdt, cdn) { 129 | 130 | }, 131 | doctype_name: function (frm, cdt, cdn) { 132 | var row = locals[cdt][cdn]; 133 | if (row.doctype_name) { 134 | frappe.model.with_doctype(row.doctype_name, function () { 135 | var options = $.map(frappe.get_meta(row.doctype_name).fields, 136 | function (d) { 137 | if (d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype) === -1) { 138 | return d.fieldname; 139 | } else if (d.fieldname && d.fieldtype == 'Table') { 140 | return d.fieldname; 141 | } 142 | return null; 143 | } 144 | ); 145 | options.push("docstatus"); 146 | options.push("name"); 147 | options.push("parent"); 148 | frappe.meta.get_docfield("Assertion", "reference_field", cur_frm.doc.name).options = options; 149 | frappe.meta.get_docfield("Assertion", "docfield_name", cur_frm.doc.name).options = options; 150 | }); 151 | cur_frm.refresh_fields(); 152 | } 153 | } 154 | }); 155 | 156 | function addTestCaseDocFields(cur_frm) { 157 | frappe.model.with_doctype(cur_frm.doc.testcase_doctype, function () { 158 | var options = $.map(frappe.get_meta(cur_frm.doc.testcase_doctype).fields, 159 | function (d) { 160 | if (d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype) === -1) { 161 | return d.fieldname; 162 | } else if (d.fieldname && d.fieldtype == 'Table') { 163 | return d.fieldname; 164 | } 165 | return null; 166 | } 167 | ); 168 | options.push("name"); 169 | cur_frm.fields_dict.test_case_docfield.df.options = options; 170 | cur_frm.refresh_field("test_case_docfield") 171 | 172 | }); 173 | // cur_frm.refresh_fields(); 174 | 175 | } 176 | 177 | function addTestDataDocFields(cur_frm) { 178 | frappe.call({ 179 | "method": "frappe.client.get_value", 180 | "args": { 181 | doctype: "Test Data", 182 | fieldname: "doctype_name", 183 | filters: { name: cur_frm.doc.test_data } 184 | }, 185 | freeze: true, 186 | callback: function (r) { 187 | var testDataDoc = r.message.doctype_name; 188 | frappe.model.with_doctype(testDataDoc, function () { 189 | var options = $.map(frappe.get_meta(testDataDoc).fields, 190 | function (d) { 191 | if (d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype) === -1) { 192 | return d.fieldname; 193 | } else if (d.fieldname && d.fieldtype == 'Table') { 194 | return d.fieldname; 195 | } 196 | return null; 197 | } 198 | ); 199 | options.push("name"); 200 | cur_frm.fields_dict.test_data_docfield.df.options = options; 201 | cur_frm.refresh_field("test_data_docfield"); 202 | }); 203 | } 204 | 205 | }) 206 | 207 | // cur_frm.refresh_fields(); 208 | } 209 | 210 | frappe.ui.form.on("Function Parameter", "test_data", function (frm, cdt, cdn) { 211 | let row = locals[cdt][cdn]; 212 | let docFields = []; 213 | frappe.db.get_value('Test Data', row.test_data, 'doctype_name').then((d) => { 214 | let testDataDoctype = d.message.doctype_name; 215 | frappe.model.with_doctype(testDataDoctype); 216 | frappe.call({ 217 | method: 'frappe.desk.form.load.getdoctype', 218 | args: { 219 | 'doctype': testDataDoctype, 220 | 'with_parent': 1 221 | }, 222 | freeze: true, 223 | callback: function (r) { 224 | if (!r.exc) { 225 | frappe.model.with_doctype(testDataDoctype, function () { 226 | let fields = frappe.get_meta(testDataDoctype).fields; 227 | let options = []; 228 | fields.forEach((f) => { 229 | if (!['Section Break', 'Column Break'].includes(f.fieldtype)) { 230 | options.push(f.fieldname); 231 | } 232 | }) 233 | options.push("docstatus"); 234 | options.push('name'); 235 | options.push('doctype'); 236 | docFields = options; 237 | frappe.meta.get_docfield("Function Parameter", "field", cur_frm.doc.name).options = docFields; 238 | }); 239 | cur_frm.refresh_fields(); 240 | } 241 | } 242 | }); 243 | }); 244 | 245 | }); -------------------------------------------------------------------------------- /barista/barista/doctype/test_case/test_case.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | 9 | 10 | class TestCase(Document): 11 | def validate(self): 12 | if self.testcase_doctype: 13 | docfields = [docfield.fieldname for docfield in frappe.get_meta( 14 | self.testcase_doctype).fields] 15 | docfields.append('docstatus') 16 | docfields.append('name') 17 | docfields.append('parent') 18 | 19 | for row in self.update_fields: 20 | if row.docfield_fieldname not in docfields: 21 | frappe.throw( 22 | f"Invalid DocField {row.docfield_fieldname} in {self.testcase_doctype} of Test Case {self.name}") 23 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_case/test_case_dashboard.py: -------------------------------------------------------------------------------- 1 | from frappe import _ 2 | 3 | 4 | def get_data(): 5 | return { 6 | 'fieldname': 'test_case', 7 | 'non_standard_fieldnames': { 8 | 'Test Result': 'test_case' 9 | }, 10 | 'internal_links': { 11 | 12 | }, 13 | 'transactions': [ 14 | { 15 | 'items': ['Test Result'] 16 | }, 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_case/test_test_case.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | // rename this file from _test_[name] to test_[name] to activate 3 | // and remove above this line 4 | 5 | QUnit.test("test: Test Case", function (assert) { 6 | let done = assert.async(); 7 | 8 | // number of asserts 9 | assert.expect(1); 10 | 11 | frappe.run_serially([ 12 | // insert a new Test Case 13 | () => frappe.tests.make('Test Case', [ 14 | // values to be set 15 | {key: 'value'} 16 | ]), 17 | () => { 18 | assert.equal(cur_frm.doc.key, 'value'); 19 | }, 20 | () => done() 21 | ]); 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_case/test_test_case.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and Contributors 3 | # See license.txt 4 | from __future__ import unicode_literals 5 | 6 | import frappe 7 | import unittest 8 | 9 | class TestTestCase(unittest.TestCase): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/test_data/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/test_data/test_data.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, elasticrun and contributors 2 | // For license information, please see license.txt 3 | let docFields = []; 4 | const ignoredFields = ['name', 'docstatus', 'workflow_state', 'parent', 'amended_from']; 5 | let fieldType = {}; 6 | 7 | frappe.ui.form.on('Test Data', { 8 | refresh: function (frm) { 9 | $('textarea[data-fieldname=function_name').css('height', '30px'); 10 | $('textarea[data-fieldname=eval_function_result').css('height', '30px'); 11 | if (cur_frm.doc.doctype_name) { 12 | if (cur_frm.doc.doctype_name) { 13 | frappe.model.with_doctype(cur_frm.doc.doctype_name, function () { 14 | var options = $.map(frappe.get_meta(cur_frm.doc.doctype_name).fields, 15 | function (d) { 16 | if (d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype) === -1) { 17 | return d.fieldname; 18 | } else if (d.fieldname && d.fieldtype == 'Table') { 19 | return d.fieldname; 20 | } 21 | return null; 22 | } 23 | ); 24 | options.push("docstatus"); 25 | frappe.meta.get_docfield("Testdatafield", "docfield_fieldname", cur_frm.doc.name).options = options; 26 | }); 27 | } 28 | } 29 | } 30 | }); 31 | 32 | 33 | frappe.ui.form.on('Testdatafield', { 34 | refresh: function (frm, cdt, cdn) { 35 | 36 | }, 37 | docfield_value_add: function (frm, cdt, cdn) { 38 | if (cur_frm.doc.doctype_name) { 39 | var row = locals[cdt][cdn]; 40 | row.doctype_name = cur_frm.doc.doctype_name; 41 | cur_frm.refresh_fields(); 42 | frappe.model.with_doctype(cur_frm.doc.doctype_name, function () { 43 | var options = $.map(frappe.get_meta(cur_frm.doc.doctype_name).fields, 44 | function (d) { 45 | if (d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype) === -1) { 46 | return d.fieldname; 47 | } else if (d.fieldname && d.fieldtype == 'Table') { 48 | return d.fieldname; 49 | } 50 | return null; 51 | } 52 | ); 53 | 54 | options.push("docstatus"); 55 | options.push("name"); 56 | frappe.meta.get_docfield("Testdatafield", "docfield_fieldname", cur_frm.doc.name).options = options; 57 | }); 58 | } else { 59 | cur_frm.refresh_fields(); 60 | frappe.throw("Please Add the Doctype Name to Proceed") 61 | } 62 | } 63 | }); 64 | 65 | frappe.ui.form.on("Test Data", "doctype_name", function (frm, cdt, cdn) { 66 | let tableFields = []; 67 | docFields = []; 68 | fieldType = {}; 69 | 70 | cur_frm.doc.docfield_value = []; 71 | cur_frm.doc.existing_record = ''; 72 | cur_frm.refresh_fields(); 73 | if (cur_frm.doc.doctype_name) { 74 | frappe.model.with_doctype(cur_frm.doc.doctype_name); 75 | frappe.call({ 76 | method: 'frappe.desk.form.load.getdoctype', 77 | args: { 78 | 'doctype': cur_frm.doc.doctype_name, 79 | 'with_parent': 1 80 | }, 81 | freeze: true, 82 | callback: function (r) { 83 | if (!r.exc) { 84 | frappe.model.with_doctype(cur_frm.doc.doctype_name, function () { 85 | var options = $.map(frappe.get_meta(cur_frm.doc.doctype_name).fields, 86 | function (d) { 87 | fieldType[d.fieldname] = d.fieldtype; 88 | 89 | if (d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype) === -1) { 90 | return d.fieldname; 91 | } else if (d.fieldname && d.fieldtype == 'Table') { 92 | tableFields.push(d.fieldname); 93 | return d.fieldname; 94 | } 95 | return null; 96 | } 97 | ); 98 | options.push("docstatus"); 99 | options.push("name"); 100 | docFields = options; 101 | frappe.meta.get_docfield("Testdatafield", "docfield_fieldname", cur_frm.doc.name).options = docFields; 102 | }); 103 | 104 | docFields.forEach((d) => { 105 | if (!ignoredFields.includes(d)) { 106 | var childTable = cur_frm.add_child("docfield_value"); 107 | childTable.doctype_name = cur_frm.doc.doctype_name; 108 | childTable.docfield_fieldname = d; 109 | if (tableFields.includes(d)) { 110 | childTable.docfield_code_value = 'Code'; 111 | } else { 112 | childTable.docfield_code_value = ''; 113 | } 114 | } 115 | }); 116 | cur_frm.refresh_fields("docfield_value"); 117 | } 118 | } 119 | }); 120 | } 121 | }) 122 | 123 | frappe.ui.form.on("Test Data", "existing_record", function (frm, cdt, cdn) { 124 | if (cur_frm.doc.existing_record) { 125 | frappe.call({ 126 | method: 'frappe.desk.form.load.getdoc', 127 | args: { 128 | 'doctype': cur_frm.doc.doctype_name, 129 | 'name': cur_frm.doc.existing_record 130 | }, 131 | freeze: true, 132 | callback: function (r) { 133 | if (!r.exc) { 134 | if (r.docs) { 135 | if (r.docs[0]) { 136 | const doc = r.docs[0]; 137 | cur_frm.doc.docfield_value.forEach((d) => { 138 | try { 139 | if (!ignoredFields.includes(d.docfield_fieldname)) { 140 | if (typeof (doc[d.docfield_fieldname]) === 'object') { 141 | // Not setting right now, will do in future 142 | } else if (doc[d.docfield_fieldname] && !['Link', 'Dynamic Link'].includes(fieldType[d.docfield_fieldname])) { 143 | d.docfield_value = doc[d.docfield_fieldname].toString(); 144 | d.docfield_code_value = 'Fixed Value'; 145 | } 146 | } 147 | } catch (err) { 148 | console.error(err); 149 | } 150 | }); 151 | cur_frm.refresh_fields("docfield_value"); 152 | } 153 | } 154 | } 155 | } 156 | }); 157 | } 158 | }) 159 | 160 | 161 | frappe.ui.form.on("Function Parameter", "test_data", function (frm, cdt, cdn) { 162 | let row = locals[cdt][cdn]; 163 | let docFields = []; 164 | frappe.db.get_value('Test Data', row.test_data, 'doctype_name').then((d) => { 165 | let testDataDoctype = d.message.doctype_name; 166 | frappe.model.with_doctype(testDataDoctype); 167 | frappe.call({ 168 | method: 'frappe.desk.form.load.getdoctype', 169 | args: { 170 | 'doctype': testDataDoctype, 171 | 'with_parent': 1 172 | }, 173 | freeze: true, 174 | callback: function (r) { 175 | if (!r.exc) { 176 | frappe.model.with_doctype(testDataDoctype, function () { 177 | let fields = frappe.get_meta(testDataDoctype).fields; 178 | let options = []; 179 | fields.forEach((f) => { 180 | if (!['Section Break', 'Column Break'].includes(f.fieldtype)) { 181 | options.push(f.fieldname); 182 | } 183 | }) 184 | options.push("docstatus"); 185 | options.push('name'); 186 | options.push('doctype'); 187 | docFields = options; 188 | frappe.meta.get_docfield("Function Parameter", "field", cur_frm.doc.name).options = docFields; 189 | }); 190 | cur_frm.refresh_fields(); 191 | } 192 | } 193 | }); 194 | }); 195 | 196 | }); -------------------------------------------------------------------------------- /barista/barista/doctype/test_data/test_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 0, 7 | "autoname": "TestData-.####", 8 | "beta": 0, 9 | "creation": "2019-12-26 06:54:24.843530", 10 | "custom": 0, 11 | "docstatus": 0, 12 | "doctype": "DocType", 13 | "document_type": "", 14 | "editable_grid": 1, 15 | "engine": "InnoDB", 16 | "fields": [ 17 | { 18 | "allow_bulk_edit": 0, 19 | "allow_in_quick_entry": 0, 20 | "allow_on_submit": 0, 21 | "bold": 0, 22 | "collapsible": 0, 23 | "columns": 0, 24 | "fetch_from": "doc.purpose", 25 | "fetch_if_empty": 1, 26 | "fieldname": "description", 27 | "fieldtype": "Data", 28 | "hidden": 0, 29 | "ignore_user_permissions": 0, 30 | "ignore_xss_filter": 0, 31 | "in_filter": 0, 32 | "in_global_search": 0, 33 | "in_list_view": 0, 34 | "in_standard_filter": 0, 35 | "label": "Description", 36 | "length": 0, 37 | "no_copy": 0, 38 | "permlevel": 0, 39 | "precision": "", 40 | "print_hide": 0, 41 | "print_hide_if_no_value": 0, 42 | "read_only": 0, 43 | "remember_last_selected_value": 0, 44 | "report_hide": 0, 45 | "reqd": 0, 46 | "search_index": 0, 47 | "set_only_once": 0, 48 | "translatable": 0, 49 | "unique": 0 50 | }, 51 | { 52 | "allow_bulk_edit": 0, 53 | "allow_in_quick_entry": 0, 54 | "allow_on_submit": 0, 55 | "bold": 0, 56 | "collapsible": 0, 57 | "columns": 0, 58 | "fetch_if_empty": 0, 59 | "fieldname": "doctype_name", 60 | "fieldtype": "Link", 61 | "hidden": 0, 62 | "ignore_user_permissions": 0, 63 | "ignore_xss_filter": 0, 64 | "in_filter": 0, 65 | "in_global_search": 0, 66 | "in_list_view": 1, 67 | "in_standard_filter": 1, 68 | "label": "Doctype Name", 69 | "length": 0, 70 | "no_copy": 0, 71 | "options": "DocType", 72 | "permlevel": 0, 73 | "precision": "", 74 | "print_hide": 0, 75 | "print_hide_if_no_value": 0, 76 | "read_only": 0, 77 | "remember_last_selected_value": 0, 78 | "report_hide": 0, 79 | "reqd": 0, 80 | "search_index": 0, 81 | "set_only_once": 0, 82 | "translatable": 0, 83 | "unique": 0 84 | }, 85 | { 86 | "allow_bulk_edit": 0, 87 | "allow_in_quick_entry": 0, 88 | "allow_on_submit": 0, 89 | "bold": 0, 90 | "collapsible": 0, 91 | "columns": 0, 92 | "fetch_if_empty": 0, 93 | "fieldname": "doctype_type", 94 | "fieldtype": "Select", 95 | "hidden": 0, 96 | "ignore_user_permissions": 0, 97 | "ignore_xss_filter": 0, 98 | "in_filter": 0, 99 | "in_global_search": 0, 100 | "in_list_view": 1, 101 | "in_standard_filter": 0, 102 | "label": "Doctype Type", 103 | "length": 0, 104 | "no_copy": 0, 105 | "options": "Master\nTransaction", 106 | "permlevel": 0, 107 | "precision": "", 108 | "print_hide": 0, 109 | "print_hide_if_no_value": 0, 110 | "read_only": 0, 111 | "remember_last_selected_value": 0, 112 | "report_hide": 0, 113 | "reqd": 0, 114 | "search_index": 0, 115 | "set_only_once": 0, 116 | "translatable": 0, 117 | "unique": 0 118 | }, 119 | { 120 | "allow_bulk_edit": 0, 121 | "allow_in_quick_entry": 0, 122 | "allow_on_submit": 0, 123 | "bold": 0, 124 | "collapsible": 0, 125 | "columns": 0, 126 | "fetch_if_empty": 0, 127 | "fieldname": "column_break_3", 128 | "fieldtype": "Column Break", 129 | "hidden": 0, 130 | "ignore_user_permissions": 0, 131 | "ignore_xss_filter": 0, 132 | "in_filter": 0, 133 | "in_global_search": 0, 134 | "in_list_view": 0, 135 | "in_standard_filter": 0, 136 | "length": 0, 137 | "no_copy": 0, 138 | "permlevel": 0, 139 | "precision": "", 140 | "print_hide": 0, 141 | "print_hide_if_no_value": 0, 142 | "read_only": 0, 143 | "remember_last_selected_value": 0, 144 | "report_hide": 0, 145 | "reqd": 0, 146 | "search_index": 0, 147 | "set_only_once": 0, 148 | "translatable": 0, 149 | "unique": 0 150 | }, 151 | { 152 | "allow_bulk_edit": 0, 153 | "allow_in_quick_entry": 0, 154 | "allow_on_submit": 0, 155 | "bold": 0, 156 | "collapsible": 0, 157 | "columns": 0, 158 | "fetch_from": "doctype_name.module", 159 | "fetch_if_empty": 1, 160 | "fieldname": "module_name", 161 | "fieldtype": "Link", 162 | "hidden": 0, 163 | "ignore_user_permissions": 0, 164 | "ignore_xss_filter": 0, 165 | "in_filter": 0, 166 | "in_global_search": 0, 167 | "in_list_view": 0, 168 | "in_standard_filter": 0, 169 | "label": "Module Name", 170 | "length": 0, 171 | "no_copy": 0, 172 | "options": "Module Def", 173 | "permlevel": 0, 174 | "precision": "", 175 | "print_hide": 0, 176 | "print_hide_if_no_value": 0, 177 | "read_only": 1, 178 | "remember_last_selected_value": 0, 179 | "report_hide": 0, 180 | "reqd": 0, 181 | "search_index": 0, 182 | "set_only_once": 0, 183 | "translatable": 0, 184 | "unique": 0 185 | }, 186 | { 187 | "allow_bulk_edit": 0, 188 | "allow_in_quick_entry": 0, 189 | "allow_on_submit": 0, 190 | "bold": 0, 191 | "collapsible": 0, 192 | "columns": 0, 193 | "fetch_from": "module_name.app_name", 194 | "fetch_if_empty": 1, 195 | "fieldname": "app_name", 196 | "fieldtype": "Data", 197 | "hidden": 0, 198 | "ignore_user_permissions": 0, 199 | "ignore_xss_filter": 0, 200 | "in_filter": 0, 201 | "in_global_search": 0, 202 | "in_list_view": 0, 203 | "in_standard_filter": 0, 204 | "label": "App Name", 205 | "length": 0, 206 | "no_copy": 0, 207 | "options": "", 208 | "permlevel": 0, 209 | "precision": "", 210 | "print_hide": 0, 211 | "print_hide_if_no_value": 0, 212 | "read_only": 1, 213 | "remember_last_selected_value": 0, 214 | "report_hide": 0, 215 | "reqd": 0, 216 | "search_index": 0, 217 | "set_only_once": 0, 218 | "translatable": 0, 219 | "unique": 0 220 | }, 221 | { 222 | "allow_bulk_edit": 0, 223 | "allow_in_quick_entry": 0, 224 | "allow_on_submit": 0, 225 | "bold": 0, 226 | "collapsible": 0, 227 | "columns": 0, 228 | "fetch_if_empty": 0, 229 | "fieldname": "existing_record", 230 | "fieldtype": "Dynamic Link", 231 | "hidden": 0, 232 | "ignore_user_permissions": 0, 233 | "ignore_xss_filter": 0, 234 | "in_filter": 0, 235 | "in_global_search": 0, 236 | "in_list_view": 0, 237 | "in_standard_filter": 0, 238 | "label": "Existing Record", 239 | "length": 0, 240 | "no_copy": 0, 241 | "options": "doctype_name", 242 | "permlevel": 0, 243 | "precision": "", 244 | "print_hide": 0, 245 | "print_hide_if_no_value": 0, 246 | "read_only": 0, 247 | "remember_last_selected_value": 0, 248 | "report_hide": 0, 249 | "reqd": 0, 250 | "search_index": 0, 251 | "set_only_once": 0, 252 | "translatable": 0, 253 | "unique": 0 254 | }, 255 | { 256 | "allow_bulk_edit": 0, 257 | "allow_in_quick_entry": 0, 258 | "allow_on_submit": 0, 259 | "bold": 0, 260 | "collapsible": 0, 261 | "columns": 0, 262 | "fetch_if_empty": 0, 263 | "fieldname": "section_break_6", 264 | "fieldtype": "Section Break", 265 | "hidden": 0, 266 | "ignore_user_permissions": 0, 267 | "ignore_xss_filter": 0, 268 | "in_filter": 0, 269 | "in_global_search": 0, 270 | "in_list_view": 0, 271 | "in_standard_filter": 0, 272 | "length": 0, 273 | "no_copy": 0, 274 | "permlevel": 0, 275 | "precision": "", 276 | "print_hide": 0, 277 | "print_hide_if_no_value": 0, 278 | "read_only": 0, 279 | "remember_last_selected_value": 0, 280 | "report_hide": 0, 281 | "reqd": 0, 282 | "search_index": 0, 283 | "set_only_once": 0, 284 | "translatable": 0, 285 | "unique": 0 286 | }, 287 | { 288 | "allow_bulk_edit": 0, 289 | "allow_in_quick_entry": 0, 290 | "allow_on_submit": 0, 291 | "bold": 0, 292 | "collapsible": 0, 293 | "columns": 0, 294 | "default": "0", 295 | "depends_on": "eval:(doc.use_function ===0)", 296 | "fetch_if_empty": 0, 297 | "fieldname": "use_script", 298 | "fieldtype": "Check", 299 | "hidden": 0, 300 | "ignore_user_permissions": 0, 301 | "ignore_xss_filter": 0, 302 | "in_filter": 0, 303 | "in_global_search": 0, 304 | "in_list_view": 0, 305 | "in_standard_filter": 0, 306 | "label": "Use Script", 307 | "length": 0, 308 | "no_copy": 0, 309 | "permlevel": 0, 310 | "precision": "", 311 | "print_hide": 0, 312 | "print_hide_if_no_value": 0, 313 | "read_only": 0, 314 | "remember_last_selected_value": 0, 315 | "report_hide": 0, 316 | "reqd": 0, 317 | "search_index": 0, 318 | "set_only_once": 0, 319 | "translatable": 0, 320 | "unique": 0 321 | }, 322 | { 323 | "allow_bulk_edit": 0, 324 | "allow_in_quick_entry": 0, 325 | "allow_on_submit": 0, 326 | "bold": 0, 327 | "collapsible": 0, 328 | "columns": 0, 329 | "fetch_if_empty": 0, 330 | "fieldname": "column_break_10", 331 | "fieldtype": "Column Break", 332 | "hidden": 0, 333 | "ignore_user_permissions": 0, 334 | "ignore_xss_filter": 0, 335 | "in_filter": 0, 336 | "in_global_search": 0, 337 | "in_list_view": 0, 338 | "in_standard_filter": 0, 339 | "length": 0, 340 | "no_copy": 0, 341 | "permlevel": 0, 342 | "precision": "", 343 | "print_hide": 0, 344 | "print_hide_if_no_value": 0, 345 | "read_only": 0, 346 | "remember_last_selected_value": 0, 347 | "report_hide": 0, 348 | "reqd": 0, 349 | "search_index": 0, 350 | "set_only_once": 0, 351 | "translatable": 0, 352 | "unique": 0 353 | }, 354 | { 355 | "allow_bulk_edit": 0, 356 | "allow_in_quick_entry": 0, 357 | "allow_on_submit": 0, 358 | "bold": 0, 359 | "collapsible": 0, 360 | "columns": 0, 361 | "default": "0", 362 | "depends_on": "eval:(doc.use_script ===0)", 363 | "fetch_if_empty": 0, 364 | "fieldname": "use_function", 365 | "fieldtype": "Check", 366 | "hidden": 0, 367 | "ignore_user_permissions": 0, 368 | "ignore_xss_filter": 0, 369 | "in_filter": 0, 370 | "in_global_search": 0, 371 | "in_list_view": 0, 372 | "in_standard_filter": 0, 373 | "label": "Use Function", 374 | "length": 0, 375 | "no_copy": 0, 376 | "permlevel": 0, 377 | "precision": "", 378 | "print_hide": 0, 379 | "print_hide_if_no_value": 0, 380 | "read_only": 0, 381 | "remember_last_selected_value": 0, 382 | "report_hide": 0, 383 | "reqd": 0, 384 | "search_index": 0, 385 | "set_only_once": 0, 386 | "translatable": 0, 387 | "unique": 0 388 | }, 389 | { 390 | "allow_bulk_edit": 0, 391 | "allow_in_quick_entry": 0, 392 | "allow_on_submit": 0, 393 | "bold": 0, 394 | "collapsible": 0, 395 | "columns": 0, 396 | "depends_on": "eval:(doc.use_function === 1)", 397 | "fetch_if_empty": 0, 398 | "fieldname": "section_break_12", 399 | "fieldtype": "Section Break", 400 | "hidden": 0, 401 | "ignore_user_permissions": 0, 402 | "ignore_xss_filter": 0, 403 | "in_filter": 0, 404 | "in_global_search": 0, 405 | "in_list_view": 0, 406 | "in_standard_filter": 0, 407 | "length": 0, 408 | "no_copy": 0, 409 | "permlevel": 0, 410 | "precision": "", 411 | "print_hide": 0, 412 | "print_hide_if_no_value": 0, 413 | "read_only": 0, 414 | "remember_last_selected_value": 0, 415 | "report_hide": 0, 416 | "reqd": 0, 417 | "search_index": 0, 418 | "set_only_once": 0, 419 | "translatable": 0, 420 | "unique": 0 421 | }, 422 | { 423 | "allow_bulk_edit": 0, 424 | "allow_in_quick_entry": 0, 425 | "allow_on_submit": 0, 426 | "bold": 0, 427 | "collapsible": 0, 428 | "columns": 0, 429 | "fetch_if_empty": 0, 430 | "fieldname": "function_name", 431 | "fieldtype": "Small Text", 432 | "hidden": 0, 433 | "ignore_user_permissions": 0, 434 | "ignore_xss_filter": 0, 435 | "in_filter": 0, 436 | "in_global_search": 0, 437 | "in_list_view": 0, 438 | "in_standard_filter": 0, 439 | "label": "Function Name", 440 | "length": 0, 441 | "no_copy": 0, 442 | "permlevel": 0, 443 | "precision": "", 444 | "print_hide": 0, 445 | "print_hide_if_no_value": 0, 446 | "read_only": 0, 447 | "remember_last_selected_value": 0, 448 | "report_hide": 0, 449 | "reqd": 0, 450 | "search_index": 0, 451 | "set_only_once": 0, 452 | "translatable": 0, 453 | "unique": 0 454 | }, 455 | { 456 | "allow_bulk_edit": 0, 457 | "allow_in_quick_entry": 0, 458 | "allow_on_submit": 0, 459 | "bold": 0, 460 | "collapsible": 0, 461 | "columns": 0, 462 | "description": "Use 'result' variable for evaluating and storing Test Record Name. Default key 'name' will be considered if nothing is provided.", 463 | "fetch_if_empty": 0, 464 | "fieldname": "eval_function_result", 465 | "fieldtype": "Small Text", 466 | "hidden": 0, 467 | "ignore_user_permissions": 0, 468 | "ignore_xss_filter": 0, 469 | "in_filter": 0, 470 | "in_global_search": 0, 471 | "in_list_view": 0, 472 | "in_standard_filter": 0, 473 | "label": "Evaluate Function Result", 474 | "length": 0, 475 | "no_copy": 0, 476 | "permlevel": 0, 477 | "precision": "", 478 | "print_hide": 0, 479 | "print_hide_if_no_value": 0, 480 | "read_only": 0, 481 | "remember_last_selected_value": 0, 482 | "report_hide": 0, 483 | "reqd": 0, 484 | "search_index": 0, 485 | "set_only_once": 0, 486 | "translatable": 0, 487 | "unique": 0 488 | }, 489 | { 490 | "allow_bulk_edit": 0, 491 | "allow_in_quick_entry": 0, 492 | "allow_on_submit": 0, 493 | "bold": 0, 494 | "collapsible": 0, 495 | "columns": 0, 496 | "fetch_if_empty": 0, 497 | "fieldname": "function_parameters", 498 | "fieldtype": "Table", 499 | "hidden": 0, 500 | "ignore_user_permissions": 0, 501 | "ignore_xss_filter": 0, 502 | "in_filter": 0, 503 | "in_global_search": 0, 504 | "in_list_view": 0, 505 | "in_standard_filter": 0, 506 | "length": 0, 507 | "no_copy": 0, 508 | "options": "Function Parameter", 509 | "permlevel": 0, 510 | "precision": "", 511 | "print_hide": 0, 512 | "print_hide_if_no_value": 0, 513 | "read_only": 0, 514 | "remember_last_selected_value": 0, 515 | "report_hide": 0, 516 | "reqd": 0, 517 | "search_index": 0, 518 | "set_only_once": 0, 519 | "translatable": 0, 520 | "unique": 0 521 | }, 522 | { 523 | "allow_bulk_edit": 0, 524 | "allow_in_quick_entry": 0, 525 | "allow_on_submit": 0, 526 | "bold": 0, 527 | "collapsible": 0, 528 | "columns": 0, 529 | "depends_on": "eval:(doc.use_script === 1)", 530 | "fetch_if_empty": 0, 531 | "fieldname": "section_break_10", 532 | "fieldtype": "Section Break", 533 | "hidden": 0, 534 | "ignore_user_permissions": 0, 535 | "ignore_xss_filter": 0, 536 | "in_filter": 0, 537 | "in_global_search": 0, 538 | "in_list_view": 0, 539 | "in_standard_filter": 0, 540 | "length": 0, 541 | "no_copy": 0, 542 | "permlevel": 0, 543 | "precision": "", 544 | "print_hide": 0, 545 | "print_hide_if_no_value": 0, 546 | "read_only": 0, 547 | "remember_last_selected_value": 0, 548 | "report_hide": 0, 549 | "reqd": 0, 550 | "search_index": 0, 551 | "set_only_once": 0, 552 | "translatable": 0, 553 | "unique": 0 554 | }, 555 | { 556 | "allow_bulk_edit": 0, 557 | "allow_in_quick_entry": 0, 558 | "allow_on_submit": 0, 559 | "bold": 0, 560 | "collapsible": 0, 561 | "columns": 0, 562 | "depends_on": "", 563 | "fetch_if_empty": 0, 564 | "fieldname": "insert_script", 565 | "fieldtype": "Code", 566 | "hidden": 0, 567 | "ignore_user_permissions": 0, 568 | "ignore_xss_filter": 0, 569 | "in_filter": 0, 570 | "in_global_search": 0, 571 | "in_list_view": 0, 572 | "in_standard_filter": 0, 573 | "label": "Insert Script", 574 | "length": 0, 575 | "no_copy": 0, 576 | "permlevel": 0, 577 | "precision": "", 578 | "print_hide": 0, 579 | "print_hide_if_no_value": 0, 580 | "read_only": 0, 581 | "remember_last_selected_value": 0, 582 | "report_hide": 0, 583 | "reqd": 0, 584 | "search_index": 0, 585 | "set_only_once": 0, 586 | "translatable": 0, 587 | "unique": 0 588 | }, 589 | { 590 | "allow_bulk_edit": 0, 591 | "allow_in_quick_entry": 0, 592 | "allow_on_submit": 0, 593 | "bold": 0, 594 | "collapsible": 0, 595 | "columns": 0, 596 | "fetch_if_empty": 0, 597 | "fieldname": "test_data_section", 598 | "fieldtype": "Section Break", 599 | "hidden": 0, 600 | "ignore_user_permissions": 0, 601 | "ignore_xss_filter": 0, 602 | "in_filter": 0, 603 | "in_global_search": 0, 604 | "in_list_view": 0, 605 | "in_standard_filter": 0, 606 | "label": "", 607 | "length": 0, 608 | "no_copy": 0, 609 | "permlevel": 0, 610 | "precision": "", 611 | "print_hide": 0, 612 | "print_hide_if_no_value": 0, 613 | "read_only": 0, 614 | "remember_last_selected_value": 0, 615 | "report_hide": 0, 616 | "reqd": 0, 617 | "search_index": 0, 618 | "set_only_once": 0, 619 | "translatable": 0, 620 | "unique": 0 621 | }, 622 | { 623 | "allow_bulk_edit": 0, 624 | "allow_in_quick_entry": 0, 625 | "allow_on_submit": 0, 626 | "bold": 0, 627 | "collapsible": 0, 628 | "columns": 0, 629 | "depends_on": "eval:(doc.use_script === 0 && doc.use_function ===0)", 630 | "description": "NOTE :- Link and Table field will not auto-set and will be left blank if not set here", 631 | "fetch_if_empty": 0, 632 | "fieldname": "docfield_value", 633 | "fieldtype": "Table", 634 | "hidden": 0, 635 | "ignore_user_permissions": 0, 636 | "ignore_xss_filter": 0, 637 | "in_filter": 0, 638 | "in_global_search": 0, 639 | "in_list_view": 0, 640 | "in_standard_filter": 0, 641 | "label": "Test Data", 642 | "length": 0, 643 | "no_copy": 0, 644 | "options": "Testdatafield", 645 | "permlevel": 0, 646 | "precision": "", 647 | "print_hide": 0, 648 | "print_hide_if_no_value": 0, 649 | "read_only": 0, 650 | "remember_last_selected_value": 0, 651 | "report_hide": 0, 652 | "reqd": 0, 653 | "search_index": 0, 654 | "set_only_once": 0, 655 | "translatable": 0, 656 | "unique": 0 657 | } 658 | ], 659 | "has_web_view": 0, 660 | "hide_heading": 0, 661 | "hide_toolbar": 0, 662 | "idx": 0, 663 | "image_view": 0, 664 | "in_create": 0, 665 | "is_submittable": 0, 666 | "issingle": 0, 667 | "istable": 0, 668 | "max_attachments": 0, 669 | "modified": "2020-05-14 19:41:07.706409", 670 | "modified_by": "Administrator", 671 | "module": "Barista", 672 | "name": "Test Data", 673 | "name_case": "", 674 | "owner": "Administrator", 675 | "permissions": [ 676 | { 677 | "amend": 0, 678 | "cancel": 0, 679 | "create": 1, 680 | "delete": 1, 681 | "email": 1, 682 | "export": 1, 683 | "if_owner": 0, 684 | "import": 0, 685 | "permlevel": 0, 686 | "print": 1, 687 | "read": 1, 688 | "report": 1, 689 | "role": "System Manager", 690 | "set_user_permissions": 0, 691 | "share": 1, 692 | "submit": 0, 693 | "write": 1 694 | } 695 | ], 696 | "quick_entry": 0, 697 | "read_only": 0, 698 | "read_only_onload": 0, 699 | "search_fields": "doctype_name,description,use_script", 700 | "show_name_in_global_search": 0, 701 | "sort_field": "modified", 702 | "sort_order": "DESC", 703 | "track_changes": 1, 704 | "track_seen": 0, 705 | "track_views": 0 706 | } -------------------------------------------------------------------------------- /barista/barista/doctype/test_data/test_data.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | import ast 9 | import json 10 | import requests 11 | import urllib3 12 | import re 13 | import math 14 | import difflib 15 | import base64 16 | import operator 17 | import copy 18 | import traceback 19 | import urllib 20 | import ssl 21 | import binascii 22 | import six 23 | import html.parser 24 | import os 25 | import bs4 26 | import sys 27 | import pymysql 28 | import html2text 29 | import warnings 30 | import markdown2 31 | import csv 32 | import calendar 33 | import unittest 34 | import random 35 | import datetime 36 | import dateutil 37 | 38 | 39 | class TestData(Document): 40 | def validate(self): 41 | docfields = [docfield.fieldname for docfield in frappe.get_meta( 42 | self.doctype_name).fields] 43 | docfields.append('docstatus') 44 | docfields.append('name') 45 | docfields.append('parent') 46 | 47 | for row in self.docfield_value: 48 | if row.docfield_fieldname not in docfields: 49 | frappe.throw( 50 | f"Invalid DocField {row.docfield_fieldname} in {self.doctype_name}") 51 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_data/test_data_dashboard.py: -------------------------------------------------------------------------------- 1 | from frappe import _ 2 | 3 | 4 | def get_data(): 5 | return { 6 | 'fieldname': 'test_data', 7 | 'non_standard_fieldnames': { 8 | 'Test Case': 'test_data', 9 | 'Test Result': 'test_data_id', 10 | }, 11 | 'internal_links': { 12 | 13 | }, 14 | 'transactions': [ 15 | { 16 | 'items': ['Test Case', 'Test Run Log'], 17 | }, 18 | { 19 | 'items': ['Test Result'] 20 | }, 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_data/test_test_data.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | // rename this file from _test_[name] to test_[name] to activate 3 | // and remove above this line 4 | 5 | QUnit.test("test: Test Data", function (assert) { 6 | let done = assert.async(); 7 | 8 | // number of asserts 9 | assert.expect(1); 10 | 11 | frappe.run_serially([ 12 | // insert a new Test Data 13 | () => frappe.tests.make('Test Data', [ 14 | // values to be set 15 | {key: 'value'} 16 | ]), 17 | () => { 18 | assert.equal(cur_frm.doc.key, 'value'); 19 | }, 20 | () => done() 21 | ]); 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_data/test_test_data.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and Contributors 3 | # See license.txt 4 | from __future__ import unicode_literals 5 | 6 | import frappe 7 | import unittest 8 | 9 | class TestTestData(unittest.TestCase): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_result/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/test_result/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/test_result/test_result.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, elasticrun and contributors 2 | // For license information, please see license.txt 3 | 4 | frappe.ui.form.on('Test Result', { 5 | refresh: function(frm) { 6 | 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_result/test_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 0, 7 | "autoname": "TestResult-.#####", 8 | "beta": 0, 9 | "creation": "2019-12-17 19:57:59.557611", 10 | "custom": 0, 11 | "docstatus": 0, 12 | "doctype": "DocType", 13 | "document_type": "", 14 | "editable_grid": 1, 15 | "engine": "InnoDB", 16 | "fields": [ 17 | { 18 | "allow_bulk_edit": 0, 19 | "allow_in_quick_entry": 0, 20 | "allow_on_submit": 0, 21 | "bold": 0, 22 | "collapsible": 0, 23 | "columns": 0, 24 | "fetch_if_empty": 0, 25 | "fieldname": "test_run_name", 26 | "fieldtype": "Data", 27 | "hidden": 0, 28 | "ignore_user_permissions": 0, 29 | "ignore_xss_filter": 0, 30 | "in_filter": 0, 31 | "in_global_search": 0, 32 | "in_list_view": 0, 33 | "in_standard_filter": 1, 34 | "label": "Test Run Name", 35 | "length": 0, 36 | "no_copy": 0, 37 | "options": "", 38 | "permlevel": 0, 39 | "precision": "", 40 | "print_hide": 0, 41 | "print_hide_if_no_value": 0, 42 | "read_only": 1, 43 | "remember_last_selected_value": 0, 44 | "report_hide": 0, 45 | "reqd": 0, 46 | "search_index": 0, 47 | "set_only_once": 0, 48 | "translatable": 0, 49 | "unique": 0 50 | }, 51 | { 52 | "allow_bulk_edit": 0, 53 | "allow_in_quick_entry": 0, 54 | "allow_on_submit": 0, 55 | "bold": 0, 56 | "collapsible": 0, 57 | "columns": 0, 58 | "fetch_if_empty": 0, 59 | "fieldname": "action", 60 | "fieldtype": "Select", 61 | "hidden": 0, 62 | "ignore_user_permissions": 0, 63 | "ignore_xss_filter": 0, 64 | "in_filter": 0, 65 | "in_global_search": 0, 66 | "in_list_view": 0, 67 | "in_standard_filter": 0, 68 | "label": "Action", 69 | "length": 0, 70 | "no_copy": 0, 71 | "options": "Initial Data Setup\nTest Case", 72 | "permlevel": 0, 73 | "precision": "", 74 | "print_hide": 0, 75 | "print_hide_if_no_value": 0, 76 | "read_only": 1, 77 | "remember_last_selected_value": 0, 78 | "report_hide": 0, 79 | "reqd": 0, 80 | "search_index": 0, 81 | "set_only_once": 0, 82 | "translatable": 0, 83 | "unique": 0 84 | }, 85 | { 86 | "allow_bulk_edit": 0, 87 | "allow_in_quick_entry": 0, 88 | "allow_on_submit": 0, 89 | "bold": 0, 90 | "collapsible": 0, 91 | "columns": 0, 92 | "fetch_if_empty": 0, 93 | "fieldname": "column_break_2", 94 | "fieldtype": "Column Break", 95 | "hidden": 0, 96 | "ignore_user_permissions": 0, 97 | "ignore_xss_filter": 0, 98 | "in_filter": 0, 99 | "in_global_search": 0, 100 | "in_list_view": 0, 101 | "in_standard_filter": 0, 102 | "length": 0, 103 | "no_copy": 0, 104 | "permlevel": 0, 105 | "precision": "", 106 | "print_hide": 0, 107 | "print_hide_if_no_value": 0, 108 | "read_only": 0, 109 | "remember_last_selected_value": 0, 110 | "report_hide": 0, 111 | "reqd": 0, 112 | "search_index": 0, 113 | "set_only_once": 0, 114 | "translatable": 0, 115 | "unique": 0 116 | }, 117 | { 118 | "allow_bulk_edit": 0, 119 | "allow_in_quick_entry": 0, 120 | "allow_on_submit": 0, 121 | "bold": 0, 122 | "collapsible": 0, 123 | "columns": 0, 124 | "fetch_if_empty": 0, 125 | "fieldname": "test_suite", 126 | "fieldtype": "Link", 127 | "hidden": 0, 128 | "ignore_user_permissions": 0, 129 | "ignore_xss_filter": 0, 130 | "in_filter": 0, 131 | "in_global_search": 0, 132 | "in_list_view": 0, 133 | "in_standard_filter": 1, 134 | "label": "Test Suite", 135 | "length": 0, 136 | "no_copy": 0, 137 | "options": "Test Suite", 138 | "permlevel": 0, 139 | "precision": "", 140 | "print_hide": 0, 141 | "print_hide_if_no_value": 0, 142 | "read_only": 1, 143 | "remember_last_selected_value": 0, 144 | "report_hide": 0, 145 | "reqd": 0, 146 | "search_index": 0, 147 | "set_only_once": 0, 148 | "translatable": 0, 149 | "unique": 0 150 | }, 151 | { 152 | "allow_bulk_edit": 0, 153 | "allow_in_quick_entry": 0, 154 | "allow_on_submit": 0, 155 | "bold": 0, 156 | "collapsible": 0, 157 | "columns": 0, 158 | "fetch_if_empty": 0, 159 | "fieldname": "section_break_3", 160 | "fieldtype": "Section Break", 161 | "hidden": 0, 162 | "ignore_user_permissions": 0, 163 | "ignore_xss_filter": 0, 164 | "in_filter": 0, 165 | "in_global_search": 0, 166 | "in_list_view": 0, 167 | "in_standard_filter": 0, 168 | "length": 0, 169 | "no_copy": 0, 170 | "permlevel": 0, 171 | "precision": "", 172 | "print_hide": 0, 173 | "print_hide_if_no_value": 0, 174 | "read_only": 0, 175 | "remember_last_selected_value": 0, 176 | "report_hide": 0, 177 | "reqd": 0, 178 | "search_index": 0, 179 | "set_only_once": 0, 180 | "translatable": 0, 181 | "unique": 0 182 | }, 183 | { 184 | "allow_bulk_edit": 0, 185 | "allow_in_quick_entry": 0, 186 | "allow_on_submit": 0, 187 | "bold": 0, 188 | "collapsible": 0, 189 | "columns": 0, 190 | "fetch_if_empty": 0, 191 | "fieldname": "test_data_id", 192 | "fieldtype": "Link", 193 | "hidden": 0, 194 | "ignore_user_permissions": 0, 195 | "ignore_xss_filter": 0, 196 | "in_filter": 0, 197 | "in_global_search": 0, 198 | "in_list_view": 0, 199 | "in_standard_filter": 0, 200 | "label": "Test Data id", 201 | "length": 0, 202 | "no_copy": 0, 203 | "options": "Test Data", 204 | "permlevel": 0, 205 | "precision": "", 206 | "print_hide": 0, 207 | "print_hide_if_no_value": 0, 208 | "read_only": 1, 209 | "remember_last_selected_value": 0, 210 | "report_hide": 0, 211 | "reqd": 0, 212 | "search_index": 0, 213 | "set_only_once": 0, 214 | "translatable": 0, 215 | "unique": 0 216 | }, 217 | { 218 | "allow_bulk_edit": 0, 219 | "allow_in_quick_entry": 0, 220 | "allow_on_submit": 0, 221 | "bold": 0, 222 | "collapsible": 0, 223 | "columns": 0, 224 | "fetch_if_empty": 0, 225 | "fieldname": "test_case", 226 | "fieldtype": "Link", 227 | "hidden": 0, 228 | "ignore_user_permissions": 0, 229 | "ignore_xss_filter": 0, 230 | "in_filter": 0, 231 | "in_global_search": 0, 232 | "in_list_view": 0, 233 | "in_standard_filter": 0, 234 | "label": "Test Case", 235 | "length": 0, 236 | "no_copy": 0, 237 | "options": "Test Case", 238 | "permlevel": 0, 239 | "precision": "", 240 | "print_hide": 0, 241 | "print_hide_if_no_value": 0, 242 | "read_only": 1, 243 | "remember_last_selected_value": 0, 244 | "report_hide": 0, 245 | "reqd": 0, 246 | "search_index": 0, 247 | "set_only_once": 0, 248 | "translatable": 0, 249 | "unique": 0 250 | }, 251 | { 252 | "allow_bulk_edit": 0, 253 | "allow_in_quick_entry": 0, 254 | "allow_on_submit": 0, 255 | "bold": 0, 256 | "collapsible": 0, 257 | "columns": 0, 258 | "fetch_from": "test_case.testcase_name", 259 | "fetch_if_empty": 1, 260 | "fieldname": "test_case_name", 261 | "fieldtype": "Data", 262 | "hidden": 0, 263 | "ignore_user_permissions": 0, 264 | "ignore_xss_filter": 0, 265 | "in_filter": 0, 266 | "in_global_search": 0, 267 | "in_list_view": 1, 268 | "in_standard_filter": 0, 269 | "label": "Test Case Name", 270 | "length": 0, 271 | "no_copy": 0, 272 | "permlevel": 0, 273 | "precision": "", 274 | "print_hide": 0, 275 | "print_hide_if_no_value": 0, 276 | "read_only": 1, 277 | "remember_last_selected_value": 0, 278 | "report_hide": 0, 279 | "reqd": 0, 280 | "search_index": 0, 281 | "set_only_once": 0, 282 | "translatable": 0, 283 | "unique": 0 284 | }, 285 | { 286 | "allow_bulk_edit": 0, 287 | "allow_in_quick_entry": 0, 288 | "allow_on_submit": 0, 289 | "bold": 0, 290 | "collapsible": 0, 291 | "columns": 0, 292 | "fetch_if_empty": 0, 293 | "fieldname": "test_case_execution", 294 | "fieldtype": "Select", 295 | "hidden": 0, 296 | "ignore_user_permissions": 0, 297 | "ignore_xss_filter": 0, 298 | "in_filter": 0, 299 | "in_global_search": 0, 300 | "in_list_view": 1, 301 | "in_standard_filter": 0, 302 | "label": "Execution Status", 303 | "length": 0, 304 | "no_copy": 0, 305 | "options": "Pending\nExecuted\nExecution Failed", 306 | "permlevel": 0, 307 | "precision": "", 308 | "print_hide": 0, 309 | "print_hide_if_no_value": 0, 310 | "read_only": 1, 311 | "remember_last_selected_value": 0, 312 | "report_hide": 0, 313 | "reqd": 0, 314 | "search_index": 0, 315 | "set_only_once": 0, 316 | "translatable": 0, 317 | "unique": 0 318 | }, 319 | { 320 | "allow_bulk_edit": 0, 321 | "allow_in_quick_entry": 0, 322 | "allow_on_submit": 0, 323 | "bold": 0, 324 | "collapsible": 0, 325 | "columns": 0, 326 | "fetch_if_empty": 0, 327 | "fieldname": "column_break_4", 328 | "fieldtype": "Column Break", 329 | "hidden": 0, 330 | "ignore_user_permissions": 0, 331 | "ignore_xss_filter": 0, 332 | "in_filter": 0, 333 | "in_global_search": 0, 334 | "in_list_view": 0, 335 | "in_standard_filter": 0, 336 | "length": 0, 337 | "no_copy": 0, 338 | "permlevel": 0, 339 | "precision": "", 340 | "print_hide": 0, 341 | "print_hide_if_no_value": 0, 342 | "read_only": 0, 343 | "remember_last_selected_value": 0, 344 | "report_hide": 0, 345 | "reqd": 0, 346 | "search_index": 0, 347 | "set_only_once": 0, 348 | "translatable": 0, 349 | "unique": 0 350 | }, 351 | { 352 | "allow_bulk_edit": 0, 353 | "allow_in_quick_entry": 0, 354 | "allow_on_submit": 0, 355 | "bold": 0, 356 | "collapsible": 0, 357 | "columns": 0, 358 | "fetch_if_empty": 0, 359 | "fieldname": "test_data_status", 360 | "fieldtype": "Select", 361 | "hidden": 0, 362 | "ignore_user_permissions": 0, 363 | "ignore_xss_filter": 0, 364 | "in_filter": 0, 365 | "in_global_search": 0, 366 | "in_list_view": 0, 367 | "in_standard_filter": 0, 368 | "label": "Test Data Status", 369 | "length": 0, 370 | "no_copy": 0, 371 | "options": "Successful\nFailed\nPending", 372 | "permlevel": 0, 373 | "precision": "", 374 | "print_hide": 0, 375 | "print_hide_if_no_value": 0, 376 | "read_only": 1, 377 | "remember_last_selected_value": 0, 378 | "report_hide": 0, 379 | "reqd": 0, 380 | "search_index": 0, 381 | "set_only_once": 0, 382 | "translatable": 0, 383 | "unique": 0 384 | }, 385 | { 386 | "allow_bulk_edit": 0, 387 | "allow_in_quick_entry": 0, 388 | "allow_on_submit": 0, 389 | "bold": 0, 390 | "collapsible": 0, 391 | "columns": 0, 392 | "default": "Failed", 393 | "fetch_if_empty": 0, 394 | "fieldname": "test_case_status", 395 | "fieldtype": "Select", 396 | "hidden": 0, 397 | "ignore_user_permissions": 0, 398 | "ignore_xss_filter": 0, 399 | "in_filter": 0, 400 | "in_global_search": 0, 401 | "in_list_view": 1, 402 | "in_standard_filter": 1, 403 | "label": "Test Case Status", 404 | "length": 0, 405 | "no_copy": 0, 406 | "options": "Pending\nPassed\nFailed", 407 | "permlevel": 0, 408 | "precision": "", 409 | "print_hide": 0, 410 | "print_hide_if_no_value": 0, 411 | "read_only": 1, 412 | "remember_last_selected_value": 0, 413 | "report_hide": 0, 414 | "reqd": 0, 415 | "search_index": 0, 416 | "set_only_once": 0, 417 | "translatable": 0, 418 | "unique": 0 419 | }, 420 | { 421 | "allow_bulk_edit": 0, 422 | "allow_in_quick_entry": 0, 423 | "allow_on_submit": 0, 424 | "bold": 0, 425 | "collapsible": 0, 426 | "columns": 0, 427 | "fetch_from": "test_case.testcase_desc", 428 | "fetch_if_empty": 1, 429 | "fieldname": "test_case_desc", 430 | "fieldtype": "Data", 431 | "hidden": 0, 432 | "ignore_user_permissions": 0, 433 | "ignore_xss_filter": 0, 434 | "in_filter": 0, 435 | "in_global_search": 0, 436 | "in_list_view": 0, 437 | "in_standard_filter": 0, 438 | "label": "Test Case Description", 439 | "length": 0, 440 | "no_copy": 0, 441 | "permlevel": 0, 442 | "precision": "", 443 | "print_hide": 0, 444 | "print_hide_if_no_value": 0, 445 | "read_only": 1, 446 | "remember_last_selected_value": 0, 447 | "report_hide": 0, 448 | "reqd": 0, 449 | "search_index": 0, 450 | "set_only_once": 0, 451 | "translatable": 0, 452 | "unique": 0 453 | }, 454 | { 455 | "allow_bulk_edit": 0, 456 | "allow_in_quick_entry": 0, 457 | "allow_on_submit": 0, 458 | "bold": 0, 459 | "collapsible": 0, 460 | "columns": 0, 461 | "fetch_if_empty": 0, 462 | "fieldname": "execution_time", 463 | "fieldtype": "Data", 464 | "hidden": 0, 465 | "ignore_user_permissions": 0, 466 | "ignore_xss_filter": 0, 467 | "in_filter": 0, 468 | "in_global_search": 0, 469 | "in_list_view": 0, 470 | "in_standard_filter": 0, 471 | "label": "Execution Time", 472 | "length": 0, 473 | "no_copy": 0, 474 | "permlevel": 0, 475 | "precision": "", 476 | "print_hide": 0, 477 | "print_hide_if_no_value": 0, 478 | "read_only": 1, 479 | "remember_last_selected_value": 0, 480 | "report_hide": 0, 481 | "reqd": 0, 482 | "search_index": 0, 483 | "set_only_once": 0, 484 | "translatable": 0, 485 | "unique": 0 486 | }, 487 | { 488 | "allow_bulk_edit": 0, 489 | "allow_in_quick_entry": 0, 490 | "allow_on_submit": 0, 491 | "bold": 0, 492 | "collapsible": 0, 493 | "columns": 0, 494 | "fetch_if_empty": 0, 495 | "fieldname": "section_break_13", 496 | "fieldtype": "Section Break", 497 | "hidden": 0, 498 | "ignore_user_permissions": 0, 499 | "ignore_xss_filter": 0, 500 | "in_filter": 0, 501 | "in_global_search": 0, 502 | "in_list_view": 0, 503 | "in_standard_filter": 0, 504 | "length": 0, 505 | "no_copy": 0, 506 | "permlevel": 0, 507 | "precision": "", 508 | "print_hide": 0, 509 | "print_hide_if_no_value": 0, 510 | "read_only": 0, 511 | "remember_last_selected_value": 0, 512 | "report_hide": 0, 513 | "reqd": 0, 514 | "search_index": 0, 515 | "set_only_once": 0, 516 | "translatable": 0, 517 | "unique": 0 518 | }, 519 | { 520 | "allow_bulk_edit": 0, 521 | "allow_in_quick_entry": 0, 522 | "allow_on_submit": 0, 523 | "bold": 0, 524 | "collapsible": 0, 525 | "columns": 0, 526 | "fetch_if_empty": 0, 527 | "fieldname": "execution_result", 528 | "fieldtype": "Code", 529 | "hidden": 0, 530 | "ignore_user_permissions": 0, 531 | "ignore_xss_filter": 0, 532 | "in_filter": 0, 533 | "in_global_search": 0, 534 | "in_list_view": 0, 535 | "in_standard_filter": 0, 536 | "label": "Execution Result", 537 | "length": 0, 538 | "no_copy": 0, 539 | "permlevel": 0, 540 | "precision": "", 541 | "print_hide": 0, 542 | "print_hide_if_no_value": 0, 543 | "read_only": 1, 544 | "remember_last_selected_value": 0, 545 | "report_hide": 0, 546 | "reqd": 0, 547 | "search_index": 0, 548 | "set_only_once": 0, 549 | "translatable": 0, 550 | "unique": 0 551 | }, 552 | { 553 | "allow_bulk_edit": 0, 554 | "allow_in_quick_entry": 0, 555 | "allow_on_submit": 0, 556 | "bold": 0, 557 | "collapsible": 0, 558 | "columns": 0, 559 | "fetch_if_empty": 0, 560 | "fieldname": "assertion_results", 561 | "fieldtype": "Table", 562 | "hidden": 0, 563 | "ignore_user_permissions": 0, 564 | "ignore_xss_filter": 0, 565 | "in_filter": 0, 566 | "in_global_search": 0, 567 | "in_list_view": 0, 568 | "in_standard_filter": 0, 569 | "label": "Assertion Results", 570 | "length": 0, 571 | "no_copy": 0, 572 | "options": "Assertion Result", 573 | "permlevel": 0, 574 | "precision": "", 575 | "print_hide": 0, 576 | "print_hide_if_no_value": 0, 577 | "read_only": 1, 578 | "remember_last_selected_value": 0, 579 | "report_hide": 0, 580 | "reqd": 0, 581 | "search_index": 0, 582 | "set_only_once": 0, 583 | "translatable": 0, 584 | "unique": 0 585 | } 586 | ], 587 | "has_web_view": 0, 588 | "hide_heading": 0, 589 | "hide_toolbar": 0, 590 | "idx": 0, 591 | "image_view": 0, 592 | "in_create": 0, 593 | "is_submittable": 0, 594 | "issingle": 0, 595 | "istable": 0, 596 | "max_attachments": 0, 597 | "modified": "2020-05-12 01:05:04.919740", 598 | "modified_by": "Administrator", 599 | "module": "Barista", 600 | "name": "Test Result", 601 | "name_case": "", 602 | "owner": "Administrator", 603 | "permissions": [ 604 | { 605 | "amend": 0, 606 | "cancel": 0, 607 | "create": 1, 608 | "delete": 1, 609 | "email": 1, 610 | "export": 1, 611 | "if_owner": 0, 612 | "import": 0, 613 | "permlevel": 0, 614 | "print": 1, 615 | "read": 1, 616 | "report": 1, 617 | "role": "System Manager", 618 | "set_user_permissions": 0, 619 | "share": 1, 620 | "submit": 0, 621 | "write": 1 622 | } 623 | ], 624 | "quick_entry": 1, 625 | "read_only": 0, 626 | "read_only_onload": 0, 627 | "show_name_in_global_search": 0, 628 | "sort_field": "modified", 629 | "sort_order": "DESC", 630 | "track_changes": 1, 631 | "track_seen": 0, 632 | "track_views": 0 633 | } -------------------------------------------------------------------------------- /barista/barista/doctype/test_result/test_result.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | 9 | class TestResult(Document): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_result/test_test_result.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | // rename this file from _test_[name] to test_[name] to activate 3 | // and remove above this line 4 | 5 | QUnit.test("test: Test Result", function (assert) { 6 | let done = assert.async(); 7 | 8 | // number of asserts 9 | assert.expect(1); 10 | 11 | frappe.run_serially([ 12 | // insert a new Test Result 13 | () => frappe.tests.make('Test Result', [ 14 | // values to be set 15 | {key: 'value'} 16 | ]), 17 | () => { 18 | assert.equal(cur_frm.doc.key, 'value'); 19 | }, 20 | () => done() 21 | ]); 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_result/test_test_result.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and Contributors 3 | # See license.txt 4 | from __future__ import unicode_literals 5 | 6 | import frappe 7 | import unittest 8 | 9 | class TestTestResult(unittest.TestCase): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_run_log/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/test_run_log/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/test_run_log/test_run_log.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, elasticrun and contributors 2 | // For license information, please see license.txt 3 | 4 | frappe.ui.form.on('Test Run', { 5 | refresh: function(frm) { 6 | 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_run_log/test_run_log.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 0, 7 | "autoname": "TRL-.#####", 8 | "beta": 0, 9 | "creation": "2020-05-07 13:07:25.657233", 10 | "custom": 0, 11 | "docstatus": 0, 12 | "doctype": "DocType", 13 | "document_type": "", 14 | "editable_grid": 1, 15 | "engine": "InnoDB", 16 | "fields": [ 17 | { 18 | "allow_bulk_edit": 0, 19 | "allow_in_quick_entry": 0, 20 | "allow_on_submit": 0, 21 | "bold": 0, 22 | "collapsible": 0, 23 | "columns": 0, 24 | "fetch_if_empty": 0, 25 | "fieldname": "test_run_name", 26 | "fieldtype": "Data", 27 | "hidden": 0, 28 | "ignore_user_permissions": 0, 29 | "ignore_xss_filter": 0, 30 | "in_filter": 0, 31 | "in_global_search": 0, 32 | "in_list_view": 1, 33 | "in_standard_filter": 1, 34 | "label": "Test Run Name", 35 | "length": 0, 36 | "no_copy": 0, 37 | "permlevel": 0, 38 | "precision": "", 39 | "print_hide": 0, 40 | "print_hide_if_no_value": 0, 41 | "read_only": 1, 42 | "remember_last_selected_value": 0, 43 | "report_hide": 0, 44 | "reqd": 1, 45 | "search_index": 0, 46 | "set_only_once": 0, 47 | "translatable": 0, 48 | "unique": 0 49 | }, 50 | { 51 | "allow_bulk_edit": 0, 52 | "allow_in_quick_entry": 0, 53 | "allow_on_submit": 0, 54 | "bold": 0, 55 | "collapsible": 0, 56 | "columns": 0, 57 | "fetch_if_empty": 0, 58 | "fieldname": "section_break_2", 59 | "fieldtype": "Section Break", 60 | "hidden": 0, 61 | "ignore_user_permissions": 0, 62 | "ignore_xss_filter": 0, 63 | "in_filter": 0, 64 | "in_global_search": 0, 65 | "in_list_view": 0, 66 | "in_standard_filter": 0, 67 | "length": 0, 68 | "no_copy": 0, 69 | "permlevel": 0, 70 | "precision": "", 71 | "print_hide": 0, 72 | "print_hide_if_no_value": 0, 73 | "read_only": 0, 74 | "remember_last_selected_value": 0, 75 | "report_hide": 0, 76 | "reqd": 0, 77 | "search_index": 0, 78 | "set_only_once": 0, 79 | "translatable": 0, 80 | "unique": 0 81 | }, 82 | { 83 | "allow_bulk_edit": 0, 84 | "allow_in_quick_entry": 0, 85 | "allow_on_submit": 0, 86 | "bold": 0, 87 | "collapsible": 0, 88 | "columns": 0, 89 | "fetch_if_empty": 0, 90 | "fieldname": "test_data", 91 | "fieldtype": "Link", 92 | "hidden": 0, 93 | "ignore_user_permissions": 0, 94 | "ignore_xss_filter": 0, 95 | "in_filter": 0, 96 | "in_global_search": 0, 97 | "in_list_view": 1, 98 | "in_standard_filter": 1, 99 | "label": "Test Data", 100 | "length": 0, 101 | "no_copy": 0, 102 | "options": "Test Data", 103 | "permlevel": 0, 104 | "precision": "", 105 | "print_hide": 0, 106 | "print_hide_if_no_value": 0, 107 | "read_only": 1, 108 | "remember_last_selected_value": 0, 109 | "report_hide": 0, 110 | "reqd": 1, 111 | "search_index": 0, 112 | "set_only_once": 0, 113 | "translatable": 0, 114 | "unique": 0 115 | }, 116 | { 117 | "allow_bulk_edit": 0, 118 | "allow_in_quick_entry": 0, 119 | "allow_on_submit": 0, 120 | "bold": 0, 121 | "collapsible": 0, 122 | "columns": 0, 123 | "fetch_from": "", 124 | "fetch_if_empty": 0, 125 | "fieldname": "test_data_status", 126 | "fieldtype": "Select", 127 | "hidden": 0, 128 | "ignore_user_permissions": 0, 129 | "ignore_xss_filter": 0, 130 | "in_filter": 0, 131 | "in_global_search": 0, 132 | "in_list_view": 0, 133 | "in_standard_filter": 1, 134 | "label": "Test Data Status", 135 | "length": 0, 136 | "no_copy": 0, 137 | "options": "Created\nFailed", 138 | "permlevel": 0, 139 | "precision": "", 140 | "print_hide": 0, 141 | "print_hide_if_no_value": 0, 142 | "read_only": 1, 143 | "remember_last_selected_value": 0, 144 | "report_hide": 0, 145 | "reqd": 1, 146 | "search_index": 0, 147 | "set_only_once": 0, 148 | "translatable": 0, 149 | "unique": 0 150 | }, 151 | { 152 | "allow_bulk_edit": 0, 153 | "allow_in_quick_entry": 0, 154 | "allow_on_submit": 0, 155 | "bold": 0, 156 | "collapsible": 0, 157 | "columns": 0, 158 | "fetch_if_empty": 0, 159 | "fieldname": "column_break_3", 160 | "fieldtype": "Column Break", 161 | "hidden": 0, 162 | "ignore_user_permissions": 0, 163 | "ignore_xss_filter": 0, 164 | "in_filter": 0, 165 | "in_global_search": 0, 166 | "in_list_view": 0, 167 | "in_standard_filter": 0, 168 | "length": 0, 169 | "no_copy": 0, 170 | "permlevel": 0, 171 | "precision": "", 172 | "print_hide": 0, 173 | "print_hide_if_no_value": 0, 174 | "read_only": 0, 175 | "remember_last_selected_value": 0, 176 | "report_hide": 0, 177 | "reqd": 0, 178 | "search_index": 0, 179 | "set_only_once": 0, 180 | "translatable": 0, 181 | "unique": 0 182 | }, 183 | { 184 | "allow_bulk_edit": 0, 185 | "allow_in_quick_entry": 0, 186 | "allow_on_submit": 0, 187 | "bold": 0, 188 | "collapsible": 0, 189 | "columns": 0, 190 | "fetch_from": "test_data.doctype_name", 191 | "fetch_if_empty": 1, 192 | "fieldname": "test_data_doctype", 193 | "fieldtype": "Link", 194 | "hidden": 0, 195 | "ignore_user_permissions": 0, 196 | "ignore_xss_filter": 0, 197 | "in_filter": 0, 198 | "in_global_search": 0, 199 | "in_list_view": 1, 200 | "in_standard_filter": 1, 201 | "label": "Test Data DocType", 202 | "length": 0, 203 | "no_copy": 0, 204 | "options": "DocType", 205 | "permlevel": 0, 206 | "precision": "", 207 | "print_hide": 0, 208 | "print_hide_if_no_value": 0, 209 | "read_only": 1, 210 | "remember_last_selected_value": 0, 211 | "report_hide": 0, 212 | "reqd": 0, 213 | "search_index": 0, 214 | "set_only_once": 0, 215 | "translatable": 0, 216 | "unique": 0 217 | }, 218 | { 219 | "allow_bulk_edit": 0, 220 | "allow_in_quick_entry": 0, 221 | "allow_on_submit": 0, 222 | "bold": 0, 223 | "collapsible": 0, 224 | "columns": 0, 225 | "fetch_from": "", 226 | "fetch_if_empty": 0, 227 | "fieldname": "test_record", 228 | "fieldtype": "Dynamic Link", 229 | "hidden": 0, 230 | "ignore_user_permissions": 0, 231 | "ignore_xss_filter": 0, 232 | "in_filter": 0, 233 | "in_global_search": 0, 234 | "in_list_view": 1, 235 | "in_standard_filter": 1, 236 | "label": "Test Record", 237 | "length": 0, 238 | "no_copy": 0, 239 | "options": "test_data_doctype", 240 | "permlevel": 0, 241 | "precision": "", 242 | "print_hide": 0, 243 | "print_hide_if_no_value": 0, 244 | "read_only": 1, 245 | "remember_last_selected_value": 0, 246 | "report_hide": 0, 247 | "reqd": 0, 248 | "search_index": 0, 249 | "set_only_once": 0, 250 | "translatable": 0, 251 | "unique": 0 252 | } 253 | ], 254 | "has_web_view": 0, 255 | "hide_heading": 0, 256 | "hide_toolbar": 0, 257 | "idx": 0, 258 | "image_view": 0, 259 | "in_create": 0, 260 | "is_submittable": 0, 261 | "issingle": 0, 262 | "istable": 0, 263 | "max_attachments": 0, 264 | "modified": "2020-05-14 15:11:31.128590", 265 | "modified_by": "Administrator", 266 | "module": "Barista", 267 | "name": "Test Run Log", 268 | "name_case": "", 269 | "owner": "Administrator", 270 | "permissions": [ 271 | { 272 | "amend": 0, 273 | "cancel": 0, 274 | "create": 1, 275 | "delete": 1, 276 | "email": 1, 277 | "export": 1, 278 | "if_owner": 0, 279 | "import": 0, 280 | "permlevel": 0, 281 | "print": 1, 282 | "read": 1, 283 | "report": 1, 284 | "role": "System Manager", 285 | "set_user_permissions": 0, 286 | "share": 1, 287 | "submit": 0, 288 | "write": 1 289 | } 290 | ], 291 | "quick_entry": 0, 292 | "read_only": 0, 293 | "read_only_onload": 0, 294 | "show_name_in_global_search": 0, 295 | "sort_field": "modified", 296 | "sort_order": "DESC", 297 | "track_changes": 1, 298 | "track_seen": 0, 299 | "track_views": 0 300 | } -------------------------------------------------------------------------------- /barista/barista/doctype/test_run_log/test_run_log.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2020, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | 9 | class TestRunLog(Document): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_run_log/test_run_log_dashboard.py: -------------------------------------------------------------------------------- 1 | from frappe import _ 2 | 3 | 4 | def get_data(): 5 | return { 6 | 'fieldname': 'test_run_name', 7 | 'non_standard_fieldnames': { 8 | 'Test Result': 'test_run_name' 9 | }, 10 | 'internal_links': { 11 | 12 | }, 13 | 'transactions': [ 14 | { 15 | 'items': [] 16 | }, 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_run_log/test_test_run_log.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | // rename this file from _test_[name] to test_[name] to activate 3 | // and remove above this line 4 | 5 | QUnit.test("test: Test Run", function (assert) { 6 | let done = assert.async(); 7 | 8 | // number of asserts 9 | assert.expect(1); 10 | 11 | frappe.run_serially([ 12 | // insert a new Test Run 13 | () => frappe.tests.make('Test Run', [ 14 | // values to be set 15 | {key: 'value'} 16 | ]), 17 | () => { 18 | assert.equal(cur_frm.doc.key, 'value'); 19 | }, 20 | () => done() 21 | ]); 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_run_log/test_test_run_log.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2020, elasticrun and Contributors 3 | # See license.txt 4 | from __future__ import unicode_literals 5 | 6 | import frappe 7 | import unittest 8 | 9 | class TestTestRun(unittest.TestCase): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_suite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/test_suite/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/test_suite/run_test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | from barista.barista.doctype.test_data.test_data_generator import TestDataGenerator 9 | from frappe.model.workflow import apply_workflow 10 | import coverage 11 | from barista.barista.doctype.test_case.test_case_execution import TestCaseExecution 12 | import time 13 | import shutil 14 | import sqlite3 15 | import click 16 | import sys 17 | import os 18 | from pathlib import Path 19 | from coverage.numbits import register_sqlite_functions 20 | 21 | 22 | error_log_title_len = 1000 23 | 24 | 25 | class RunTest(): 26 | # Run all the suites for the given app 27 | def run_complete_suite(self, app_name, suites=[], run_name=None): 28 | start_time = time.time() 29 | alter_error_log() 30 | print("\033[0;33;93m************ Running all test cases for App - " + 31 | app_name + " *************\n\n") 32 | if len(suites) == 0: 33 | suites = frappe.get_all("Test Suite", filters={ 34 | 'app_name': app_name}, order_by='creation asc') 35 | else: 36 | suite_name = [] 37 | for suite in suites: 38 | suite_name.append({'name': suite}) 39 | suites = suite_name 40 | 41 | run_name_path = run_name.replace(' ', '__').replace('-', '_') 42 | barista_app_path = f"{frappe.get_app_path('barista')}/public/test-coverage/{run_name_path}/" 43 | data_file_path = str(f"{barista_app_path}{app_name}.coverage") 44 | 45 | shutil.rmtree(barista_app_path, ignore_errors=True) 46 | 47 | generatorObj = TestDataGenerator() 48 | objCoverage = coverage.Coverage(source=[frappe.get_app_path( 49 | app_name)], data_file=data_file_path, omit=['*test_*'], config_file=False) 50 | objCoverage.erase() 51 | objCoverage.start() 52 | total_suites = len(suites) 53 | suite_srno = 0 54 | for suite in suites: 55 | suite_srno += 1 56 | print("\033[0;32;92m************ Suite - " + 57 | suite.get('name') + " *************\n\n") 58 | try: 59 | generatorObj.create_pretest_data(suite.get('name'), run_name) 60 | testcases = frappe.get_list('Testcase Item', filters={ 61 | 'parent': suite.get('name')}, fields=["testcase"], order_by="idx") 62 | total_testcases = len(testcases) 63 | testcase_srno = 0 64 | for testcase in testcases: 65 | testcase_srno += 1 66 | self.run_testcase( 67 | testcase, suite, testcase_srno, total_testcases, suite_srno, total_suites, run_name) 68 | 69 | except Exception as e: 70 | frappe.log_error(frappe.get_traceback( 71 | ), ('barista-Suite Execution Failed-'+suite.get('name')+'-'+str(e))[:error_log_title_len]) 72 | print( 73 | "\033[0;31;91mAn Error occurred which will cause false test case result in the suite - " + str(suite.get('name'))) 74 | print("\033[0;31;91m*************ERROR****************") 75 | print( 76 | "\033[0;31;91m The error encountered is - " + str(e) + "\n") 77 | print("\033[0;31;91m*************ERROR****************") 78 | 79 | objCoverage.stop() 80 | objCoverage.save() 81 | #objCoverage.annotate(directory=frappe.get_app_path('barista') + '/public/test-coverage/') 82 | 83 | objCoverage.html_report( 84 | directory=barista_app_path, skip_empty=True, omit=['*test_*']) 85 | 86 | print( 87 | f"\033[0;33;93m************ Execution ends. Verify coverage at - /assets/barista/test-coverage/{run_name_path}/index.html") 88 | 89 | end_time = round(time.time() - start_time, 2) 90 | time_uom = 'seconds' 91 | if(end_time >= 60): 92 | end_time = round(end_time/60, 2) 93 | time_uom = 'minutes' 94 | print("--- Executed in %s %s ---" % (end_time, time_uom)) 95 | 96 | def run_testcase(self, testcase, suite, testcase_srno, total_testcases, suite_srno, total_suites, run_name): 97 | executionObj = TestCaseExecution() 98 | executionObj.run_testcase(testcase['testcase'], suite.get( 99 | 'name'), testcase_srno, total_testcases, suite_srno, total_suites, run_name) 100 | frappe.db.commit() 101 | 102 | def get_executed_lines(self, app_name, file_name): 103 | sql_query_result = [] 104 | try: 105 | barista_app_path = frappe.get_app_path( 106 | 'barista') + '/public/test-coverage/' 107 | data_file_path = str(barista_app_path+app_name+'.coverage') 108 | 109 | def dict_factory(cursor, row): 110 | d = {} 111 | for idx, col in enumerate(cursor.description): 112 | d[col[0]] = row[idx] 113 | return d 114 | 115 | conn = sqlite3.connect(data_file_path) 116 | conn.row_factory = dict_factory 117 | register_sqlite_functions(conn) 118 | c = conn.cursor() 119 | sql_query = """SELECT lb.file_id, 120 | f.path, 121 | lb.numbits 122 | FROM 'line_bits' lb 123 | INNER JOIN 'file' f ON f.id=lb.file_id 124 | WHERE f.path LIKE '%{0}'""".format(file_name) 125 | c.execute(sql_query) 126 | sql_query_result = c.fetchall() 127 | for row in sql_query_result: 128 | if row: 129 | numbits = row.get('numbits') 130 | if numbits: 131 | lines = coverage.numbits.numbits_to_nums(numbits) 132 | row['numbits'] = lines 133 | 134 | conn.commit() 135 | conn.close() 136 | except Exception as e: 137 | frappe.log_error(frappe.get_traceback( 138 | ), ('barista-get_executed_lines-'+str(e))[:error_log_title_len]) 139 | return sql_query_result 140 | 141 | 142 | @frappe.whitelist() 143 | # bench execute barista.barista.doctype.test_suite.run_test.generate_merge_commit_coverage --kwargs "{'app_name':'velocityduos','file_name':'trip.py','new_lines':[]}" 144 | def generate_merge_commit_coverage(app_name, file_name, new_lines): 145 | output = { 146 | 'file_name': file_name, 147 | 'file_path': '', 148 | 'executed_lines': [], 149 | 'missed_lines': [] 150 | } 151 | try: 152 | new_executed_lines = [] 153 | missed_lines = [] 154 | run_test_obj = RunTest() 155 | 156 | if type(new_lines) == str: 157 | new_lines = [int(l) for l in new_lines.split(',')] 158 | 159 | executed_lines = run_test_obj.get_executed_lines(app_name, file_name) 160 | if len(executed_lines) != 0: 161 | record = executed_lines[0] 162 | file_path = record.get('path') 163 | record_file_name = file_path.split('/').pop() 164 | if '/' in file_name: 165 | file_name = file_name.split('/').pop() 166 | if record_file_name == file_name: 167 | output['file_path'] = file_path 168 | executed_lines = record.get('numbits') 169 | new_executed_lines = executed_lines 170 | for line in new_lines: 171 | if line not in executed_lines: 172 | missed_lines.append(line) 173 | for line in missed_lines: 174 | if line in executed_lines: 175 | new_executed_lines.remove(line) 176 | else: 177 | frappe.throw('Multiple files of the same name found.') 178 | 179 | output['executed_lines'] = new_executed_lines 180 | output['missed_lines'] = missed_lines 181 | except Exception as e: 182 | frappe.log_error(frappe.get_traceback( 183 | ), ('barista-generate_merge_commit_coverage-'+str(e))[:error_log_title_len]) 184 | return output 185 | 186 | 187 | @frappe.whitelist() 188 | # barista.barista.doctype.test_suite.run_test.read_file 189 | def read_file(file_path): 190 | lines = [] 191 | try: 192 | opened_file = open(file_path, 'r') 193 | lines = opened_file.readlines() 194 | except Exception: 195 | frappe.log_error(frappe.get_traceback(), 'barista-read_file') 196 | return lines 197 | 198 | 199 | def alter_error_log(): 200 | frappe.db.sql("""UPDATE `tabDocField` 201 | SET fieldtype="Small Text" 202 | WHERE parent= "Error Log" 203 | AND fieldname= "method" 204 | AND label= "Title";""", auto_commit=1) 205 | frappe.db.sql( 206 | """ALTER TABLE `tabError Log` CHANGE `method` `method` text;""", auto_commit=1) 207 | if frappe.conf.get('developer_mode') == 1: 208 | frappe.get_doc('DocType', 'Error Log').save(True) 209 | 210 | 211 | # bench execute barista.barista.doctype.test_suite.run_test.fix_series 212 | def fix_series(): 213 | print('Previous Series-', frappe.db.sql( 214 | """select * from `tabSeries` where name in ('TestData-','TestCase-')""", as_dict=1)) 215 | test_data_series = frappe.db.sql_list( 216 | """select * from `tabSeries` where name='TestData-';""") 217 | max_test_data_series = frappe.db.sql_list( 218 | """select ifnull(max(name),'TestData-0') from `tabTest Data`;""") 219 | if len(max_test_data_series): 220 | max_test_data_series = int(max_test_data_series[0].split('-')[1]) 221 | if len(test_data_series) == 0: 222 | frappe.db.sql( 223 | f"""Insert into `tabSeries` (name,current) values ('TestData-',{max_test_data_series});""", auto_commit=1) 224 | else: 225 | frappe.db.sql( 226 | f"""update `tabSeries` set current={max_test_data_series} where name="TestData-";""", auto_commit=1) 227 | 228 | test_case_series = frappe.db.sql_list( 229 | """select * from `tabSeries` where name='TestCase-';""") 230 | max_test_case_series = frappe.db.sql_list( 231 | """select ifnull(max(name),'TestCase-0') from `tabTest Case`;""") 232 | if len(max_test_case_series): 233 | max_test_case_series = int(max_test_case_series[0].split('-')[1]) 234 | if len(test_case_series) == 0: 235 | frappe.db.sql( 236 | f"""Insert into `tabSeries` (name,current) values ('TestCase-',{max_test_case_series});""", auto_commit=1) 237 | else: 238 | frappe.db.sql( 239 | f"""update `tabSeries` set current={max_test_case_series} where name="TestCase-";""", auto_commit=1) 240 | 241 | print('Current Series-', frappe.db.sql( 242 | """select * from `tabSeries` where name in ('TestData-','TestCase-')""", as_dict=1)) 243 | 244 | 245 | # bench execute barista.barista.doctype.test_suite.run_test.run_test --kwargs "{'app_name':'velocityduos','suites':[]}" 246 | def run_test(app_name, suites=[]): 247 | print(''' 248 | This commmand is deprecated. 249 | ''', end='') 250 | print(''' 251 | Please use bench execute barista.run --kwargs "{'app_name':'velocityduos','suites':[],'reset_testdata':0,'clear_testresult':0,'run_name':'Release 1'}" 252 | ''', end='') 253 | print(''' 254 | app_name is mandatory while all other parameters are optional 255 | ''', end='') 256 | print(''' 257 | You can use bench execute barista.run --kwargs "{'app_name':'velocityduos'}" 258 | ''') 259 | return 260 | # RunTest().run_complete_suite(app_name, suites) 261 | 262 | 263 | def fix_assertion_type_status(): 264 | frappe.db.sql( 265 | "update `tabAssertion` set assertion_type='Field Value' where assertion_type='FIELD VALUE'", auto_commit=1) 266 | frappe.db.sql( 267 | "update `tabAssertion` set assertion_type='Record Validation' where assertion_type='RECORD VALIDATION'", auto_commit=1) 268 | frappe.db.sql( 269 | "update `tabAssertion` set assertion_type='Workflow' where assertion_type='WORKFLOW'", auto_commit=1) 270 | frappe.db.sql( 271 | "update `tabAssertion` set assertion_type='Response' where assertion_type='RESPONSE'", auto_commit=1) 272 | frappe.db.sql( 273 | "update `tabAssertion` set assertion_type='Error' where assertion_type='ERROR'", auto_commit=1) 274 | 275 | 276 | def fix_testcase_type_status(): 277 | frappe.db.sql( 278 | "update `tabTest Case` set testcase_type='Create' where testcase_type='CREATE'", auto_commit=1) 279 | frappe.db.sql( 280 | "update `tabTest Case` set testcase_type='Update' where testcase_type='UPDATE'", auto_commit=1) 281 | frappe.db.sql( 282 | "update `tabTest Case` set testcase_type='Read' where testcase_type='READ'", auto_commit=1) 283 | frappe.db.sql( 284 | "update `tabTest Case` set testcase_type='Delete' where testcase_type='DELETE'", auto_commit=1) 285 | frappe.db.sql( 286 | "update `tabTest Case` set testcase_type='Workflow' where testcase_type='WORKFLOW'", auto_commit=1) 287 | frappe.db.sql( 288 | "update `tabTest Case` set testcase_type='Function' where testcase_type='FUNCTION'", auto_commit=1) 289 | 290 | 291 | def resolve_run_name(run_name='Pass-1'): 292 | # bench execute barista.resolve_run_name --kwargs "{'run_name':''}" 293 | 294 | if frappe.db.exists('Test Run Log', {'test_run_name': run_name}): 295 | if 'Pass-' in run_name: 296 | return resolve_run_name( 297 | f"Pass-{safe_cast(run_name.split('-')[1],int,1)+1}") 298 | else: 299 | click.echo( 300 | f'Provided Run Name [{run_name}] already exists. Please provide other Run Name.') 301 | sys.exit(1) 302 | else: 303 | return run_name 304 | 305 | 306 | def safe_cast(value, value_type, default): 307 | try: 308 | return value_type(value) 309 | except Exception: 310 | return default 311 | 312 | 313 | @frappe.whitelist() 314 | def get_test_coverage(): 315 | # bench execute barista.barista.doctype.test_suite.run_test.get_test_coverage 316 | test_coverage_lst = [] 317 | try: 318 | barista_app_path = frappe.get_app_path('barista') 319 | test_coverage_path = f"{barista_app_path}/public/test-coverage" 320 | 321 | paths = sorted(Path(test_coverage_path).iterdir(), 322 | key=os.path.getmtime) 323 | 324 | for path in paths: 325 | if path.is_dir(): 326 | path_parts = str(path).split('/') 327 | d = path_parts.pop() 328 | run_name = d.replace('__', ' ').replace('_', '-') 329 | test_coverage_lst.append({ 330 | 'coverage_path': f"/assets/barista/test-coverage/{d}/index.html", 331 | 'test_run_name': run_name 332 | }) 333 | except Exception as e: 334 | print('error-', e) 335 | frappe.log_error(frappe.get_traceback(), 'barista-get_test_coverage') 336 | 337 | return test_coverage_lst 338 | 339 | 340 | @frappe.whitelist() 341 | def delete_test_coverage(run_name): 342 | # barista.barista.doctype.test_suite.run_test.delete_test_coverage 343 | try: 344 | run_name_path = run_name.replace(' ', '__').replace('-', '_') 345 | barista_app_path = f"{frappe.get_app_path('barista')}/public/test-coverage/{run_name_path}/" 346 | 347 | shutil.rmtree(barista_app_path, ignore_errors=True) 348 | frappe.db.sql(''' 349 | delete from `tabTest Run Log` where test_run_name=%(run_name)s 350 | ''', {'run_name': run_name}, auto_commit=1) 351 | frappe.db.sql(''' 352 | delete from `tabTest Result` where test_run_name=%(run_name)s 353 | ''', {'run_name': run_name}, auto_commit=1) 354 | except Exception: 355 | frappe.log_error(frappe.get_traceback(), 356 | 'barista-delete_test_coverage') 357 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_suite/test_suite.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, elasticrun and contributors 2 | // For license information, please see license.txt 3 | 4 | frappe.ui.form.on('Test Suite', { 5 | refresh: function(frm) { 6 | 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_suite/test_suite.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 1, 7 | "autoname": "field:suite_name", 8 | "beta": 0, 9 | "creation": "2019-12-19 11:49:55.460732", 10 | "custom": 0, 11 | "docstatus": 0, 12 | "doctype": "DocType", 13 | "document_type": "", 14 | "editable_grid": 1, 15 | "engine": "InnoDB", 16 | "fields": [ 17 | { 18 | "allow_bulk_edit": 0, 19 | "allow_in_quick_entry": 0, 20 | "allow_on_submit": 0, 21 | "bold": 0, 22 | "collapsible": 0, 23 | "columns": 0, 24 | "fetch_if_empty": 0, 25 | "fieldname": "suite_name", 26 | "fieldtype": "Data", 27 | "hidden": 0, 28 | "ignore_user_permissions": 0, 29 | "ignore_xss_filter": 0, 30 | "in_filter": 0, 31 | "in_global_search": 0, 32 | "in_list_view": 0, 33 | "in_standard_filter": 0, 34 | "label": "Suite Name", 35 | "length": 0, 36 | "no_copy": 0, 37 | "permlevel": 0, 38 | "precision": "", 39 | "print_hide": 0, 40 | "print_hide_if_no_value": 0, 41 | "read_only": 0, 42 | "remember_last_selected_value": 0, 43 | "report_hide": 0, 44 | "reqd": 0, 45 | "search_index": 0, 46 | "set_only_once": 0, 47 | "translatable": 0, 48 | "unique": 1 49 | }, 50 | { 51 | "allow_bulk_edit": 0, 52 | "allow_in_quick_entry": 0, 53 | "allow_on_submit": 0, 54 | "bold": 0, 55 | "collapsible": 0, 56 | "columns": 0, 57 | "fetch_if_empty": 0, 58 | "fieldname": "app_name", 59 | "fieldtype": "Data", 60 | "hidden": 0, 61 | "ignore_user_permissions": 0, 62 | "ignore_xss_filter": 0, 63 | "in_filter": 0, 64 | "in_global_search": 0, 65 | "in_list_view": 0, 66 | "in_standard_filter": 0, 67 | "label": "App Name", 68 | "length": 0, 69 | "no_copy": 0, 70 | "permlevel": 0, 71 | "precision": "", 72 | "print_hide": 0, 73 | "print_hide_if_no_value": 0, 74 | "read_only": 0, 75 | "remember_last_selected_value": 0, 76 | "report_hide": 0, 77 | "reqd": 0, 78 | "search_index": 0, 79 | "set_only_once": 0, 80 | "translatable": 0, 81 | "unique": 0 82 | }, 83 | { 84 | "allow_bulk_edit": 0, 85 | "allow_in_quick_entry": 0, 86 | "allow_on_submit": 0, 87 | "bold": 0, 88 | "collapsible": 0, 89 | "columns": 0, 90 | "fetch_if_empty": 0, 91 | "fieldname": "test_data", 92 | "fieldtype": "Table", 93 | "hidden": 0, 94 | "ignore_user_permissions": 0, 95 | "ignore_xss_filter": 0, 96 | "in_filter": 0, 97 | "in_global_search": 0, 98 | "in_list_view": 0, 99 | "in_standard_filter": 0, 100 | "label": "Test Data", 101 | "length": 0, 102 | "no_copy": 0, 103 | "options": "Testdata Item", 104 | "permlevel": 0, 105 | "precision": "", 106 | "print_hide": 0, 107 | "print_hide_if_no_value": 0, 108 | "read_only": 0, 109 | "remember_last_selected_value": 0, 110 | "report_hide": 0, 111 | "reqd": 0, 112 | "search_index": 0, 113 | "set_only_once": 0, 114 | "translatable": 0, 115 | "unique": 0 116 | }, 117 | { 118 | "allow_bulk_edit": 0, 119 | "allow_in_quick_entry": 0, 120 | "allow_on_submit": 0, 121 | "bold": 0, 122 | "collapsible": 0, 123 | "columns": 0, 124 | "fetch_if_empty": 0, 125 | "fieldname": "testcase", 126 | "fieldtype": "Table", 127 | "hidden": 0, 128 | "ignore_user_permissions": 0, 129 | "ignore_xss_filter": 0, 130 | "in_filter": 0, 131 | "in_global_search": 0, 132 | "in_list_view": 0, 133 | "in_standard_filter": 0, 134 | "label": "Testcase", 135 | "length": 0, 136 | "no_copy": 0, 137 | "options": "Testcase Item", 138 | "permlevel": 0, 139 | "precision": "", 140 | "print_hide": 0, 141 | "print_hide_if_no_value": 0, 142 | "read_only": 0, 143 | "remember_last_selected_value": 0, 144 | "report_hide": 0, 145 | "reqd": 0, 146 | "search_index": 0, 147 | "set_only_once": 0, 148 | "translatable": 0, 149 | "unique": 0 150 | } 151 | ], 152 | "has_web_view": 0, 153 | "hide_heading": 0, 154 | "hide_toolbar": 0, 155 | "idx": 0, 156 | "image_view": 0, 157 | "in_create": 0, 158 | "is_submittable": 0, 159 | "issingle": 0, 160 | "istable": 0, 161 | "max_attachments": 0, 162 | "modified": "2020-05-07 14:17:49.904989", 163 | "modified_by": "Administrator", 164 | "module": "Barista", 165 | "name": "Test Suite", 166 | "name_case": "", 167 | "owner": "Administrator", 168 | "permissions": [ 169 | { 170 | "amend": 0, 171 | "cancel": 0, 172 | "create": 1, 173 | "delete": 1, 174 | "email": 1, 175 | "export": 1, 176 | "if_owner": 0, 177 | "import": 0, 178 | "permlevel": 0, 179 | "print": 1, 180 | "read": 1, 181 | "report": 1, 182 | "role": "System Manager", 183 | "set_user_permissions": 0, 184 | "share": 1, 185 | "submit": 0, 186 | "write": 1 187 | } 188 | ], 189 | "quick_entry": 0, 190 | "read_only": 0, 191 | "read_only_onload": 0, 192 | "show_name_in_global_search": 0, 193 | "sort_field": "modified", 194 | "sort_order": "DESC", 195 | "track_changes": 1, 196 | "track_seen": 0, 197 | "track_views": 0 198 | } -------------------------------------------------------------------------------- /barista/barista/doctype/test_suite/test_suite.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | import random 9 | import datetime 10 | import ast, json, requests, urllib3, re, math, difflib, base64, operator, copy, traceback, urllib, ssl, binascii, six, html.parser, os 11 | import bs4, sys, pymysql, html2text, warnings, markdown2, csv, calendar, unittest 12 | 13 | 14 | class TestSuite(Document): 15 | pass 16 | 17 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_suite/test_suite_dashboard.py: -------------------------------------------------------------------------------- 1 | from frappe import _ 2 | 3 | 4 | def get_data(): 5 | return { 6 | 'fieldname': 'test_suite', 7 | 'non_standard_fieldnames': { 8 | 'Test Result': 'test_suite' 9 | }, 10 | 'internal_links': { 11 | 12 | }, 13 | 'transactions': [ 14 | { 15 | 'items': ['Test Result'] 16 | }, 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_suite/test_test_suite.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | // rename this file from _test_[name] to test_[name] to activate 3 | // and remove above this line 4 | 5 | QUnit.test("test: Test Suite", function (assert) { 6 | let done = assert.async(); 7 | 8 | // number of asserts 9 | assert.expect(1); 10 | 11 | frappe.run_serially([ 12 | // insert a new Test Suite 13 | () => frappe.tests.make('Test Suite', [ 14 | // values to be set 15 | {key: 'value'} 16 | ]), 17 | () => { 18 | assert.equal(cur_frm.doc.key, 'value'); 19 | }, 20 | () => done() 21 | ]); 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /barista/barista/doctype/test_suite/test_test_suite.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and Contributors 3 | # See license.txt 4 | from __future__ import unicode_literals 5 | 6 | import frappe 7 | import unittest 8 | 9 | class TestTestSuite(unittest.TestCase): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/testcase_item/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/testcase_item/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/testcase_item/test_testcase_item.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | // rename this file from _test_[name] to test_[name] to activate 3 | // and remove above this line 4 | 5 | QUnit.test("test: Testcase Item", function (assert) { 6 | let done = assert.async(); 7 | 8 | // number of asserts 9 | assert.expect(1); 10 | 11 | frappe.run_serially([ 12 | // insert a new Testcase Item 13 | () => frappe.tests.make('Testcase Item', [ 14 | // values to be set 15 | {key: 'value'} 16 | ]), 17 | () => { 18 | assert.equal(cur_frm.doc.key, 'value'); 19 | }, 20 | () => done() 21 | ]); 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /barista/barista/doctype/testcase_item/test_testcase_item.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and Contributors 3 | # See license.txt 4 | from __future__ import unicode_literals 5 | 6 | import frappe 7 | import unittest 8 | 9 | class TestTestcaseItem(unittest.TestCase): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/testcase_item/testcase_item.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, elasticrun and contributors 2 | // For license information, please see license.txt 3 | 4 | frappe.ui.form.on('Testcase Item', { 5 | refresh: function(frm) { 6 | 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /barista/barista/doctype/testcase_item/testcase_item.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 0, 7 | "beta": 0, 8 | "creation": "2019-12-19 11:34:51.691669", 9 | "custom": 0, 10 | "docstatus": 0, 11 | "doctype": "DocType", 12 | "document_type": "", 13 | "editable_grid": 1, 14 | "engine": "InnoDB", 15 | "fields": [ 16 | { 17 | "allow_bulk_edit": 0, 18 | "allow_in_quick_entry": 0, 19 | "allow_on_submit": 0, 20 | "bold": 0, 21 | "collapsible": 0, 22 | "columns": 0, 23 | "fetch_if_empty": 0, 24 | "fieldname": "testcase", 25 | "fieldtype": "Link", 26 | "hidden": 0, 27 | "ignore_user_permissions": 0, 28 | "ignore_xss_filter": 0, 29 | "in_filter": 0, 30 | "in_global_search": 0, 31 | "in_list_view": 1, 32 | "in_standard_filter": 0, 33 | "label": "Test Case", 34 | "length": 0, 35 | "no_copy": 0, 36 | "options": "Test Case", 37 | "permlevel": 0, 38 | "precision": "", 39 | "print_hide": 0, 40 | "print_hide_if_no_value": 0, 41 | "read_only": 0, 42 | "remember_last_selected_value": 0, 43 | "report_hide": 0, 44 | "reqd": 1, 45 | "search_index": 0, 46 | "set_only_once": 0, 47 | "translatable": 0, 48 | "unique": 0 49 | }, 50 | { 51 | "allow_bulk_edit": 0, 52 | "allow_in_quick_entry": 0, 53 | "allow_on_submit": 0, 54 | "bold": 0, 55 | "collapsible": 0, 56 | "columns": 0, 57 | "fetch_if_empty": 0, 58 | "fieldname": "column_break_2", 59 | "fieldtype": "Column Break", 60 | "hidden": 0, 61 | "ignore_user_permissions": 0, 62 | "ignore_xss_filter": 0, 63 | "in_filter": 0, 64 | "in_global_search": 0, 65 | "in_list_view": 0, 66 | "in_standard_filter": 0, 67 | "length": 0, 68 | "no_copy": 0, 69 | "permlevel": 0, 70 | "precision": "", 71 | "print_hide": 0, 72 | "print_hide_if_no_value": 0, 73 | "read_only": 0, 74 | "remember_last_selected_value": 0, 75 | "report_hide": 0, 76 | "reqd": 0, 77 | "search_index": 0, 78 | "set_only_once": 0, 79 | "translatable": 0, 80 | "unique": 0 81 | }, 82 | { 83 | "allow_bulk_edit": 0, 84 | "allow_in_quick_entry": 0, 85 | "allow_on_submit": 0, 86 | "bold": 0, 87 | "collapsible": 0, 88 | "columns": 0, 89 | "fetch_from": "testcase.testcase_name", 90 | "fetch_if_empty": 1, 91 | "fieldname": "testcase_name", 92 | "fieldtype": "Data", 93 | "hidden": 0, 94 | "ignore_user_permissions": 0, 95 | "ignore_xss_filter": 0, 96 | "in_filter": 0, 97 | "in_global_search": 0, 98 | "in_list_view": 1, 99 | "in_standard_filter": 0, 100 | "label": "Test Case Name", 101 | "length": 0, 102 | "no_copy": 0, 103 | "permlevel": 0, 104 | "precision": "", 105 | "print_hide": 0, 106 | "print_hide_if_no_value": 0, 107 | "read_only": 1, 108 | "remember_last_selected_value": 0, 109 | "report_hide": 0, 110 | "reqd": 0, 111 | "search_index": 0, 112 | "set_only_once": 0, 113 | "translatable": 0, 114 | "unique": 0 115 | } 116 | ], 117 | "has_web_view": 0, 118 | "hide_heading": 0, 119 | "hide_toolbar": 0, 120 | "idx": 0, 121 | "image_view": 0, 122 | "in_create": 0, 123 | "is_submittable": 0, 124 | "issingle": 0, 125 | "istable": 1, 126 | "max_attachments": 0, 127 | "modified": "2020-05-04 16:06:41.221576", 128 | "modified_by": "Administrator", 129 | "module": "Barista", 130 | "name": "Testcase Item", 131 | "name_case": "", 132 | "owner": "Administrator", 133 | "permissions": [], 134 | "quick_entry": 1, 135 | "read_only": 0, 136 | "read_only_onload": 0, 137 | "show_name_in_global_search": 0, 138 | "sort_field": "modified", 139 | "sort_order": "DESC", 140 | "track_changes": 1, 141 | "track_seen": 0, 142 | "track_views": 0 143 | } -------------------------------------------------------------------------------- /barista/barista/doctype/testcase_item/testcase_item.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | 9 | class TestcaseItem(Document): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/testdata_item/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/testdata_item/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/testdata_item/test_testdata_item.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | // rename this file from _test_[name] to test_[name] to activate 3 | // and remove above this line 4 | 5 | QUnit.test("test: Testdata Item", function (assert) { 6 | let done = assert.async(); 7 | 8 | // number of asserts 9 | assert.expect(1); 10 | 11 | frappe.run_serially([ 12 | // insert a new Testdata Item 13 | () => frappe.tests.make('Testdata Item', [ 14 | // values to be set 15 | {key: 'value'} 16 | ]), 17 | () => { 18 | assert.equal(cur_frm.doc.key, 'value'); 19 | }, 20 | () => done() 21 | ]); 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /barista/barista/doctype/testdata_item/test_testdata_item.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and Contributors 3 | # See license.txt 4 | from __future__ import unicode_literals 5 | 6 | import frappe 7 | import unittest 8 | 9 | class TestTestdataItem(unittest.TestCase): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/testdata_item/testdata_item.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, elasticrun and contributors 2 | // For license information, please see license.txt 3 | 4 | frappe.ui.form.on('Testdata Item', { 5 | refresh: function(frm) { 6 | 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /barista/barista/doctype/testdata_item/testdata_item.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 0, 7 | "beta": 0, 8 | "creation": "2019-12-30 13:47:35.012561", 9 | "custom": 0, 10 | "docstatus": 0, 11 | "doctype": "DocType", 12 | "document_type": "", 13 | "editable_grid": 1, 14 | "engine": "InnoDB", 15 | "fields": [ 16 | { 17 | "allow_bulk_edit": 0, 18 | "allow_in_quick_entry": 0, 19 | "allow_on_submit": 0, 20 | "bold": 0, 21 | "collapsible": 0, 22 | "columns": 0, 23 | "fetch_if_empty": 0, 24 | "fieldname": "test_data", 25 | "fieldtype": "Link", 26 | "hidden": 0, 27 | "ignore_user_permissions": 0, 28 | "ignore_xss_filter": 0, 29 | "in_filter": 0, 30 | "in_global_search": 0, 31 | "in_list_view": 1, 32 | "in_standard_filter": 0, 33 | "label": "Test Data", 34 | "length": 0, 35 | "no_copy": 0, 36 | "options": "Test Data", 37 | "permlevel": 0, 38 | "precision": "", 39 | "print_hide": 0, 40 | "print_hide_if_no_value": 0, 41 | "read_only": 0, 42 | "remember_last_selected_value": 0, 43 | "report_hide": 0, 44 | "reqd": 1, 45 | "search_index": 0, 46 | "set_only_once": 0, 47 | "translatable": 0, 48 | "unique": 0 49 | }, 50 | { 51 | "allow_bulk_edit": 0, 52 | "allow_in_quick_entry": 0, 53 | "allow_on_submit": 0, 54 | "bold": 0, 55 | "collapsible": 0, 56 | "columns": 0, 57 | "fetch_if_empty": 0, 58 | "fieldname": "column_break_2", 59 | "fieldtype": "Column Break", 60 | "hidden": 0, 61 | "ignore_user_permissions": 0, 62 | "ignore_xss_filter": 0, 63 | "in_filter": 0, 64 | "in_global_search": 0, 65 | "in_list_view": 0, 66 | "in_standard_filter": 0, 67 | "length": 0, 68 | "no_copy": 0, 69 | "permlevel": 0, 70 | "precision": "", 71 | "print_hide": 0, 72 | "print_hide_if_no_value": 0, 73 | "read_only": 0, 74 | "remember_last_selected_value": 0, 75 | "report_hide": 0, 76 | "reqd": 0, 77 | "search_index": 0, 78 | "set_only_once": 0, 79 | "translatable": 0, 80 | "unique": 0 81 | }, 82 | { 83 | "allow_bulk_edit": 0, 84 | "allow_in_quick_entry": 0, 85 | "allow_on_submit": 0, 86 | "bold": 0, 87 | "collapsible": 0, 88 | "columns": 0, 89 | "fetch_from": "test_data.description", 90 | "fetch_if_empty": 1, 91 | "fieldname": "test_data_description", 92 | "fieldtype": "Data", 93 | "hidden": 0, 94 | "ignore_user_permissions": 0, 95 | "ignore_xss_filter": 0, 96 | "in_filter": 0, 97 | "in_global_search": 0, 98 | "in_list_view": 1, 99 | "in_standard_filter": 0, 100 | "label": "Test Data Description", 101 | "length": 0, 102 | "no_copy": 0, 103 | "permlevel": 0, 104 | "precision": "", 105 | "print_hide": 0, 106 | "print_hide_if_no_value": 0, 107 | "read_only": 1, 108 | "remember_last_selected_value": 0, 109 | "report_hide": 0, 110 | "reqd": 0, 111 | "search_index": 0, 112 | "set_only_once": 0, 113 | "translatable": 0, 114 | "unique": 0 115 | } 116 | ], 117 | "has_web_view": 0, 118 | "hide_heading": 0, 119 | "hide_toolbar": 0, 120 | "idx": 0, 121 | "image_view": 0, 122 | "in_create": 0, 123 | "is_submittable": 0, 124 | "issingle": 0, 125 | "istable": 1, 126 | "max_attachments": 0, 127 | "modified": "2020-05-04 16:06:52.136293", 128 | "modified_by": "Administrator", 129 | "module": "Barista", 130 | "name": "Testdata Item", 131 | "name_case": "", 132 | "owner": "Administrator", 133 | "permissions": [], 134 | "quick_entry": 1, 135 | "read_only": 0, 136 | "read_only_onload": 0, 137 | "show_name_in_global_search": 0, 138 | "sort_field": "modified", 139 | "sort_order": "DESC", 140 | "track_changes": 1, 141 | "track_seen": 0, 142 | "track_views": 0 143 | } -------------------------------------------------------------------------------- /barista/barista/doctype/testdata_item/testdata_item.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | 9 | class TestdataItem(Document): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/testdatafield/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/doctype/testdatafield/__init__.py -------------------------------------------------------------------------------- /barista/barista/doctype/testdatafield/test_testdatafield.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | // rename this file from _test_[name] to test_[name] to activate 3 | // and remove above this line 4 | 5 | QUnit.test("test: Testdatafield", function (assert) { 6 | let done = assert.async(); 7 | 8 | // number of asserts 9 | assert.expect(1); 10 | 11 | frappe.run_serially([ 12 | // insert a new Testdatafield 13 | () => frappe.tests.make('Testdatafield', [ 14 | // values to be set 15 | {key: 'value'} 16 | ]), 17 | () => { 18 | assert.equal(cur_frm.doc.key, 'value'); 19 | }, 20 | () => done() 21 | ]); 22 | 23 | }); 24 | -------------------------------------------------------------------------------- /barista/barista/doctype/testdatafield/test_testdatafield.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and Contributors 3 | # See license.txt 4 | from __future__ import unicode_literals 5 | 6 | import frappe 7 | import unittest 8 | 9 | class TestTestdatafield(unittest.TestCase): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/doctype/testdatafield/testdatafield.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, elasticrun and contributors 2 | // For license information, please see license.txt 3 | 4 | frappe.ui.form.on('Testdatafield', { 5 | refresh: function(frm) { 6 | 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /barista/barista/doctype/testdatafield/testdatafield.json: -------------------------------------------------------------------------------- 1 | { 2 | "allow_copy": 0, 3 | "allow_events_in_timeline": 0, 4 | "allow_guest_to_view": 0, 5 | "allow_import": 0, 6 | "allow_rename": 0, 7 | "beta": 0, 8 | "creation": "2019-12-18 09:55:19.639158", 9 | "custom": 0, 10 | "docstatus": 0, 11 | "doctype": "DocType", 12 | "document_type": "", 13 | "editable_grid": 1, 14 | "engine": "InnoDB", 15 | "fields": [ 16 | { 17 | "allow_bulk_edit": 0, 18 | "allow_in_quick_entry": 0, 19 | "allow_on_submit": 0, 20 | "bold": 0, 21 | "collapsible": 0, 22 | "columns": 0, 23 | "fetch_if_empty": 0, 24 | "fieldname": "doctype_name", 25 | "fieldtype": "Link", 26 | "hidden": 0, 27 | "ignore_user_permissions": 0, 28 | "ignore_xss_filter": 0, 29 | "in_filter": 0, 30 | "in_global_search": 0, 31 | "in_list_view": 0, 32 | "in_standard_filter": 0, 33 | "label": "DocType Name", 34 | "length": 0, 35 | "no_copy": 0, 36 | "options": "DocType", 37 | "permlevel": 0, 38 | "precision": "", 39 | "print_hide": 0, 40 | "print_hide_if_no_value": 0, 41 | "read_only": 1, 42 | "remember_last_selected_value": 0, 43 | "report_hide": 0, 44 | "reqd": 0, 45 | "search_index": 0, 46 | "set_only_once": 0, 47 | "translatable": 0, 48 | "unique": 0 49 | }, 50 | { 51 | "allow_bulk_edit": 0, 52 | "allow_in_quick_entry": 0, 53 | "allow_on_submit": 0, 54 | "bold": 0, 55 | "collapsible": 0, 56 | "columns": 0, 57 | "fetch_from": "docfield_name.fieldname", 58 | "fetch_if_empty": 1, 59 | "fieldname": "docfield_fieldname", 60 | "fieldtype": "Select", 61 | "hidden": 0, 62 | "ignore_user_permissions": 0, 63 | "ignore_xss_filter": 0, 64 | "in_filter": 0, 65 | "in_global_search": 0, 66 | "in_list_view": 1, 67 | "in_standard_filter": 0, 68 | "label": "DocField Name", 69 | "length": 0, 70 | "no_copy": 0, 71 | "options": "", 72 | "permlevel": 0, 73 | "precision": "", 74 | "print_hide": 0, 75 | "print_hide_if_no_value": 0, 76 | "read_only": 0, 77 | "remember_last_selected_value": 0, 78 | "report_hide": 0, 79 | "reqd": 0, 80 | "search_index": 0, 81 | "set_only_once": 0, 82 | "translatable": 0, 83 | "unique": 0 84 | }, 85 | { 86 | "allow_bulk_edit": 0, 87 | "allow_in_quick_entry": 0, 88 | "allow_on_submit": 0, 89 | "bold": 0, 90 | "collapsible": 0, 91 | "columns": 0, 92 | "default": "0", 93 | "fetch_if_empty": 0, 94 | "fieldname": "is_default", 95 | "fieldtype": "Check", 96 | "hidden": 0, 97 | "ignore_user_permissions": 0, 98 | "ignore_xss_filter": 0, 99 | "in_filter": 0, 100 | "in_global_search": 0, 101 | "in_list_view": 1, 102 | "in_standard_filter": 0, 103 | "label": "Assign Random Value", 104 | "length": 0, 105 | "no_copy": 0, 106 | "permlevel": 0, 107 | "precision": "", 108 | "print_hide": 0, 109 | "print_hide_if_no_value": 0, 110 | "read_only": 0, 111 | "remember_last_selected_value": 0, 112 | "report_hide": 0, 113 | "reqd": 0, 114 | "search_index": 0, 115 | "set_only_once": 0, 116 | "translatable": 0, 117 | "unique": 0 118 | }, 119 | { 120 | "allow_bulk_edit": 0, 121 | "allow_in_quick_entry": 0, 122 | "allow_on_submit": 0, 123 | "bold": 0, 124 | "collapsible": 0, 125 | "columns": 0, 126 | "default": "", 127 | "depends_on": "eval:(doc.is_default===0)", 128 | "fetch_if_empty": 0, 129 | "fieldname": "docfield_code_value", 130 | "fieldtype": "Select", 131 | "hidden": 0, 132 | "ignore_user_permissions": 0, 133 | "ignore_xss_filter": 0, 134 | "in_filter": 0, 135 | "in_global_search": 0, 136 | "in_list_view": 1, 137 | "in_standard_filter": 0, 138 | "label": "DocField Fixed Value or Code", 139 | "length": 0, 140 | "no_copy": 0, 141 | "options": "\nFixed Value\nCode", 142 | "permlevel": 0, 143 | "precision": "", 144 | "print_hide": 0, 145 | "print_hide_if_no_value": 0, 146 | "read_only": 0, 147 | "remember_last_selected_value": 0, 148 | "report_hide": 0, 149 | "reqd": 0, 150 | "search_index": 0, 151 | "set_only_once": 0, 152 | "translatable": 0, 153 | "unique": 0 154 | }, 155 | { 156 | "allow_bulk_edit": 0, 157 | "allow_in_quick_entry": 0, 158 | "allow_on_submit": 0, 159 | "bold": 0, 160 | "collapsible": 0, 161 | "columns": 0, 162 | "depends_on": "eval:(doc.docfield_code_value == \"Code\" && doc.is_default===0)", 163 | "description": "\n", 164 | "fetch_if_empty": 0, 165 | "fieldname": "docfield_code", 166 | "fieldtype": "Code", 167 | "hidden": 0, 168 | "ignore_user_permissions": 0, 169 | "ignore_xss_filter": 0, 170 | "in_filter": 0, 171 | "in_global_search": 0, 172 | "in_list_view": 0, 173 | "in_standard_filter": 0, 174 | "label": "DocField Code", 175 | "length": 0, 176 | "no_copy": 0, 177 | "permlevel": 0, 178 | "precision": "", 179 | "print_hide": 0, 180 | "print_hide_if_no_value": 0, 181 | "read_only": 0, 182 | "remember_last_selected_value": 0, 183 | "report_hide": 0, 184 | "reqd": 0, 185 | "search_index": 0, 186 | "set_only_once": 0, 187 | "translatable": 0, 188 | "unique": 0 189 | }, 190 | { 191 | "allow_bulk_edit": 0, 192 | "allow_in_quick_entry": 0, 193 | "allow_on_submit": 0, 194 | "bold": 0, 195 | "collapsible": 0, 196 | "columns": 0, 197 | "default": "Examples - \nCurrency: round(random.uniform(500.12, 22000.34),2) \nDate: datetime.date.today() + datetime.timedelta(days(random.randrange(0,15,1)))\n\nDatetime:\ndatetime.datetime.now() + datetime.timedelta(minutes(random.randrange(0,200,2)))\nFloat: round(random.uniform(0, 22000.34),2)\nInt: random.randrange(0,200,1)\n", 198 | "depends_on": "eval:doc.docfield_code_value == \"Code\"", 199 | "description": "", 200 | "fetch_if_empty": 0, 201 | "fieldname": "code_desc", 202 | "fieldtype": "Small Text", 203 | "hidden": 0, 204 | "ignore_user_permissions": 0, 205 | "ignore_xss_filter": 0, 206 | "in_filter": 0, 207 | "in_global_search": 0, 208 | "in_list_view": 0, 209 | "in_standard_filter": 0, 210 | "length": 0, 211 | "no_copy": 0, 212 | "options": "", 213 | "permlevel": 0, 214 | "precision": "", 215 | "print_hide": 0, 216 | "print_hide_if_no_value": 0, 217 | "read_only": 1, 218 | "remember_last_selected_value": 0, 219 | "report_hide": 0, 220 | "reqd": 0, 221 | "search_index": 0, 222 | "set_only_once": 0, 223 | "translatable": 0, 224 | "unique": 0 225 | }, 226 | { 227 | "allow_bulk_edit": 0, 228 | "allow_in_quick_entry": 0, 229 | "allow_on_submit": 0, 230 | "bold": 0, 231 | "collapsible": 0, 232 | "columns": 0, 233 | "depends_on": "eval:(doc.docfield_code_value == \"Fixed Value\" && doc.is_default===0)", 234 | "fetch_if_empty": 0, 235 | "fieldname": "docfield_value", 236 | "fieldtype": "Small Text", 237 | "hidden": 0, 238 | "ignore_user_permissions": 0, 239 | "ignore_xss_filter": 0, 240 | "in_filter": 0, 241 | "in_global_search": 0, 242 | "in_list_view": 1, 243 | "in_standard_filter": 0, 244 | "label": "DocField Value", 245 | "length": 0, 246 | "no_copy": 0, 247 | "permlevel": 0, 248 | "precision": "", 249 | "print_hide": 0, 250 | "print_hide_if_no_value": 0, 251 | "read_only": 0, 252 | "remember_last_selected_value": 0, 253 | "report_hide": 0, 254 | "reqd": 0, 255 | "search_index": 0, 256 | "set_only_once": 0, 257 | "translatable": 0, 258 | "unique": 0 259 | }, 260 | { 261 | "allow_bulk_edit": 0, 262 | "allow_in_quick_entry": 0, 263 | "allow_on_submit": 0, 264 | "bold": 0, 265 | "collapsible": 0, 266 | "columns": 0, 267 | "depends_on": "eval:(doc.is_default===0)", 268 | "fetch_if_empty": 0, 269 | "fieldname": "linkfield_name", 270 | "fieldtype": "Link", 271 | "hidden": 0, 272 | "ignore_user_permissions": 0, 273 | "ignore_xss_filter": 0, 274 | "in_filter": 0, 275 | "in_global_search": 0, 276 | "in_list_view": 0, 277 | "in_standard_filter": 0, 278 | "label": "Link Field", 279 | "length": 0, 280 | "no_copy": 0, 281 | "options": "Test Data", 282 | "permlevel": 0, 283 | "precision": "", 284 | "print_hide": 0, 285 | "print_hide_if_no_value": 0, 286 | "read_only": 0, 287 | "remember_last_selected_value": 0, 288 | "report_hide": 0, 289 | "reqd": 0, 290 | "search_index": 0, 291 | "set_only_once": 0, 292 | "translatable": 0, 293 | "unique": 0 294 | } 295 | ], 296 | "has_web_view": 0, 297 | "hide_heading": 0, 298 | "hide_toolbar": 0, 299 | "idx": 0, 300 | "image_view": 0, 301 | "in_create": 0, 302 | "is_submittable": 0, 303 | "issingle": 0, 304 | "istable": 1, 305 | "max_attachments": 0, 306 | "modified": "2020-04-14 17:29:14.869061", 307 | "modified_by": "Administrator", 308 | "module": "Barista", 309 | "name": "Testdatafield", 310 | "name_case": "", 311 | "owner": "Administrator", 312 | "permissions": [], 313 | "quick_entry": 1, 314 | "read_only": 0, 315 | "read_only_onload": 0, 316 | "show_name_in_global_search": 0, 317 | "sort_field": "modified", 318 | "sort_order": "DESC", 319 | "track_changes": 1, 320 | "track_seen": 0, 321 | "track_views": 0 322 | } -------------------------------------------------------------------------------- /barista/barista/doctype/testdatafield/testdatafield.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (c) 2019, elasticrun and contributors 3 | # For license information, please see license.txt 4 | 5 | from __future__ import unicode_literals 6 | import frappe 7 | from frappe.model.document import Document 8 | 9 | class Testdatafield(Document): 10 | pass 11 | -------------------------------------------------------------------------------- /barista/barista/page/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/page/__init__.py -------------------------------------------------------------------------------- /barista/barista/page/test_coverage/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/page/test_coverage/__init__.py -------------------------------------------------------------------------------- /barista/barista/page/test_coverage/test_coverage.js: -------------------------------------------------------------------------------- 1 | frappe.pages['test-coverage'].on_page_load = function (wrapper) { 2 | var page = frappe.ui.make_app_page({ 3 | parent: wrapper, 4 | title: 'Barista Test Coverage', 5 | single_column: true 6 | }); 7 | 8 | $('head').append(` 9 | 21 | `); 22 | getTestCoverage(); 23 | $('.ellipsis.title-text').append(` `); 24 | } 25 | 26 | function getTestCoverage() { 27 | $('.row.layout-main').empty(); 28 | frappe.call({ 29 | method: 'barista.barista.doctype.test_suite.run_test.get_test_coverage', 30 | freeze: true, 31 | callback: function (r) { 32 | if (!r.exc) { 33 | const testCoverages = r.message; 34 | let srNo = 1; 35 | let tableContent = ''; 36 | 37 | testCoverages.forEach(t => { 38 | tableContent += ` 39 | 40 | ${srNo} 41 | ${t.test_run_name} 42 | 43 | 44 | `; 45 | srNo += 1; 46 | }) 47 | 48 | const table = ` 49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | ${tableContent} 57 |
Sr.No.Test Run NameDelete Test Coverage
58 | `; 59 | 60 | $('.row.layout-main').append(table); 61 | } 62 | } 63 | }); 64 | } 65 | 66 | function deleteTestCoverage(run_name) { 67 | frappe.call({ 68 | method: 'barista.barista.doctype.test_suite.run_test.delete_test_coverage', 69 | args: { 70 | run_name: run_name 71 | }, 72 | freeze: true, 73 | freeze_message: `Deleting Test Coverage of Test Run ${run_name}`, 74 | callback: function (r) { 75 | if (!r.exc) { 76 | getTestCoverage(); 77 | } 78 | } 79 | }); 80 | } -------------------------------------------------------------------------------- /barista/barista/page/test_coverage/test_coverage.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": null, 3 | "creation": "2020-05-17 13:46:15.319127", 4 | "docstatus": 0, 5 | "doctype": "Page", 6 | "idx": 0, 7 | "modified": "2020-05-17 16:43:25.095107", 8 | "modified_by": "Administrator", 9 | "module": "Barista", 10 | "name": "test-coverage", 11 | "owner": "Administrator", 12 | "page_name": "Test Coverage", 13 | "roles": [ 14 | { 15 | "role": "All" 16 | } 17 | ], 18 | "script": null, 19 | "standard": "Yes", 20 | "style": null, 21 | "system_page": 0, 22 | "title": "Barista Test Coverage" 23 | } -------------------------------------------------------------------------------- /barista/barista/report/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/report/__init__.py -------------------------------------------------------------------------------- /barista/barista/report/assertion_effectiveness/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/report/assertion_effectiveness/__init__.py -------------------------------------------------------------------------------- /barista/barista/report/assertion_effectiveness/assertion_effectiveness.json: -------------------------------------------------------------------------------- 1 | { 2 | "add_total_row": 0, 3 | "creation": "2020-03-05 12:19:36.430561", 4 | "disable_prepared_report": 0, 5 | "disabled": 0, 6 | "docstatus": 0, 7 | "doctype": "Report", 8 | "idx": 0, 9 | "is_standard": "Yes", 10 | "letter_head": "ElasticRun", 11 | "modified": "2020-04-01 11:04:39.433077", 12 | "modified_by": "Administrator", 13 | "module": "Barista", 14 | "name": "Assertion Effectiveness", 15 | "owner": "Administrator", 16 | "prepared_report": 0, 17 | "query": "select \nda0.a0 as '0 Assertion Test Cases',\nda1.a1 as '1 Assertion Test Cases',\nda2.a2 as '2 Assertions Test Cases',\nda3.a3 as '3 Assertions Test Cases',\nda4.a4 as '4 Assertions Test Cases',\nda5.a5 as '>= 5 Assertions Test Cases',\n(da0.a0+da1.a1+da2.a2+da3.a3+da4.a4+da5.a5) as 'Total Test Cases'\n\nfrom (select count(*) as 'a1' from (select count(tc.name) from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase left join `tabAssertion` a on a.parent=tc.name group by a.parent having count(a.name)=1) as dc) da1\njoin\n(select count(*) as 'a2' from (select count(tc.name) from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase left join `tabAssertion` a on a.parent=tc.name group by a.parent having count(a.name)=2) as dc) da2\njoin\n(select count(*) as 'a3' from (select count(tc.name) from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase left join `tabAssertion` a on a.parent=tc.name group by a.parent having count(a.name)=3) as dc) da3\njoin\n(select count(*) as 'a4' from (select count(tc.name) from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase left join `tabAssertion` a on a.parent=tc.name group by a.parent having count(a.name)=4) as dc) da4\njoin\n(select count(*) as 'a5' from (select count(tc.name) from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase left join `tabAssertion` a on a.parent=tc.name group by a.parent having count(a.name)>=5) as dc) da5\njoin\n(select count(*) as 'a0' from (select count(tc.name) from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase left join `tabAssertion` a on a.parent=tc.name where a.name is null group by tc.name ) as dc) da0", 18 | "ref_doctype": "Test Case", 19 | "report_name": "Assertion Effectiveness", 20 | "report_type": "Query Report", 21 | "roles": [] 22 | } -------------------------------------------------------------------------------- /barista/barista/report/assertion_type_wise_test_cases/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/report/assertion_type_wise_test_cases/__init__.py -------------------------------------------------------------------------------- /barista/barista/report/assertion_type_wise_test_cases/assertion_type_wise_test_cases.json: -------------------------------------------------------------------------------- 1 | { 2 | "add_total_row": 0, 3 | "creation": "2020-03-05 17:11:15.301359", 4 | "disable_prepared_report": 0, 5 | "disabled": 0, 6 | "docstatus": 0, 7 | "doctype": "Report", 8 | "idx": 0, 9 | "is_standard": "Yes", 10 | "letter_head": "ElasticRun", 11 | "modified": "2020-04-03 18:58:19.941708", 12 | "modified_by": "Administrator", 13 | "module": "Barista", 14 | "name": "Assertion Type Wise Test Cases", 15 | "owner": "Administrator", 16 | "prepared_report": 0, 17 | "query": "select\n(ort.r+oft.f+owt.w +orvt.rv+oet.e) as 'Total Assertions',\nort.r as 'API RESPONSE VERIFICATION',\noft.f as 'FIELD VALUE VERIFICATION',\nowt.w AS 'WORKFLOW VERIFICATION',\norvt.rv AS 'RECORD VALIDATION',\noet.e AS 'ERROR VERIFICATION'\n\nfrom \n( select count(*) as 'r' from (select count(tc.name) as 'r' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase inner join `tabAssertion` a on a.parent=tc.name where a.assertion_type='RESPONSE' group by a.name) dr ) ort\n join\n( select count(*) as 'f' from (select count(tc.name) as 'f' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase inner join `tabAssertion` a on a.parent=tc.name where a.assertion_type='FIELD VALUE' group by a.name) df) oft\n join\n(select count(*) as 'w' from (select count(tc.name) as 'w' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase inner join `tabAssertion` a on a.parent=tc.name where a.assertion_type='WORKFLOW' group by a.name) dw) owt\n join\n(select count(*) 'rv' from (select count(tc.name) as 'rv' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase inner join `tabAssertion` a on a.parent=tc.name where a.assertion_type='RECORD VALIDATION' group by a.name) drv) orvt\n join\n(select count(*) as 'e' from (select count(tc.name) as 'e' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase inner join `tabAssertion` a on a.parent=tc.name where a.assertion_type='ERROR' group by a.name) de) oet", 18 | "ref_doctype": "Test Case", 19 | "report_name": "Assertion Type Wise Test Cases", 20 | "report_type": "Query Report", 21 | "roles": [] 22 | } -------------------------------------------------------------------------------- /barista/barista/report/error_statistics/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/report/error_statistics/__init__.py -------------------------------------------------------------------------------- /barista/barista/report/error_statistics/error_statistics.json: -------------------------------------------------------------------------------- 1 | { 2 | "add_total_row": 0, 3 | "creation": "2020-05-07 19:42:18.883697", 4 | "disable_prepared_report": 0, 5 | "disabled": 0, 6 | "docstatus": 0, 7 | "doctype": "Report", 8 | "idx": 0, 9 | "is_standard": "Yes", 10 | "letter_head": "ElasticRun", 11 | "modified": "2020-05-07 20:00:05.588666", 12 | "modified_by": "Administrator", 13 | "module": "Barista", 14 | "name": "Error Statistics", 15 | "owner": "Administrator", 16 | "prepared_report": 0, 17 | "query": "SELECT count(error) as 'Error Count',\n replace(METHOD, 'barista-', '') as 'Error:Text:1500'\nFROM `tabError Log`\nWHERE METHOD LIKE 'barista%%'\nGROUP BY error\nORDER BY METHOD;", 18 | "ref_doctype": "Error Log", 19 | "report_name": "Error Statistics", 20 | "report_type": "Query Report", 21 | "roles": [ 22 | { 23 | "role": "System Manager" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /barista/barista/report/test_execution_statistics/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/report/test_execution_statistics/__init__.py -------------------------------------------------------------------------------- /barista/barista/report/test_execution_statistics/test_execution_statistics.json: -------------------------------------------------------------------------------- 1 | { 2 | "add_total_row": 1, 3 | "creation": "2020-04-09 23:38:08.774486", 4 | "disable_prepared_report": 0, 5 | "disabled": 0, 6 | "docstatus": 0, 7 | "doctype": "Report", 8 | "idx": 0, 9 | "is_standard": "Yes", 10 | "javascript": "let apps = [];\nlet run_names = [];\ngetAppName();\ngetRunName();\nfrappe.query_reports[\"Test Execution Statistics\"] = {\n \"filters\": [{\n \"fieldname\": \"app_name\",\n \"label\": __(\"App\"),\n \"fieldtype\": \"Select\",\n \"default\": '',\n \"reqd\": 1,\n \"options\": apps\n },\n {\n \"fieldname\": \"run_name\",\n \"label\": __(\"Test Run Name\"),\n \"fieldtype\": \"Select\",\n \"default\": '',\n \"reqd\": 1,\n \"options\": run_names\n }\n ]\n}\n\nfunction getAppName() {\n apps = [];\n frappe.call({\n method: 'frappe.desk.reportview.get',\n args: {\n doctype: 'Module Def',\n fields: [\"`tabModule Def`.`app_name`\"],\n order_by: \"`tabModule Def`.`modified` desc\",\n start: 0,\n page_length: 2000,\n with_comment_count: true\n },\n freeze: true,\n freeze_message: 'Loading report please wait',\n async: false,\n callback: function (r) {\n if (!r.exc) {\n let all_apps = r.message.values;\n all_apps.forEach((a) => {\n let app_name = a[0];\n if (!apps.includes(app_name)) {\n apps.push(app_name);\n }\n });\n\n return apps;\n }\n }\n });\n}\n\nfunction getRunName() {\n run_names = [];\n frappe.call({\n type: 'GET',\n url: `${window.location.origin}/api/resource/Test Run Log?fields=[\"distinct test_run_name\"]&limit_page_length=9000`,\n freeze: true,\n freeze_message: 'Loading report please wait',\n async: false,\n callback: function (r) {\n if (!r.exc) {\n let all_runs = r.data;\n all_runs.forEach((a) => {\n let run_name = a['test_run_name'];\n if (!run_names.includes(run_name)) {\n run_names.push(run_name);\n }\n });\n\n return run_names;\n }\n }\n });\n}", 11 | "letter_head": "ElasticRun", 12 | "modified": "2020-05-14 09:37:39.360327", 13 | "modified_by": "Administrator", 14 | "module": "Barista", 15 | "name": "Test Execution Statistics", 16 | "owner": "Administrator", 17 | "prepared_report": 0, 18 | "query": "SELECT tr.test_suite AS 'Test Suite:Link/Test Suite',\n dtr.total_tr AS 'Total Test Cases:Int',\n dtrp.passed_tr AS 'Passed Test Cases:Int',\n ifnull(dtrf.failed_tr,0) AS 'Failed Test Cases:Int',\n\t((dtrp.passed_tr/dtr.total_tr)*100) as 'Percentage Passed:Percent'\nFROM `tabTest Result` tr\nINNER JOIN `tabTest Suite` ts ON ts.name=tr.test_suite\nLEFT JOIN\n (SELECT count(trs.name) AS 'total_tr',\n trs.test_suite\n FROM `tabTest Result` trs where trs.test_run_name=%(run_name)s\n GROUP BY trs.test_suite) dtr ON dtr.test_suite=tr.test_suite\nLEFT JOIN\n (SELECT count(trp.name) AS 'passed_tr',\n trp.test_suite\n FROM `tabTest Result` trp\n WHERE trp.test_case_status='Passed' and trp.test_run_name=%(run_name)s\n GROUP BY trp.test_suite) dtrp ON dtrp.test_suite=tr.test_suite\nLEFT JOIN\n (SELECT count(trf.name) AS 'failed_tr',\n trf.test_suite\n FROM `tabTest Result` trf\n WHERE trf.test_case_status='Failed' and trf.test_run_name=%(run_name)s\n GROUP BY trf.test_suite) dtrf ON dtrf.test_suite=tr.test_suite\nWHERE ts.app_name=%(app_name)s and tr.test_run_name=%(run_name)s\nGROUP BY tr.test_suite\norder by ifnull(dtrf.failed_tr,0)", 19 | "ref_doctype": "Test Result", 20 | "report_name": "Test Execution Statistics", 21 | "report_type": "Query Report", 22 | "roles": [ 23 | { 24 | "role": "System Manager" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /barista/barista/report/test_run_log_test_data_statistics/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/report/test_run_log_test_data_statistics/__init__.py -------------------------------------------------------------------------------- /barista/barista/report/test_run_log_test_data_statistics/test_run_log_test_data_statistics.json: -------------------------------------------------------------------------------- 1 | { 2 | "add_total_row": 0, 3 | "creation": "2020-05-07 20:34:49.425741", 4 | "disable_prepared_report": 0, 5 | "disabled": 0, 6 | "docstatus": 0, 7 | "doctype": "Report", 8 | "idx": 0, 9 | "is_standard": "Yes", 10 | "letter_head": "ElasticRun", 11 | "modified": "2020-05-11 14:22:45.026384", 12 | "modified_by": "Administrator", 13 | "module": "Barista", 14 | "name": "Test Run Log Test Data Statistics", 15 | "owner": "Administrator", 16 | "prepared_report": 0, 17 | "query": "SELECT trl.test_run_name AS 'Test Run Name',\n\tcount(distinct trl.test_data) as 'Total Test Data',\n\tstrl.create_count as 'Test Data Created',\n\tifnull(ftrl.failed_count,0) as 'Test Data Failed'\nFROM `tabTest Run Log` trl\nleft join (select itrl.test_run_name,count(distinct itrl.test_data) as 'create_count' from `tabTest Run Log` itrl where itrl.test_data_status='CREATED' group by itrl.test_run_name) strl on strl.test_run_name=trl.test_run_name\nleft join (select itrl.test_run_name,count(distinct itrl.test_data) as 'failed_count' from `tabTest Run Log` itrl where itrl.test_data_status='FAILED' group by itrl.test_run_name) ftrl on ftrl.test_run_name=trl.test_run_name\nGROUP BY trl.test_run_name\norder by trl.creation desc", 18 | "ref_doctype": "Test Run Log", 19 | "report_name": "Test Run Log Test Data Statistics", 20 | "report_type": "Query Report", 21 | "roles": [ 22 | { 23 | "role": "System Manager" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /barista/barista/report/types_of_test_case_on_doctype/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/barista/report/types_of_test_case_on_doctype/__init__.py -------------------------------------------------------------------------------- /barista/barista/report/types_of_test_case_on_doctype/types_of_test_case_on_doctype.json: -------------------------------------------------------------------------------- 1 | { 2 | "add_total_row": 1, 3 | "creation": "2020-03-05 14:53:01.492814", 4 | "disable_prepared_report": 0, 5 | "disabled": 0, 6 | "docstatus": 0, 7 | "doctype": "Report", 8 | "idx": 0, 9 | "is_standard": "Yes", 10 | "javascript": "let apps=[];\ngetAppName();\nfrappe.query_reports[\"Types of Test Case on Doctype\"] = {\n \"filters\": [{\n \"fieldname\": \"app_name\",\n \"label\": __(\"App\"),\n \"fieldtype\": \"Select\",\n \"default\": '',\n \"reqd\": 1,\n \"options\":apps\n }]\n}\n\nfunction getAppName() {\napps=[];\n frappe.call({\n method: 'frappe.desk.reportview.get',\n args: {\n doctype: 'Module Def',\n fields: [\"`tabModule Def`.`app_name`\"],\n order_by: \"`tabModule Def`.`modified` desc\",\n start: 0,\n page_length: 2000,\n with_comment_count: true\n },\n freeze: true,\n freeze_message: 'Loading report please wait',\n async: false,\n callback: function(r) {\n if (!r.exc) {\n let all_apps = r.message.values;\n all_apps.forEach((a) => {\n let app_name = a[0];\n if (!apps.includes(app_name)) {\n apps.push(app_name);\n }\n });\n \n return apps;\n }\n }\n });\n}", 11 | "letter_head": "ElasticRun", 12 | "modified": "2020-04-01 14:50:46.869462", 13 | "modified_by": "Administrator", 14 | "module": "Barista", 15 | "name": "Types of Test Case on Doctype", 16 | "owner": "Administrator", 17 | "prepared_report": 0, 18 | "query": "select dt.name as 'DocType',\ndtc.total_test_case as 'Total Test Cases:Number',\ndtcc.create_test_case as 'Create Type Test Cases',\ndtcu.update_test_case as 'Update Type Test Cases',\ndtcr.read_test_case as 'Read Type Test Cases',\ndtcd.delete_test_case as 'Delete Type Test Cases',\ndtcw.workflow_test_case as 'Workflow Type Test Cases',\ndtcf.function_test_case as 'Function Type Test Cases'\n\n from `tabDocType` dt inner join `tabModule Def` md on md.name=dt.module\nleft join (select count(distinct tc.name) as 'total_test_case',tc.testcase_doctype as 'doctype' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase group by tc.testcase_doctype) dtc on dtc.doctype=dt.name\nleft join (select count(distinct tc.name) as 'create_test_case',tc.testcase_doctype as 'doctype' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase where tc.testcase_type='CREATE' group by tc.testcase_doctype) dtcc on dtcc.doctype=dt.name\nleft join (select count(distinct tc.name) as 'update_test_case',tc.testcase_doctype as 'doctype' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase where tc.testcase_type='UPDATE' group by tc.testcase_doctype) dtcu on dtcu.doctype=dt.name\nleft join (select count(distinct tc.name) as 'read_test_case',tc.testcase_doctype as 'doctype' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase where tc.testcase_type='READ' group by tc.testcase_doctype) dtcr on dtcr.doctype=dt.name\nleft join (select count(distinct tc.name) as 'delete_test_case',tc.testcase_doctype as 'doctype' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase where tc.testcase_type='DELETE' group by tc.testcase_doctype) dtcd on dtcd.doctype=dt.name\nleft join (select count(distinct tc.name) as 'workflow_test_case',tc.testcase_doctype as 'doctype' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase where tc.testcase_type='WORKFLOW' group by tc.testcase_doctype) dtcw on dtcw.doctype=dt.name\nleft join (select count(distinct tc.name) as 'function_test_case',tc.testcase_doctype as 'doctype' from `tabTest Suite` ts join `tabTestcase Item` ti on ti.parent=ts.name join `tabTest Case` tc on tc.name=ti.testcase where tc.testcase_type='FUNCTION' group by tc.testcase_doctype) dtcf on dtcf.doctype=dt.name\n\nwhere md.app_name=%(app_name)s and dtc.total_test_case is not null\norder by dt.name", 19 | "ref_doctype": "Test Case", 20 | "report_name": "Types of Test Case on Doctype", 21 | "report_type": "Query Report", 22 | "roles": [] 23 | } -------------------------------------------------------------------------------- /barista/commands.py: -------------------------------------------------------------------------------- 1 | import click 2 | import frappe 3 | from frappe import _ 4 | from frappe.commands import pass_context, get_site 5 | from barista.barista.doctype.test_suite.run_test import RunTest, resolve_run_name 6 | 7 | 8 | @click.command('run-barista') 9 | @click.argument('app_name') 10 | @click.option('-r', '--run-name', default='Pass-1', help='Test Run Name for this execution run') 11 | @click.option('-s', '--suite', multiple=True, help='Test Suite name') 12 | @pass_context 13 | def run_barista(context, app_name, suite=[], run_name='Pass-1'): 14 | site = get_site(context) 15 | frappe.init(site=site) 16 | frappe.connect(site) 17 | 18 | run_name = resolve_run_name(run_name) 19 | print('Test Run Name - ', run_name) 20 | RunTest().run_complete_suite(app_name, list(suite), run_name) 21 | 22 | 23 | commands = [ 24 | run_barista 25 | ] 26 | -------------------------------------------------------------------------------- /barista/config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/config/__init__.py -------------------------------------------------------------------------------- /barista/config/barista.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | from frappe import _ 4 | 5 | 6 | def get_data(): 7 | return [ 8 | { 9 | "label": _("Barista"), 10 | "items": [ 11 | { 12 | "type": "doctype", 13 | "name": "Test Data", 14 | "description": _("Test Data") 15 | }, 16 | { 17 | "type": "doctype", 18 | "name": "Test Case", 19 | "description": _("Test Case") 20 | }, 21 | { 22 | "type": "doctype", 23 | "name": "Test Suite", 24 | "description": _("Test Suite") 25 | }, 26 | { 27 | "type": "doctype", 28 | "name": "Test Result", 29 | "description": _("Test Result") 30 | }, 31 | { 32 | "type": "doctype", 33 | "name": "Test Run Log", 34 | "description": _("Test Run Log") 35 | } 36 | ] 37 | 38 | }, 39 | { 40 | "label": "Reports", 41 | "items": [ 42 | { 43 | "type": "doctype", 44 | "link": "query-report/Assertion Effectiveness", 45 | "name": "Test Result", 46 | "description": _("Assertion Effectiveness"), 47 | "label": "Assertion Effectiveness" 48 | }, 49 | { 50 | "type": "doctype", 51 | "link": "query-report/Types of Test Case on Doctype", 52 | "name": "Test Result", 53 | "description": _("Types of Test Case on Doctype"), 54 | "label": "Types of Test Case on Doctype" 55 | }, 56 | { 57 | "type": "doctype", 58 | "link": "query-report/Assertion Type Wise Test Cases", 59 | "name": "Test Result", 60 | "description": _("Assertion Type Wise Test Cases"), 61 | "label": "Assertion Type Wise Test Cases" 62 | }, 63 | { 64 | "type": "doctype", 65 | "link": "query-report/Test Execution Statistics", 66 | "name": "Test Result", 67 | "description": _("Test Execution Statistics"), 68 | "label": "Test Execution Statistics" 69 | }, 70 | { 71 | "type": "doctype", 72 | "link": "query-report/Test Run Log Test Data Statistics", 73 | "name": "Test Result", 74 | "description": _("Test Run Log Test Data Statistics"), 75 | "label": "Test Run Log Test Data Statistics" 76 | } 77 | ] 78 | }, 79 | { 80 | "label": _('Test Coverage'), 81 | "items": [ 82 | { 83 | 'type': "doctype", 84 | 'name': 'Test Result', 85 | 'link': '#test-coverage', 86 | "label": "Test Coverage" 87 | } 88 | ] 89 | } 90 | ] 91 | -------------------------------------------------------------------------------- /barista/config/desktop.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | from frappe import _ 4 | 5 | def get_data(): 6 | return [ 7 | { 8 | "module_name": "Barista", 9 | "color": "grey", 10 | "icon": "octicon octicon-file-directory", 11 | "type": "module", 12 | "label": _("Barista") 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /barista/config/docs.py: -------------------------------------------------------------------------------- 1 | """ 2 | Configuration for docs 3 | """ 4 | 5 | # source_link = "https://github.com/[org_name]/barista" 6 | # docs_base_url = "https://[org_name].github.io/barista" 7 | # headline = "App that does everything" 8 | # sub_heading = "Yes, you got that right the first time, everything" 9 | 10 | def get_context(context): 11 | context.brand_html = "Barista" 12 | -------------------------------------------------------------------------------- /barista/hooks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | from . import __version__ as app_version 4 | 5 | app_name = "barista" 6 | app_title = "Barista" 7 | app_publisher = "elasticrun" 8 | app_description = "Frapp app test framework" 9 | app_icon = "octicon octicon-file-directory" 10 | app_color = "grey" 11 | app_email = "shreem.bansal@elastic.run" 12 | app_license = "MIT" 13 | 14 | # Includes in 15 | # ------------------ 16 | 17 | # include js, css files in header of desk.html 18 | # app_include_css = "/assets/barista/css/barista.css" 19 | # app_include_js = "/assets/barista/js/barista.js" 20 | 21 | # include js, css files in header of web template 22 | # web_include_css = "/assets/barista/css/barista.css" 23 | # web_include_js = "/assets/barista/js/barista.js" 24 | 25 | # include js in page 26 | # page_js = {"page" : "public/js/file.js"} 27 | 28 | # include js in doctype views 29 | # doctype_js = {"doctype" : "public/js/doctype.js"} 30 | # doctype_list_js = {"doctype" : "public/js/doctype_list.js"} 31 | # doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"} 32 | # doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"} 33 | 34 | # Home Pages 35 | # ---------- 36 | 37 | # application home page (will override Website Settings) 38 | # home_page = "login" 39 | 40 | # website user home page (by Role) 41 | # role_home_page = { 42 | # "Role": "home_page" 43 | # } 44 | 45 | # Website user home page (by function) 46 | # get_website_user_home_page = "barista.utils.get_home_page" 47 | 48 | # Generators 49 | # ---------- 50 | 51 | # automatically create page for each record of this doctype 52 | # website_generators = ["Web Page"] 53 | 54 | # Installation 55 | # ------------ 56 | 57 | # before_install = "barista.install.before_install" 58 | # after_install = "barista.install.after_install" 59 | 60 | # Desk Notifications 61 | # ------------------ 62 | # See frappe.core.notifications.get_notification_config 63 | 64 | # notification_config = "barista.notifications.get_notification_config" 65 | 66 | # Permissions 67 | # ----------- 68 | # Permissions evaluated in scripted ways 69 | 70 | # permission_query_conditions = { 71 | # "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", 72 | # } 73 | # 74 | # has_permission = { 75 | # "Event": "frappe.desk.doctype.event.event.has_permission", 76 | # } 77 | 78 | # Document Events 79 | # --------------- 80 | # Hook on document methods and events 81 | 82 | # doc_events = { 83 | # "*": { 84 | # "on_update": "method", 85 | # "on_cancel": "method", 86 | # "on_trash": "method" 87 | # } 88 | # } 89 | 90 | # Scheduled Tasks 91 | # --------------- 92 | 93 | # scheduler_events = { 94 | # "all": [ 95 | # "barista.tasks.all" 96 | # ], 97 | # "daily": [ 98 | # "barista.tasks.daily" 99 | # ], 100 | # "hourly": [ 101 | # "barista.tasks.hourly" 102 | # ], 103 | # "weekly": [ 104 | # "barista.tasks.weekly" 105 | # ] 106 | # "monthly": [ 107 | # "barista.tasks.monthly" 108 | # ] 109 | # } 110 | 111 | # Testing 112 | # ------- 113 | 114 | # before_tests = "barista.install.before_tests" 115 | 116 | # Overriding Whitelisted Methods 117 | # ------------------------------ 118 | # 119 | # override_whitelisted_methods = { 120 | # "frappe.desk.doctype.event.event.get_events": "barista.event.get_events" 121 | # } 122 | fixtures = [ 123 | "Test Data", 124 | "Test Case", 125 | "Test Suite", 126 | # "Testcase Item", 127 | # "Testdata Item", 128 | # "Assertion", 129 | # "Testdatafield" 130 | ] 131 | 132 | after_migrate = [ 133 | 'barista.barista.doctype.test_suite.run_test.fix_series', 134 | 'barista.barista.doctype.test_suite.run_test.fix_assertion_type_status', 135 | 'barista.barista.doctype.test_suite.run_test.fix_testcase_type_status', 136 | ] 137 | -------------------------------------------------------------------------------- /barista/modules.txt: -------------------------------------------------------------------------------- 1 | Barista -------------------------------------------------------------------------------- /barista/patches.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/patches.txt -------------------------------------------------------------------------------- /barista/public/sample-file.html: -------------------------------------------------------------------------------- 1 | 2 | SAMPLE FILE TO TEST ATTACHMENT 3 | -------------------------------------------------------------------------------- /barista/templates/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/templates/__init__.py -------------------------------------------------------------------------------- /barista/templates/pages/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/barista/templates/pages/__init__.py -------------------------------------------------------------------------------- /examples/Create User John Doe/test_case.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "assertion": [ 4 | { 5 | "assertion_type": "FIELD VALUE", 6 | "code": null, 7 | "docfield_name": "full_name", 8 | "docfield_value": "John Doe", 9 | "doctype_name": "User", 10 | "error_message": null, 11 | "module": "Core", 12 | "parent": "TestCase-0001", 13 | "parentfield": "assertion", 14 | "parenttype": "Test Case", 15 | "record_count": 1, 16 | "reference_field": "name", 17 | "response_regex": null, 18 | "value_type": "Fixed Value", 19 | "workflow_action": null, 20 | "workflow_state": null 21 | }, 22 | { 23 | "assertion_type": "FIELD VALUE", 24 | "code": null, 25 | "docfield_name": "username", 26 | "docfield_value": "john", 27 | "doctype_name": "User", 28 | "error_message": null, 29 | "module": "Core", 30 | "parent": "TestCase-0001", 31 | "parentfield": "assertion", 32 | "parenttype": "Test Case", 33 | "record_count": 1, 34 | "reference_field": "name", 35 | "response_regex": null, 36 | "value_type": "Fixed Value", 37 | "workflow_action": null, 38 | "workflow_state": null 39 | }, 40 | { 41 | "assertion_type": "RECORD VALIDATION", 42 | "code": null, 43 | "docfield_name": null, 44 | "docfield_value": null, 45 | "doctype_name": "User", 46 | "error_message": null, 47 | "module": "Core", 48 | "parent": "TestCase-0001", 49 | "parentfield": "assertion", 50 | "parenttype": "Test Case", 51 | "record_count": 1, 52 | "reference_field": "name", 53 | "response_regex": null, 54 | "value_type": "Fixed Value", 55 | "workflow_action": null, 56 | "workflow_state": null 57 | } 58 | ], 59 | "docstatus": 0, 60 | "doctype": "Test Case", 61 | "dummy_chkbox": 0, 62 | "function_name": null, 63 | "function_parameters": [], 64 | "is_test_data_on_different_doctype": 0, 65 | "json_parameter": null, 66 | "modified": "2020-04-28 13:46:22.976972", 67 | "name": "TestCase-0001", 68 | "parent": null, 69 | "parentfield": null, 70 | "parenttype": null, 71 | "test_case_docfield": null, 72 | "test_data": "TestData-0001", 73 | "test_data_docfield": null, 74 | "testcase_desc": "Test user creation John Doe", 75 | "testcase_doctype": "User", 76 | "testcase_name": "Test user creation John Doe", 77 | "testcase_type": "CREATE", 78 | "update_fields": [], 79 | "workflow_state": null 80 | }, 81 | { 82 | "assertion": [ 83 | { 84 | "assertion_type": "ERROR", 85 | "code": null, 86 | "docfield_name": null, 87 | "docfield_value": null, 88 | "doctype_name": "User", 89 | "error_message": "There should remain at least one System Manager", 90 | "module": "Core", 91 | "parent": "TestCase-0002", 92 | "parentfield": "assertion", 93 | "parenttype": "Test Case", 94 | "record_count": 1, 95 | "reference_field": "name", 96 | "response_regex": null, 97 | "value_type": "Fixed Value", 98 | "workflow_action": null, 99 | "workflow_state": null 100 | } 101 | ], 102 | "docstatus": 0, 103 | "doctype": "Test Case", 104 | "dummy_chkbox": 0, 105 | "function_name": null, 106 | "function_parameters": [], 107 | "is_test_data_on_different_doctype": 0, 108 | "json_parameter": null, 109 | "modified": "2020-04-28 14:12:17.391420", 110 | "name": "TestCase-0002", 111 | "parent": null, 112 | "parentfield": null, 113 | "parenttype": null, 114 | "test_case_docfield": null, 115 | "test_data": "TestData-0001", 116 | "test_data_docfield": null, 117 | "testcase_desc": "Delete created User John Doe", 118 | "testcase_doctype": "User", 119 | "testcase_name": "Delete created User John Doe", 120 | "testcase_type": "DELETE", 121 | "update_fields": [], 122 | "workflow_state": null 123 | } 124 | ] -------------------------------------------------------------------------------- /examples/Create User John Doe/test_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "app_name": "frappe", 4 | "description": "Create User John Doe", 5 | "docfield_value": [ 6 | { 7 | "code_desc": "Examples - \nCurrency: round(random.uniform(500.12, 22000.34),2) \nDate: datetime.date.today() + datetime.timedelta(days(random.randrange(0,15,1)))\n\nDatetime:\ndatetime.datetime.now() + datetime.timedelta(minutes(random.randrange(0,200,2)))\nFloat: round(random.uniform(0, 22000.34),2)\nInt: random.randrange(0,200,1)\n", 8 | "docfield_code": null, 9 | "docfield_code_value": "Fixed Value", 10 | "docfield_fieldname": "enabled", 11 | "docfield_value": "1", 12 | "doctype_name": "User", 13 | "is_default": 0, 14 | "linkfield_name": null, 15 | "parent": "TestData-0001", 16 | "parentfield": "docfield_value", 17 | "parenttype": "Test Data" 18 | }, 19 | { 20 | "code_desc": "Examples - \nCurrency: round(random.uniform(500.12, 22000.34),2) \nDate: datetime.date.today() + datetime.timedelta(days(random.randrange(0,15,1)))\n\nDatetime:\ndatetime.datetime.now() + datetime.timedelta(minutes(random.randrange(0,200,2)))\nFloat: round(random.uniform(0, 22000.34),2)\nInt: random.randrange(0,200,1)\n", 21 | "docfield_code": null, 22 | "docfield_code_value": "Fixed Value", 23 | "docfield_fieldname": "email", 24 | "docfield_value": "john.doe@example.com", 25 | "doctype_name": "User", 26 | "is_default": 0, 27 | "linkfield_name": null, 28 | "parent": "TestData-0001", 29 | "parentfield": "docfield_value", 30 | "parenttype": "Test Data" 31 | }, 32 | { 33 | "code_desc": "Examples - \nCurrency: round(random.uniform(500.12, 22000.34),2) \nDate: datetime.date.today() + datetime.timedelta(days(random.randrange(0,15,1)))\n\nDatetime:\ndatetime.datetime.now() + datetime.timedelta(minutes(random.randrange(0,200,2)))\nFloat: round(random.uniform(0, 22000.34),2)\nInt: random.randrange(0,200,1)\n", 34 | "docfield_code": null, 35 | "docfield_code_value": "Fixed Value", 36 | "docfield_fieldname": "first_name", 37 | "docfield_value": "John", 38 | "doctype_name": "User", 39 | "is_default": 0, 40 | "linkfield_name": null, 41 | "parent": "TestData-0001", 42 | "parentfield": "docfield_value", 43 | "parenttype": "Test Data" 44 | }, 45 | { 46 | "code_desc": "Examples - \nCurrency: round(random.uniform(500.12, 22000.34),2) \nDate: datetime.date.today() + datetime.timedelta(days(random.randrange(0,15,1)))\n\nDatetime:\ndatetime.datetime.now() + datetime.timedelta(minutes(random.randrange(0,200,2)))\nFloat: round(random.uniform(0, 22000.34),2)\nInt: random.randrange(0,200,1)\n", 47 | "docfield_code": null, 48 | "docfield_code_value": "Fixed Value", 49 | "docfield_fieldname": "last_name", 50 | "docfield_value": "Doe", 51 | "doctype_name": "User", 52 | "is_default": 0, 53 | "linkfield_name": null, 54 | "parent": "TestData-0001", 55 | "parentfield": "docfield_value", 56 | "parenttype": "Test Data" 57 | }, 58 | { 59 | "code_desc": "Examples - \nCurrency: round(random.uniform(500.12, 22000.34),2) \nDate: datetime.date.today() + datetime.timedelta(days(random.randrange(0,15,1)))\n\nDatetime:\ndatetime.datetime.now() + datetime.timedelta(minutes(random.randrange(0,200,2)))\nFloat: round(random.uniform(0, 22000.34),2)\nInt: random.randrange(0,200,1)\n", 60 | "docfield_code": null, 61 | "docfield_code_value": "Fixed Value", 62 | "docfield_fieldname": "send_welcome_email", 63 | "docfield_value": "0", 64 | "doctype_name": "User", 65 | "is_default": 0, 66 | "linkfield_name": null, 67 | "parent": "TestData-0001", 68 | "parentfield": "docfield_value", 69 | "parenttype": "Test Data" 70 | }, 71 | { 72 | "code_desc": "Examples - \nCurrency: round(random.uniform(500.12, 22000.34),2) \nDate: datetime.date.today() + datetime.timedelta(days(random.randrange(0,15,1)))\n\nDatetime:\ndatetime.datetime.now() + datetime.timedelta(minutes(random.randrange(0,200,2)))\nFloat: round(random.uniform(0, 22000.34),2)\nInt: random.randrange(0,200,1)\n", 73 | "docfield_code": null, 74 | "docfield_code_value": "Code", 75 | "docfield_fieldname": "roles", 76 | "docfield_value": null, 77 | "doctype_name": "User", 78 | "is_default": 0, 79 | "linkfield_name": "TestData-0003", 80 | "parent": "TestData-0001", 81 | "parentfield": "docfield_value", 82 | "parenttype": "Test Data" 83 | } 84 | ], 85 | "docstatus": 0, 86 | "doctype": "Test Data", 87 | "doctype_name": "User", 88 | "doctype_type": "Master", 89 | "existing_record": "", 90 | "insert_script": null, 91 | "modified": "2020-04-28 14:10:06.666268", 92 | "module_name": "Core", 93 | "name": "TestData-0001", 94 | "parent": null, 95 | "parentfield": null, 96 | "parenttype": null, 97 | "status": "PENDING", 98 | "test_record_name": "", 99 | "use_script": 0 100 | }, 101 | { 102 | "app_name": "frappe", 103 | "description": "Create new Role System User", 104 | "docfield_value": [ 105 | { 106 | "code_desc": "Examples - \nCurrency: round(random.uniform(500.12, 22000.34),2) \nDate: datetime.date.today() + datetime.timedelta(days(random.randrange(0,15,1)))\n\nDatetime:\ndatetime.datetime.now() + datetime.timedelta(minutes(random.randrange(0,200,2)))\nFloat: round(random.uniform(0, 22000.34),2)\nInt: random.randrange(0,200,1)\n", 107 | "docfield_code": null, 108 | "docfield_code_value": "Fixed Value", 109 | "docfield_fieldname": "role_name", 110 | "docfield_value": "System User", 111 | "doctype_name": "Role", 112 | "is_default": 0, 113 | "linkfield_name": null, 114 | "parent": "TestData-0002", 115 | "parentfield": "docfield_value", 116 | "parenttype": "Test Data" 117 | } 118 | ], 119 | "docstatus": 0, 120 | "doctype": "Test Data", 121 | "doctype_name": "Role", 122 | "doctype_type": "Master", 123 | "existing_record": "", 124 | "insert_script": null, 125 | "modified": "2020-04-28 14:10:06.774969", 126 | "module_name": "Core", 127 | "name": "TestData-0002", 128 | "parent": null, 129 | "parentfield": null, 130 | "parenttype": null, 131 | "status": "PENDING", 132 | "test_record_name": "", 133 | "use_script": 0 134 | }, 135 | { 136 | "app_name": "frappe", 137 | "description": "Assign new role System User to John Doe", 138 | "docfield_value": [ 139 | { 140 | "code_desc": "Examples - \nCurrency: round(random.uniform(500.12, 22000.34),2) \nDate: datetime.date.today() + datetime.timedelta(days(random.randrange(0,15,1)))\n\nDatetime:\ndatetime.datetime.now() + datetime.timedelta(minutes(random.randrange(0,200,2)))\nFloat: round(random.uniform(0, 22000.34),2)\nInt: random.randrange(0,200,1)\n", 141 | "docfield_code": null, 142 | "docfield_code_value": "Code", 143 | "docfield_fieldname": "role", 144 | "docfield_value": null, 145 | "doctype_name": "Has Role", 146 | "is_default": 0, 147 | "linkfield_name": "TestData-0002", 148 | "parent": "TestData-0003", 149 | "parentfield": "docfield_value", 150 | "parenttype": "Test Data" 151 | } 152 | ], 153 | "docstatus": 0, 154 | "doctype": "Test Data", 155 | "doctype_name": "Has Role", 156 | "doctype_type": "Master", 157 | "existing_record": "", 158 | "insert_script": null, 159 | "modified": "2020-04-28 14:10:06.884365", 160 | "module_name": "Core", 161 | "name": "TestData-0003", 162 | "parent": null, 163 | "parentfield": null, 164 | "parenttype": null, 165 | "status": "PENDING", 166 | "test_record_name": "", 167 | "use_script": 0 168 | } 169 | ] -------------------------------------------------------------------------------- /examples/Create User John Doe/test_suite.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "app_name": "frappe", 4 | "docstatus": 0, 5 | "doctype": "Test Suite", 6 | "modified": "2020-04-28 13:55:15.731499", 7 | "name": "Create User", 8 | "parent": null, 9 | "parentfield": null, 10 | "parenttype": null, 11 | "suite_name": "Create User", 12 | "test_data": [ 13 | { 14 | "parent": "Create User", 15 | "parentfield": "test_data", 16 | "parenttype": "Test Suite", 17 | "test_data": "TestData-0002", 18 | "test_data_description": "Create new Role System User" 19 | } 20 | ], 21 | "testcase": [ 22 | { 23 | "parent": "Create User", 24 | "parentfield": "testcase", 25 | "parenttype": "Test Suite", 26 | "testcase": "TestCase-0001", 27 | "testcase_name": "Test user creation John Doe" 28 | }, 29 | { 30 | "parent": "Create User", 31 | "parentfield": "testcase", 32 | "parenttype": "Test Suite", 33 | "testcase": "TestCase-0002", 34 | "testcase_name": "Delete created User John Doe" 35 | } 36 | ] 37 | } 38 | ] -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | ### Barista Examples 2 | 3 | - Copy paste the files (3 files) present in the individual example folder into **_barista/barista/fixtures_** folder 4 | - Then do the **_bench migrate_** 5 | 6 | -------------------------------------------------------------------------------- /images/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/images/dashboard.png -------------------------------------------------------------------------------- /images/sample-manual-testcase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/images/sample-manual-testcase.png -------------------------------------------------------------------------------- /images/tc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/images/tc.gif -------------------------------------------------------------------------------- /images/td.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/images/td.gif -------------------------------------------------------------------------------- /images/test-result.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElasticRun/barista/661c43536105fae7a724fd1af7eef928e1426444/images/test-result.gif -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | License: MIT -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | frappe 2 | coverage==5.0.4 -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from setuptools import setup, find_packages 3 | import re, ast 4 | 5 | with open('requirements.txt') as f: 6 | install_requires = f.read().strip().split('\n') 7 | 8 | # get version from __version__ variable in barista/__init__.py 9 | _version_re = re.compile(r'__version__\s+=\s+(.*)') 10 | 11 | with open('barista/__init__.py', 'rb') as f: 12 | version = str(ast.literal_eval(_version_re.search( 13 | f.read().decode('utf-8')).group(1))) 14 | 15 | setup( 16 | name='barista', 17 | version=version, 18 | description='Frappe App Test Framework', 19 | author='ElasticRun', 20 | author_email='shreem.bansal@elastic.run', 21 | packages=find_packages(), 22 | zip_safe=False, 23 | include_package_data=True, 24 | install_requires=install_requires 25 | ) 26 | --------------------------------------------------------------------------------