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

Remove libpagure #71

Merged
merged 24 commits into from
May 29, 2019
Merged

Conversation

lachmanfrantisek
Copy link
Member

@lachmanfrantisek lachmanfrantisek commented May 20, 2019

  • Remove OurPagure.
  • Implement forking logic and PR methods.
  • First part of implementing the Pagure classes without libpagure.
  • Add string representation for PRComment and PullRequest.

Fix #64
Fix #67


TODO:

  • readonly mode
  • tests

How to test?

from ogr.services.pagure import PagureService
from ogr.abstract import PRStatus


service = PagureService(token="???_PAGURE_TOKEN_???")

# Play with the API

print(service.user.get_username())
project = service.get_project(repo="colin", namespace="rpms")
print(project.get_commit_statuses("339a19b0bbc766d0c6cdbbc2ef5a32c0de9f7551")[0])
print(project.get_tags())

fork = project.get_fork()
print(fork.exists())

project.fork_create()

for pr in project.get_pr_list(status=PRStatus.all):
    print(pr)

pr = project.get_pr_info(3)
print(pr)
for c in project.get_pr_comments(3):
    print(c)

print(fork.is_fork)
print(fork.is_forked())

Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
@lachmanfrantisek
Copy link
Member Author

@jscotka
I've removed the old read-only setup for libpagure. Do you have some idea how it can be done in the current state without libpagure?
Thanks!

Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
@rpitonak
Copy link
Contributor

I played with it a little bit, and I got:

>>> project = service.get_project(repo="conu", namespace="rpms")
>>> for pr in project.get_pr_list(status=PRStatus.all):
...     print(pr)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/home/vagrant/ogr/ogr/abstract.py", line 39, in __str__
    f"PullRequest("
TypeError: 'NoneType' object is not subscriptable

Signed-off-by: Frantisek Lachman <flachman@redhat.com>
@lachmanfrantisek
Copy link
Member Author

@rpitonak

Good catch. Fixed.

@rpitonak
Copy link
Contributor

Good catch. Fixed.

Thanks, I tried all of the commands above on conu and it worked smoothly. Nice work so far!

@lachmanfrantisek
Copy link
Member Author

Thanks, I tried all of the commands above on conu and it worked smoothly.

That was just an example. Whole API should be already implemented...

Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Copy link
Member

@jpopelka jpopelka left a comment

Choose a reason for hiding this comment

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

Haven't tried yet

ogr/services/pagure.py Outdated Show resolved Hide resolved
ogr/services/pagure.py Outdated Show resolved Hide resolved
ogr/services/pagure.py Show resolved Hide resolved
ogr/services/pagure.py Outdated Show resolved Hide resolved
ogr/services/pagure.py Show resolved Hide resolved
ogr/services/pagure.py Outdated Show resolved Hide resolved
lachmanfrantisek and others added 4 commits May 22, 2019 18:18
Co-Authored-By: Jiri Popelka <jpopelka@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Copy link
Contributor

@jscotka jscotka left a comment

Choose a reason for hiding this comment

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

few issues regarding to easier mocking of pagure API.

ogr/services/pagure.py Outdated Show resolved Hide resolved
ogr/services/pagure.py Outdated Show resolved Hide resolved
@jscotka
Copy link
Contributor

jscotka commented May 23, 2019

@jscotka
I've removed the old read-only setup for libpagure. Do you have some idea how it can be done in the current state without libpagure?
Thanks!

@lachmanfrantisek by readonly mode are directly wrappend method in services/pagure, so no change here.

Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
@lachmanfrantisek
Copy link
Member Author

lachmanfrantisek commented May 23, 2019

@lachmanfrantisek by readonly mode are directly wrappend method in services/pagure, so no change here.

Sorry, I meant the request caching...

@jscotka :

Ahh now I understand, theoretically it should be easier, to create there some class like previous our_pagure, what will contain just these methods for requests and parsing responses, and it then use inside service/pagure, and do not have request handling directly inside services/pagure, and then mocking will just replace implementation of this class. maybe it could lead also to better readability, of code.

file could be named something like: pagure_request and could contain class like Pagure what will provide API call methods,

and theoretically, as nice improvement, it could also implement generic JSON API call what will then replace https://github.com/packit-service/packit/blob/master/packit/ogr_services.py#L28 in packit ;-)

practically structure could be as it is, and then there will be in raw_request decision, that in case there is mocking, call another wrapper, so solution will be simple, just it needs to consolidate api_call and raw_request to one method, or api_call will call raw request, what will handle it then

Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
@lachmanfrantisek
Copy link
Member Author

@jscotka Can you take another look?

Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Copy link
Contributor

@jscotka jscotka left a comment

Choose a reason for hiding this comment

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

Hi Frantisek, now it seems very well from perspective of mocking and representing request-response object. thanks a lot for these changes

@lachmanfrantisek
Copy link
Member Author

Hi Frantisek, now it seems very well from perspective of mocking and representing request-response object. thanks a lot for these changes

Thanks, but the loading response values does not work now...

@lachmanfrantisek
Copy link
Member Author

@jscotka Do you know, why the loading does not work and I need to dump to dict manually (c31b895)?

Signed-off-by: Frantisek Lachman <flachman@redhat.com>
Signed-off-by: Frantisek Lachman <flachman@redhat.com>
@lachmanfrantisek
Copy link
Member Author

lachmanfrantisek commented May 27, 2019

I have a working version with direct yaml dumping but it does not go through the pre-commit yaml validation.

@jscotka Do we want to use unsafe in pre-commit validation (only the syntax check) or use current setup?

Copy link
Contributor

@jscotka jscotka left a comment

Choose a reason for hiding this comment

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

changes seems well. LGTM from perspective of mocking

@lachmanfrantisek
Copy link
Member Author

OK, let's leave it as is and we can change it to object-dumping later.

@lachmanfrantisek
Copy link
Member Author

@TomasTomecek @jpopelka Do you want to take a look at this? Otherwise, we can merge.

@lachmanfrantisek lachmanfrantisek changed the title WIP: remove libpagure Remove libpagure May 29, 2019
@lachmanfrantisek lachmanfrantisek added the pagure Related to Pagure implementation. label May 29, 2019
@TomasTomecek
Copy link
Member

Let's merge and test in production :P

@lachmanfrantisek lachmanfrantisek merged commit 60386a5 into packit:master May 29, 2019
@lachmanfrantisek lachmanfrantisek deleted the no-libpagure branch May 29, 2019 07:46
@jpopelka
Copy link
Member

test in production

Do we need to do any changes in packit? I still see OurPagure in packit's tests

@lachmanfrantisek
Copy link
Member Author

Do we need to do any changes in packit? I still see OurPagure in packit's tests.

Good point.

The API should state the same, but mocking probably needs some changes...

@jpopelka
Copy link
Member

Filled new issue packit/packit#355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pagure Related to Pagure implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

libpagure.Pagure expects '/' not in repo attribute libpagure has changed
5 participants