Update test-canopy_service_test.R#37
Conversation
Summary of ChangesHello @aliciamontesinos, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the test file test-canopy_service_test.R by removing old data loading logic in favor of using pre-loaded test data, and translating test descriptions from Spanish to English. These are good improvements. My review includes two suggestions to further enhance the test code by applying the DRY principle to avoid redundant calculations and by clarifying the intent of some test assertions for better maintainability.
| expect_equal(fila$Fc, 18) | ||
| expect_equal(fila$Fc, sum(mysite_com[mysite_com$Canopy=="Artemisia_barrelieri" ,"Frequency"])) | ||
| expect_equal(fila$Fc, sum(Amoladeras_int[Amoladeras_int$Canopy=="Artemisia_barrelieri" ,"Frequency"])) | ||
| expect_equal(fila$Fro, 5111) | ||
| expect_equal(fila$Fro, sum(mysite_com[mysite_com$Canopy=="Open" ,"Frequency"])) | ||
| expect_equal(fila$Fro, sum(Amoladeras_int[Amoladeras_int$Canopy=="Open" ,"Frequency"])) |
There was a problem hiding this comment.
These assertions are a bit confusing as they test fila$Fc and fila$Fro against both a hardcoded value and a calculated sum. This implicitly tests that the hardcoded value equals the sum. It would be clearer to separate these concerns. You can test the function's output against the hardcoded value, and then have a separate assertion to ensure the input data hasn't changed, i.e., that the sum still equals the hardcoded value.
expect_equal(fila$Fc, 18)
expect_equal(sum(Amoladeras_int[Amoladeras_int$Canopy=="Artemisia_barrelieri" ,"Frequency"]), 18)
expect_equal(fila$Fro, 5111)
expect_equal(sum(Amoladeras_int[Amoladeras_int$Canopy=="Open" ,"Frequency"]), 5111)
No description provided.