Closed bjester closed 1 month ago
can we Update the code to dynamically generate the subject line with the user account's email address doing this modification : subject = f"Kolibri Studio storage request from {user_email}" then we can just write test cases to ensure that the email subject line is being generated correctly. def test_storage_request_email_subject():
user_email = "user@example.com"
# Call the function or method responsible for generating the email subject
subject = generate_storage_request_subject(user_email)
# Assert that the subject matches the expected format
assert subject == f"Kolibri Studio storage request from {user_email}"
is this approach right
Hi @sanketkanade, since this is such a small change, and testing that a string is formatted as expected is so trivial, it's preferred to go a bit further and add test coverage on StorageSettingsView
which would include the change. I think with some mocking, it should be a small amount of additional effort.
Yeah sure may I work on this task
Sound so :)! Thanks @sanketkanade, I will assign you.
Hi @sanketkanade are you still working on this ?
Hi @bjester, can I take up this issue now I reckon Sanket is not planning on continuing this
HI @Abhishekzod007, since @sanketkanade has not being responsive for quite a while now, I'll assign it to you.
@sanketkanade please feel free to let us know in case there is another issue in our backlog you would like to take up, otherwise thanks for your interest.
@Abhishekzod007, please feel free to tag @bjester or myself incase you have any questions regarding the issue.
Hii @akolson first I want to thankyou for assigning me this issue. I already done the first change Kolibri Studio storage request from <user account's email address> and the second part was to add some tests. Can you please tell me the file location where I have to do that and can you elaborate about the test which you wanted here.
@Abhishekzod007
There isn't existing test coverage for this view. Generally, we structure the test files the same way they're structured in the codebase. So this means you would create contentcuration/contentcuration/tests/views/test_settings.py
for the file contentcuration/contentcuration/view/settings.py
.
For the test, you should use the mock library to create a mock form
and request
, as well as patch-mock send_mail
in the settings.py
. Then call the view's form_valid
method with the mocked form
object. You then would assert the patched send_mail
is called with the appropriately structured email subject. You may need to mock some data in form.cleaned_data
too.
Here's an example test you could follow somewhat, implementing my instructions above https://github.com/learningequality/studio/blob/unstable/contentcuration/contentcuration/tests/views/test_users.py#L139
Hi @Abhishekzod007, are you working on this or would it be better to unassign?
Hi! May I work on this one?
Hi @bmortella! Sure! Thanks for your interest in contributing to this issue. I will assign this to you :open_hands:.
Added a test case following @bjester's instructions. Let me know if anything is missing :)
(Going a little off-topic)
Sorry if there is an issue about this (I couldn't find one), but I noticed the channels are not being displayed for me in the form. Tested with Safari and Firefox:
They do appear if I click but the checkbox doesn't change unless I click on it, too:
Thought I'd let you know just in case.
Thanks @bmortella! Would you like to copy the bug you've found to a new issue?
Hi @MisRob, I dug a little further and I believe #4525 is the issue I encountered.
Alright, thanks for checking on it @bmortella
Background
Studio users can request additional storage for their account through their account settings. This process sends an email to a static address of a Google group with the information.
Desired behavior
The subject line should say
Kolibri Studio storage request from <user account's email address>
. Since this is a small change, adding some test coverage on the code would be worthwhile.Current behavior
The subject line always says
Kolibri Studio storage request
. There is no test coverage.Value add
From @laurenlichtman