Skip to content
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

[WIP] Implement missing API functions #8

Closed
wants to merge 16 commits into from

Conversation

philipflohr
Copy link
Contributor

@philipflohr philipflohr commented Oct 17, 2020

As written in #7 my work is not yet finished and is not ready to be pulled.

Besides the missing functionality there are no tests.
Also I'm actually not sure if the remote_query_id flag should default to True or False - I chose False for a simple reason: without explicitly allowing a query with this default value it's only possible to update an attendance record which already exists on the Personio servers.

@codecov-io
Copy link

codecov-io commented Oct 17, 2020

Codecov Report

Merging #8 into master will decrease coverage by 9.31%.
The diff coverage is 17.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #8      +/-   ##
==========================================
- Coverage   84.49%   75.18%   -9.32%     
==========================================
  Files           6        6              
  Lines         729      826      +97     
==========================================
+ Hits          616      621       +5     
- Misses        113      205      +92     
Impacted Files Coverage Δ
src/personio_py/client.py 53.02% <11.49%> (-26.15%) ⬇️
src/personio_py/models.py 81.08% <29.26%> (-3.85%) ⬇️

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 2bb8a03...f4476cb. Read the comment docs.

@klamann
Copy link
Contributor

klamann commented Oct 27, 2020

@philipflohr thanks for your work on this PR. I'm gonna make a short review of the code now and add a few comments.

One thing that would be really important though are tests. The most useful and thorough tests we have right now are in test_mock_api.py, where the response from the server for certain inputs is mocked. Would you be willing to add tests for the API methods you have implemented?

Comment on lines 292 to 294
def set_client(self, client: 'Personio'):
self._client = client

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if there is a need for a setter here, this looks like java code to me ^^

We can change create_attendances() so that this is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Solution proposal: I could change the objects client to be public accessible

Comment on lines 670 to 671
def _create(self, client: 'Personio'):
pass
self._client.create_attendances([self])
Copy link
Contributor

Choose a reason for hiding this comment

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

I left this part unfinished... client should have been an optional parameter and the function should choose between client and self._client or raise an error if both are None. I should probably fix this myself ^^

Comment on lines +296 to +297
Note: Attendances are created sequentially. This function stops on first error.
All attendance records before the error will be created, all records after the error will be skipped.
Copy link
Contributor

Choose a reason for hiding this comment

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

were you able to verify that this works? The documentation does not indicate what happens when there are errors in only some of the attendance records.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not documented but I verified this using a personio test account

Copy link
Contributor

Choose a reason for hiding this comment

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

in this case, maybe we should tell the user which attendances have been created and which have failed? We could return a dictionary like

{
  'success': [list of attendance objects that were created],
  'failure': [list of attendance objects that were not created],
}

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 only did a very quick test of this behavior, but IIRC the response does not contain the information where the error happened.

Philip Flohr added 6 commits October 28, 2020 13:45
Raises error if no client is available
Changed Absence definition: half_day_start, half_day_end are now bool
Implemented Absence.to_body_params
Added test
@philipflohr
Copy link
Contributor Author

@klamann are the test provided for absences ok like this?

@philipflohr
Copy link
Contributor Author

@klamann can you give any update on this or do you have an idea when you'll have a little time for it?

@klamann
Copy link
Contributor

klamann commented Nov 17, 2020

Hey @philipflohr, sorry for letting you wait. I plan to review your changes on the weekend, maybe earlier if I get the chance.
Are you finished with your additions or do you want to add more to this PR?

@philipflohr
Copy link
Contributor Author

There are still test missing for attendances. Could have a quick look into the absences tests? If they are ok I'll provide similar tests for attendances

@klamann
Copy link
Contributor

klamann commented Nov 20, 2020

I had a look at the tests; what I like is that there are many tests that work with a live Personio instance and where many edge cases are covered. What I'm missing however are tests that can run as part of the CI pipeline without a live Personio instance, like those defined in test_mock_api.py. I know those are more difficult to define, but they are really important to ensure that the API functions are still working when other parts of the implementation are changed.

Also, I'm starting to worry that this PR is getting out of hand, there's too much structural change in here (e.g. the refactoring of the tests in multiple files) and it's becoming increasingly more difficult to review. I think it would be wise to split this into several smaller PRs that are easier to edit and review.
We could easily merge the small changes to client.py and if we have focused PRs for attendances & absences, I could help you with the mock API tests.
With the current state of the PR, I don't feel comfortable to merge the whole package.

@philipflohr
Copy link
Contributor Author

I'm closing this PR in favor of multiple smaller PRs.

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.

3 participants