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
Merge requests
!4
Feature/activity log
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feature/activity log
feature/activity-log
into
develop
Overview
0
Commits
10
Pipelines
0
Changes
17
Merged
Neda Moeini
requested to merge
feature/activity-log
into
develop
3 weeks ago
Overview
0
Commits
10
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
version 5
version 6
5b082ef2
3 weeks ago
version 5
7264217a
3 weeks ago
version 4
3502bacd
3 weeks ago
version 3
1a7d601d
3 weeks ago
version 2
b7456861
3 weeks ago
version 1
fc025137
3 weeks ago
develop (base)
and
version 6
latest version
5b1da7cd
10 commits,
3 weeks ago
version 6
5b082ef2
9 commits,
3 weeks ago
version 5
7264217a
8 commits,
3 weeks ago
version 4
3502bacd
7 commits,
3 weeks ago
version 3
1a7d601d
6 commits,
3 weeks ago
version 2
b7456861
5 commits,
3 weeks ago
version 1
fc025137
4 commits,
3 weeks ago
Show latest version
1 file
+
27
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
test/test_file_validator/test_file_validator_endpoints.py
+
27
−
0
Options
@@ -5,6 +5,8 @@ from django.core.files.uploadedfile import SimpleUploadedFile
from
django.urls.base
import
reverse
from
rest_framework.test
import
APIClient
from
sage_validation.accounts.models
import
UserActivityLog
UPLOAD_FILE_URL
=
reverse
(
"
upload-file
"
)
@@ -57,7 +59,32 @@ def test_csv_export_with_data(api_client: APIClient) -> None:
response
=
api_client
.
get
(
url
)
assert
UserActivityLog
.
objects
.
count
()
==
1
assert
response
.
status_code
==
200
assert
response
[
"
Content-Disposition
"
]
==
"
attachment; filename=Validated_BK1234.csv
"
assert
b
"
AccountNumber,TransactionDate,TransactionReference
"
in
response
.
content
assert
b
"
12345,01/03/2024,BK1234
"
in
response
.
content
@pytest.mark.django_db
def
test_activity_log_creation_on_csv_export
(
api_client
:
APIClient
)
->
None
:
"""
Test that a UserActivityLog is created when exporting a CSV file.
"""
url
=
reverse
(
"
export-file
"
)
# Simulate session data
session
=
api_client
.
session
session
[
"
validated_csv
"
]
=
[
{
"
AccountNumber
"
:
"
12345
"
,
"
TransactionDate
"
:
"
01/03/2024
"
,
"
TransactionReference
"
:
"
BK1234
"
},
]
session
[
"
input_file_hash
"
]
=
"
123456
"
session
.
save
()
response
=
api_client
.
get
(
url
)
assert
response
.
status_code
==
200
log
=
UserActivityLog
.
objects
.
first
()
assert
log
.
action
==
"
download
"
assert
log
.
input_file_hash
==
"
123456
"
assert
log
.
output_file_hash
==
UserActivityLog
.
generate_file_hash
(
session
[
"
validated_csv
"
])
assert
log
.
name
==
"
Validated_BK1234.csv
"
Loading