Skip to content

Conversation

@IdanPelled
Copy link
Contributor

  • Expand the user model and the event model
  • Add invitation model
  • Create in app shareable events
  • Create foundations for sending email invitations (export to .ics file)

@codecov-io
Copy link

codecov-io commented Jan 16, 2021

Codecov Report

Merging #44 (3400fe9) into develop (17a43c6) will increase coverage by 1.23%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##           develop       #44      +/-   ##
============================================
+ Coverage    98.76%   100.00%   +1.23%     
============================================
  Files           11        16       +5     
  Lines          243       424     +181     
============================================
+ Hits           240       424     +184     
+ Misses           3         0       -3     
Impacted Files Coverage Δ
app/database/database.py 100.00% <ø> (ø)
app/database/models.py 100.00% <100.00%> (ø)
app/internal/agenda_events.py 100.00% <100.00%> (+6.25%) ⬆️
app/internal/events.py 100.00% <100.00%> (ø)
app/internal/utils.py 100.00% <100.00%> (ø)
app/main.py 100.00% <100.00%> (+5.88%) ⬆️
app/routers/agenda.py 100.00% <100.00%> (ø)
app/routers/event.py 100.00% <100.00%> (ø)
app/routers/export.py 100.00% <100.00%> (ø)
app/routers/invitation.py 100.00% <100.00%> (ø)
... and 9 more

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 17a43c6...3400fe9. Read the comment docs.

app/main.py Outdated


@app.get("/invitations")
def view_invitations(request: Request, db: Session = Depends(get_db)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you like to create a specific route for invitations?

@@ -0,0 +1,103 @@
from datetime import datetime
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between files under internal/ and utils/ folders?

Copy link
Member

Choose a reason for hiding this comment

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

+1. Maybe should be under app/routers/export.py?

from sqlalchemy.orm import Session, sessionmaker

from app.database.models import Event, Invitation, User, Base

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider: create a separate db_entities conftest file.
As far as I know, this is how you reference the other files:
pytest_plugins = ['module1', 'module2']
(stackoverflow answer)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice ;)

@@ -0,0 +1,85 @@
from typing import List, Dict, Union
Copy link
Member

Choose a reason for hiding this comment

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

I believe this file should be in app/routers/share.py?

https://fastapi.tiangolo.com/tutorial/bigger-applications/

app/main.py Outdated
"request": request,
"username": current_username,
"events": upcouming_events
"events": upcoming_events
Copy link
Member

Choose a reason for hiding this comment

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

Add trailing ,

@@ -0,0 +1,103 @@
from datetime import datetime
Copy link
Member

Choose a reason for hiding this comment

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

+1. Maybe should be under app/routers/export.py?

@yammesicka
Copy link
Member

Please change the PR to merge into PythonFreeCourse:develop

@ivarshav ivarshav mentioned this pull request Jan 17, 2021
@IdanPelled IdanPelled changed the base branch from main to develop January 17, 2021 12:44
email='test.email@gmail.com',
)
yield test_user
delete_instance(session, test_user)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that you thought of the concept of DRY :)
Personally, I prefer to read tests with their logic as clear as possible - it's easier to understand what is going on in the test, and when.
So, I'm not sure if delete_instance function is more useful or more helps tests to be ambiguous :)
What do you think?

end: Optional[date]) -> List[Event]:
"""filter events by a time frame."""

return [
Copy link
Member

Choose a reason for hiding this comment

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

To match the behavior of the original filter, I might use yield from (event for ...)

return False


def get_all_user_events(session: Session, user_id: int) -> List[Event]:
Copy link
Member

Choose a reason for hiding this comment

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

This should prolly be in the routers/user.py file



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

Nicely done

"""Adds an optional field if it exists."""

if user_event.location:
data += [('location', user_event.location)]
Copy link
Member

Choose a reason for hiding this comment

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

Prefer .append to use the current list and not create a new one :)


def does_user_exist(
session: Session,
*_, user_id=None,
Copy link
Member

Choose a reason for hiding this comment

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

You can use just plain * (without giving it a name)

description = Column(String, default="Happy new user!")
avatar = Column(String, default="profile.png")

is_active = Column(Boolean, default=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be wiser to set it as False if its about being connected to the calendar

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 agree

@yammesicka yammesicka closed this Jan 21, 2021
@yammesicka yammesicka deleted the branch PythonFreeCourse:develop January 21, 2021 02:36
@yammesicka yammesicka reopened this Jan 21, 2021
from app.database.models import Event


def sort_by_date(events: List[Event]) -> List[Event]:
Copy link
Member

Choose a reason for hiding this comment

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

I think we should add /sort to event.py in routers

def sort_by_date(events: List[Event]) -> List[Event]:
"""Sorts the events by the start of the event."""

temp = events.copy()
Copy link
Member

Choose a reason for hiding this comment

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

No need to, sorted already makes a copy of it

for participant in participants:

if does_user_exist(email=participant, session=session):
temp: list = emails['registered']
Copy link
Member

Choose a reason for hiding this comment

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

List[] (of what?)

"""Sends invitations to all event participants."""

registered, unregistered = (
sort_emails(participants, session=session).values()
Copy link
Member

Choose a reason for hiding this comment

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

Prefer explicitly asking the dictionary, in case the sort_emails will change and the order will be tempered:

emails = sort_email(...)
registered, unregistered = emails['registered'], emails['unregistered']


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

Choose a reason for hiding this comment

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

.ok

@yammesicka yammesicka merged commit ab45a02 into PythonFreeCourse:develop Jan 23, 2021
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.

6 participants