Skip to content

Commit

Permalink
Merge pull request #395 from mfocko/pagure-project-str
Browse files Browse the repository at this point in the history
Add is_fork and username to PagureProject __str__

Reviewed-by: https://github.com/apps/packit-as-a-service
  • Loading branch information
softwarefactory-project-zuul[bot] authored Apr 24, 2020
2 parents 8d3a95f + 7728c08 commit 5d10f5d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ogr/services/pagure/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def __init__(
self.namespace = namespace

def __str__(self) -> str:
return f'PagureProject(namespace="{self.namespace}", repo="{self.repo}")'
fork_info = ""
if self._is_fork:
fork_info = f', username="{self._username}", is_fork={self._is_fork}'
return f'PagureProject(namespace="{self.namespace}", repo="{self.repo}"{fork_info})'

def __eq__(self, o: object) -> bool:
if not isinstance(o, PagureProject):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
_requre:
DataTypes: 1
key_strategy: StorageKeysInspectFull
version_storage_file: 2
unittest.case:
tests.integration.test_pagure:
ogr.services.pagure.user:
ogr.services.pagure.service:
requests.sessions:
requre.objects:
requests.sessions:
send:
- metadata:
latency: 0.8971946239471436
module_call_list:
- unittest.case
- tests.integration.test_pagure
- ogr.services.pagure.user
- ogr.services.pagure.service
- requests.sessions
- requre.objects
- requests.sessions
- send
output:
__store_indicator: 2
_content:
username: mfocko
_next: null
elapsed: 0.2
encoding: null
headers:
Connection: Keep-Alive
Content-Length: '26'
Content-Security-Policy: default-src 'self';script-src 'self'
'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' https://apps.fedoraproject.org;
style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; object-src
'none';base-uri 'self';img-src 'self' https:;
Content-Type: application/json
Date: Fri, 01 Nov 2019 13-36-03 GMT
Keep-Alive: timeout=5, max=100
Referrer-Policy: same-origin
Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips
mod_wsgi/3.4 Python/2.7.5
Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiWVRZelpEQmpZemczTldaa1pUWXhZV1ptT1dZMlkyWTFOMlV4T0dWa05EY3hZalkzTmpZek1BPT0ifX0.EYRyew.BuB19eIOGCc9z2zT-uzFxvR0LG8;
Expires=Mon, 25-May-2020 12:52:11 GMT; Secure; HttpOnly; Path=/
Strict-Transport-Security: max-age=31536000; includeSubDomains;
preload
X-Content-Type-Options: nosniff
X-Frame-Options: ALLOW-FROM https://pagure.io/
X-Xss-Protection: 1; mode=block
raw: !!binary ""
reason: OK
status_code: 200
5 changes: 5 additions & 0 deletions tests/integration/test_pagure.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ def test_fork(self):
urls = fork.get_git_urls()
assert "{username}" not in urls["ssh"]

def test_fork_in_str(self):
str_representation = str(self.ogr_fork)
assert 'username="' in str_representation
assert "is_fork=True" in str_representation

def test_nonexisting_fork(self):
ogr_project_non_existing_fork = self.service.get_project(
namespace=None,
Expand Down

0 comments on commit 5d10f5d

Please sign in to comment.