learningequality / studio

Content curation tools for Kolibri
https://studio.learningequality.org/
MIT License
111 stars 159 forks source link

Update subject line of storage request to include email address #4418

Closed bjester closed 1 month ago

bjester commented 7 months ago

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

it would make it easier to track responses in the Google Group

From @laurenlichtman

bjester commented 7 months ago

The code in question: https://github.com/learningequality/studio/blob/aa92a57ecb6bec5956380b920bf60d4f667cba48/contentcuration/contentcuration/views/settings.py#L186

sanketkanade commented 7 months 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():

Mock user email

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}"
sanketkanade commented 7 months ago

is this approach right

bjester commented 7 months ago

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.

sanketkanade commented 7 months ago

Yeah sure may I work on this task

MisRob commented 7 months ago

Sound so :)! Thanks @sanketkanade, I will assign you.

Abhishekzod007 commented 6 months ago

Hi @sanketkanade are you still working on this ?

Abhishekzod007 commented 6 months ago

Hi @bjester, can I take up this issue now I reckon Sanket is not planning on continuing this

akolson commented 5 months ago

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.

akolson commented 5 months ago

@Abhishekzod007, please feel free to tag @bjester or myself incase you have any questions regarding the issue.

Abhishekzod007 commented 5 months ago

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.

bjester commented 5 months ago

@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.

bjester commented 5 months ago

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

MisRob commented 3 months ago

Hi @Abhishekzod007, are you working on this or would it be better to unassign?

bmortella commented 1 month ago

Hi! May I work on this one?

AlexVelezLl commented 1 month ago

Hi @bmortella! Sure! Thanks for your interest in contributing to this issue. I will assign this to you :open_hands:.

bmortella commented 1 month ago

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: image

They do appear if I click but the checkbox doesn't change unless I click on it, too: image image

Thought I'd let you know just in case.

MisRob commented 1 month ago

Thanks @bmortella! Would you like to copy the bug you've found to a new issue?

bmortella commented 1 month ago

Hi @MisRob, I dug a little further and I believe #4525 is the issue I encountered.

MisRob commented 1 month ago

Alright, thanks for checking on it @bmortella