Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sage Validation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
Sage Validation
Commits
568c07d1
Commit
568c07d1
authored
3 weeks ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Improve validation error handling for missing nominal analysis fields in CSV upload
parent
c3bf9f52
No related branches found
No related tags found
1 merge request
!7
Improve validation error handling for missing nominal analysis fields in CSV upload
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sage_validation/file_validator/forms.py
+2
-0
2 additions, 0 deletions
sage_validation/file_validator/forms.py
test/test_file_validator/test_forms.py
+18
-0
18 additions, 0 deletions
test/test_file_validator/test_forms.py
with
20 additions
and
0 deletions
sage_validation/file_validator/forms.py
+
2
−
0
View file @
568c07d1
...
...
@@ -245,6 +245,8 @@ class CSVUploadForm(forms.Form):
nominal_account_name
=
row
.
get
(
nominal_account_field
)
if
not
cc
or
not
dep
or
not
nominal_account_name
:
errors
.
append
(
f
"
Row
{
index
}
: Missing values in
'
{
cc_field
}
'
,
'
{
dep_field
}
'
, or
"
f
"'
{
nominal_account_field
}
'
.
"
)
continue
cc_type
=
cost_centre_map
.
get
(
cc
)
...
...
This diff is collapsed.
Click to expand it.
test/test_file_validator/test_forms.py
+
18
−
0
View file @
568c07d1
...
...
@@ -93,6 +93,24 @@ def test_validate_nc_cc_dep_combination_against_meo_sage_account(
in
str
(
form
.
errors
[
"
file
"
][
0
]))
def
test_validate_nc_cc_dep_combination_against_meo_sage_account_blank_values
(
sample_input_file
:
SimpleUploadedFile
,
mock_meo_database
:
MagicMock
)
->
None
:
"""
Test validation for nominal analysis fields against MEO valid Sage accounts.
"""
modified_file
=
create_modified_csv
(
sample_input_file
,
{
"
NominalAnalysisNominalCostCentre/1
"
:
""
,
})
form
=
CSVUploadForm
(
files
=
{
"
file
"
:
modified_file
})
assert
not
form
.
is_valid
()
assert
(
"
Row 1: Missing values in
'
NominalAnalysisNominalCostCentre/1
'
,
'
NominalAnalysisNominalDepartment/1
'
,
"
"
or
'
NominalAnalysisNominalAccountNumber/1
'
.
"
in
str
(
form
.
errors
[
"
file
"
][
0
])
)
def
test_cheque_fields_must_be_empty
(
sample_input_file
:
SimpleUploadedFile
,
mock_meo_database
:
MagicMock
)
->
None
:
"""
Test that cheque fields must be empty.
"""
modified_file
=
create_modified_csv
(
sample_input_file
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment