-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part of #9
- Loading branch information
Showing
8 changed files
with
516 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"issues_data": { | ||
"pull_request": { | ||
"html_url": "" | ||
}, | ||
"state": "", | ||
"labels": [], | ||
"created_at": "" | ||
}, | ||
"pr_data": { | ||
"base": { | ||
"repo": { | ||
"owner": { | ||
"login": "" | ||
} | ||
} | ||
}, | ||
"head": { | ||
"user": { | ||
"login": "" | ||
} | ||
}, | ||
"merged": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import json | ||
import copy | ||
|
||
|
||
class PRData: | ||
def __init__(self, data: dict = None): | ||
if data == None: | ||
with open('./client_test/models/empty_pr_data.json') as file: | ||
self.data = json.load(file) | ||
else: | ||
self.data = data | ||
|
||
def with_pr_url(self, url: str = 'some-url'): | ||
data = copy.deepcopy(self.data) | ||
data['issues_data']['pull_request']['html_url'] = url | ||
return PRData(data) | ||
|
||
def with_label(self, label_to_add: str = None): | ||
data = copy.deepcopy(self.data) | ||
if label_to_add == None: | ||
label_number = len(data["issues_data"]["labels"]) + 1 | ||
label_to_add = f'label-{label_number}' | ||
|
||
data['issues_data']['labels'].append({'name': label_to_add}) | ||
return PRData(data) | ||
|
||
def with_created_at(self, created_at: str = '2014-04-24T16:34:47Z'): | ||
data = copy.deepcopy(self.data) | ||
data['issues_data']['created_at'] = created_at | ||
return PRData(data) | ||
|
||
def with_owner(self, owner: str = 'owner_user_id'): | ||
data = copy.deepcopy(self.data) | ||
data['pr_data']['base']['repo']['owner']['login'] = owner | ||
return PRData(data) | ||
|
||
def with_pr_raised_by(self, pr_raised_by: str = 'pr_raised_by_user_id'): | ||
data = copy.deepcopy(self.data) | ||
data['pr_data']['head']['user']['login'] = pr_raised_by | ||
return PRData(data) | ||
|
||
def with_merged(self, merged=False): | ||
data = copy.deepcopy(self.data) | ||
data['pr_data']['merged'] = merged | ||
return PRData(data) | ||
|
||
def with_state(self, state='some_state'): | ||
data = copy.deepcopy(self.data) | ||
data['issues_data']['state'] = state | ||
return PRData(data) | ||
|
||
def with_defaults(self): | ||
return PRData(self.data).with_pr_url()\ | ||
.with_label()\ | ||
.with_label()\ | ||
.with_created_at()\ | ||
.with_owner()\ | ||
.with_pr_raised_by()\ | ||
.with_merged()\ | ||
.with_state() |
Oops, something went wrong.