Skip to content

feat: add a daily inspirational quote #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jan 28, 2021

Conversation

zohary89
Copy link
Contributor

  • load quotes from a json file (copied from a free api) to the db
  • the daily quote is displayed in the home page, until the calendar view will be developed.
  • add tests
  • extra small change in agenda.html- I add a link from the event's title to the event's view page.

@codecov-io
Copy link

codecov-io commented Jan 24, 2021

Codecov Report

Merging #128 (70edfc4) into develop (df1ef8d) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #128      +/-   ##
===========================================
- Coverage    99.57%   99.48%   -0.09%     
===========================================
  Files           28       30       +2     
  Lines          932      972      +40     
===========================================
+ Hits           928      967      +39     
- Misses           4        5       +1     
Impacted Files Coverage Δ
app/database/models.py 94.02% <100.00%> (+0.48%) ⬆️
app/internal/quotes/daily_quotes.py 100.00% <100.00%> (ø)
app/internal/quotes/load_quotes.py 100.00% <100.00%> (ø)
app/main.py 97.36% <100.00%> (-2.64%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df1ef8d...70edfc4. Read the comment docs.

@@ -51,6 +52,18 @@ def profile_test_client():
Base.metadata.drop_all(bind=test_engine)


@pytest.fixture(scope="session")
def home_test_client():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit pity that agenda_test_client, profile_test_client and this are very similar.
I wonder if there is a pritter way for that?

from app.internal.quotes import load_quotes


def get_quotes_amount(session):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add that as part of the table class, and then you can use it in is_quotes_table_empty too.
In the tests you can do something like:

assert is_quotes_table_empty  # count == 0
assert not is_quotes_table_empty # count > 0

@zohary89 zohary89 requested a review from yammesicka January 25, 2021 22:23
def test_get_page(self, client):
resp = client.get(self.URL)
def test_get_page(self, home_test_client):
resp = home_test_client.get(self.URL)
assert resp.status_code == 200
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could change it to assert resp.status_code.ok

<!-- I chose to add the quote day to the home page until the relavent calendar view will be developed. -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would suggest adding a demo html for adding it because in the future the daily quote might not be there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment!
Since its just a simple sentence, which changes every day, I see no reason to upload a demo page. I think it will eventually appear in the main view of the calendar, but anyway I'll follow up on it and make sure to move it accordingly...

def get_quotes_from_json() -> List[Dict[str, Optional[str]]]:
"""This function reads all of the daily quotes from a specific JSON file.
The JSON file content is copied from the free API:
'https://type.fit/api/quotes'. I saved the content so the API won't be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id suggest adding docs in the Google doc string style https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
also, there are some typos in the text.
Overall excellent job!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! :)

Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, very nice code! I've added few of my insights :)

@@ -51,6 +52,18 @@ def profile_test_client():
Base.metadata.drop_all(bind=test_engine)


@pytest.fixture(scope="session")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use the general test client? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used get_db in 'home' function (because I added the quote to the home page), so I needed to have a specific test client for home to replace the get_db with the get_test_db. Also refers to the next comment- I could not use the regular test client and had to change the test code.

I don't know yet what will be appeared at the home page, but I wanted that when the user enters the main calendar page he will see the quote, so I chose to display it at 'home' for now.. Do you think I should move it?
Thank you!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used get_db in 'home' function (because I added the quote to the home page), so I needed to have a specific test client for home to replace the get_db with the get_test_db. Also refers to the next comment- I could not use the regular test client and had to change the test code.

Sababa, but I see there are already 3 similar code segments :$
Can you extract most of the code to a single function and refactor all the functions to just call it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know yet what will be appeared at the home page, but I wanted that when the user enters the main calendar page he will see the quote, so I chose to display it at 'home' for now.. Do you think I should move it?

That's OK, the home page will be refactored soon

def test_get_page(self, client):
resp = client.get(self.URL)
assert resp.status_code == 200
def test_get_page(self, home_test_client):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to leave it as it is

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please roll back the changes to the variable name? :)

@@ -0,0 +1,37 @@
import pytest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job here! :)

def test_get_page(self, client):
resp = client.get(self.URL)
assert resp.status_code == 200
def test_get_page(self, home_test_client):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please roll back the changes to the variable name? :)

@@ -51,6 +52,18 @@ def profile_test_client():
Base.metadata.drop_all(bind=test_engine)


@pytest.fixture(scope="session")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used get_db in 'home' function (because I added the quote to the home page), so I needed to have a specific test client for home to replace the get_db with the get_test_db. Also refers to the next comment- I could not use the regular test client and had to change the test code.

Sababa, but I see there are already 3 similar code segments :$
Can you extract most of the code to a single function and refactor all the functions to just call it?

@@ -51,6 +52,18 @@ def profile_test_client():
Base.metadata.drop_all(bind=test_engine)


@pytest.fixture(scope="session")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know yet what will be appeared at the home page, but I wanted that when the user enters the main calendar page he will see the quote, so I chose to display it at 'home' for now.. Do you think I should move it?

That's OK, the home page will be refactored soon

class TestHome:
URL = "/"

def test_get_page(self, client):
resp = client.get(self.URL)
assert resp.status_code == 200
assert resp.status_code == status.HTTP_200_OK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer .ok

@yammesicka yammesicka merged commit 5762677 into PythonFreeCourse:develop Jan 28, 2021
yammesicka added a commit that referenced this pull request Feb 5, 2021
* update ORM and added export for an event

* update ORM and added export for an event

* Added in app shareable events

* docs: add type annotation and fix folder structure

* docs: add type annotation and fix folder structure

* docs: fix documentation

* feat: get weather forecast for date and location

* feat: get weather forecast for date and location

* add: tests

* set up commit

* add: timezone support

* add: session management

* fix bug

* split conftest file

* split conftest file

* move "utils" folder into "internal" folder

* working day view with jinja2 template

* with tests for pytest

* feat: get weather forecast - fixes according to requested changes.

* change file structure

* feat: get weather forecast - fixes according to requested changes.

* first functioning day-view html, css and router

* feat: Basic responsive calender day view page

Added dayview template with css and router.
An tempreroy event class with,
 processing function for the day view to work.

* feat: Basic responsive calender day view page

Added dayview template with css and router.
An tempreroy event class with,
 processing function for the day view to work.
fixed after taking notes.

* fix lint now for sure

* more lint

* feat: get weather forecast - fix requirements.txt

* feat: enable invited users to view events

* feat: flake8 changes

* fix: requirements bug

* fix: requirements bug

* feat: flake8 changes

* add: tests

* feat: flake8 changes

* add: tests

* feat: flake8 changes

* edit: file structure

* edit: file structure

* feat: get weather forecast - fix changes & add cache support

* feat: get weather forecast - fix changes & add cache support

* feat: get weather forecast - fix changes & add cache support

* feat: add route tests

* feat: get weather forecast - fix changes & add cache support

* feat: get weather forecast - fix changes & add cache support

* fix: test bug

* remove: config.py

* after all notes and started use the orm

* fix: type annotation

* feat: get weather forecast - add API mocking

* feat: get weather forecast - add API mocking

* feat: get weather forecast - add API mocking

* feat: get weather forecast - add API mocking

* fixed: changed "size" var in html and and more acuurate typing

* deleted some testing lines

* add requirements missing

* add: minor changes

* feat: flake8 changes

* @hadaskedar2020

* feat: get weather forecast - add API mocking

* feat: weather forecast - add API mocking & improve coverage

* feat: weather forecast - add API mocking & improve coverage

* feat: weather forecast - add API mocking & improve coverage

* feat: weather forecast - add API mocking & improve coverage

* feat: weather forecast - add API mocking & improve coverage

* fixed: statements of event select more accurate

* new test and lint fix

* added more contants abd more notes taken

* feat: weather forecast - move feat to internal

* Delete Scripts directory

* update constants

* more notes

* forgot white space

* feat: gets a link to the suitable image of a given event content. (#70)

* feat: gets a link to the suitable image of a given event content.

* Add basic update event (#100)

* Add basic update event

* Added search feature (#98)

* Added search feature

* Add telegram client (#111)

Add telegram client

* feat: Add a feature for sharing information with a WhatsApp account (#83)

* feat: Add a feature to share to a WhatsApp account

* Feature/logging system (#112)

* feat: first logging commit

Co-authored-by: Liad Noam <LiadN@Taldor.corp>

* feat: add a daily inspirational quote (#128)

* feat: add a daily inspirational quote

* Feature/delete event (#139)

* basic delete event

* Add an event delete function

* Fix flake8

* Deleting an unnecessary model

* Extract lines from try

* fix: modify psycopg2 dependency (#164)

* Bugfix/logging system (#158)

* Changed logging config to be received by separate parameters for simplicity, removed option to receive configuration as a dict, added .vscode to gitignore

* removed logging_config file which is no longer needed

* Fixing merge conflicts - missing whitespace on config.py.example

Co-authored-by: Liad Noam <LiadN@Taldor.corp>

* Added checking for zoom link and saving the event (#122)

* Added checking for zoom link and saving the event

* Feature/import to calendar (#119)

* feat: import file to calendar

* docs: adding community standard documents (#173)

* Feat: Event View Backend (#159)

* Moved the route to top of file

* Feature/send email (#88)

* Added files for sending invitations by email

This includes
- templates
- routes and internal code
- configuration
- tests

Co-authored-by: leddest <46251307+leddest@users.noreply.github.com>
Co-authored-by: Ellen <ellenc345@gmail.com>

* Feature/translation - add an functionality to translate event data etc. (#167)

* translation feature stuff

* Update event - Improving the code (#138)

* Add basic update event

* Support categories for events (#137)

* Support categories for events

* Style/grid (#106)

* Hello Wrold

* Creating Html Template

* Calendar dates calculation intigrating with html, HTML\CSS improvments.

* Tests for calender_grid.py, changing function according to currections, fixing bugs

* linting bug fixing

* before merge with develop

* Creating a Day object and days subclasses, changing all function and tests according to the new objects, Changing front to get information from Day objects, Re-arranging  calendar.html grid stracture to be render by weeks, adding js functionality for day view section, adding css effects on daily event display

* fix lintings

* fix lintings

* tests next week scroll

* js updates

* Calendar Scrolling with javascript

* Fix lintings

* Fix lintings

* Calendar infinit scrolling ducplicates weeks bug fixed

* seetings global parameters for calendar.py

* Js - changing to fetch, removing jquery, fixing hint tpying, adding Week object, changing tests

* Front end bug fixing

* Fix linting

* Fix lintings

* Fix lintings

* fixing syntax

* Get user local date and time when enter calendar.

* Fix lintings

* Fix lintings

* Fix lintings

* Bugs fixing

* Bugs fixing

* Bugs fixing

* Bugs fixing

* JS alerts removal

* Fix Lintings

* Js syntext fixing

* Bugs fixing

* Bugs fixing

* Js fixing varibales and adding div element to request.

* Develop Update

* Js - eliminate global parameters

* Linting fixing

* Fix Lintings

* Fix flake8

* syntac fixing

* Feature/translations workflow (#150)

* feat: add translations workflow

* fix(translations-workflow): fix doc

* fix(translations-workflow): fixed code and added automatic commit

Co-authored-by: Gonny <1@1>

* Revert "Feature/translations workflow (#150)" (#208)

This reverts commit 2e6a2c2.

* feat: Add zodiac signs to the day & month view + refactor json data loader (#155)

* feat: Add zodiac signs to the day/month view +

* Change calendar link from '#' to '/' to get the home page (#194)

when clicking on the logo

* Style/grid (#200)

* Js scrolling duplication days fixed

Co-authored-by: Idan Pelled <pelled.idan@gmail.com>
Co-authored-by: Hadas Kedar <hadasit@gmail.com>
Co-authored-by: Sagi Zaid Or <sagi@eretz.org.il>
Co-authored-by: sagizaidor <71097154+sagizaidor@users.noreply.github.com>
Co-authored-by: hadaskedar2020 <70915466+hadaskedar2020@users.noreply.github.com>
Co-authored-by: nir9696 <35953934+nir9696@users.noreply.github.com>
Co-authored-by: efratush <70986341+efratush@users.noreply.github.com>
Co-authored-by: advaa123 <64307569+advaa123@users.noreply.github.com>
Co-authored-by: leddest <46251307+leddest@users.noreply.github.com>
Co-authored-by: nelliei <71073199+nelliei@users.noreply.github.com>
Co-authored-by: Liad-n <52039539+Liad-n@users.noreply.github.com>
Co-authored-by: Liad Noam <LiadN@Taldor.corp>
Co-authored-by: zohary89 <71074080+zohary89@users.noreply.github.com>
Co-authored-by: Ron Huberfeld <32178925+ron-huberfeld@users.noreply.github.com>
Co-authored-by: Ap1234567 <58956386+Ap1234567@users.noreply.github.com>
Co-authored-by: Nir-P <70997974+Nir-P@users.noreply.github.com>
Co-authored-by: Ode <odechann@gmail.com>
Co-authored-by: Anna Shtirberg <71028276+annashtirberg@users.noreply.github.com>
Co-authored-by: Ellen <ellenc345@gmail.com>
Co-authored-by: ivarshav <ivarshav@users.noreply.github.com>
Co-authored-by: Aviad <38867584+aviadamar@users.noreply.github.com>
Co-authored-by: Gonzom <gonnym@gmail.com>
Co-authored-by: Gonny <1@1>
Co-authored-by: YairEn <71101056+YairEn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants