From 5cda2b6ae46e4245dbad7508268621b764b540d9 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 5 Feb 2019 12:57:13 +0100 Subject: [PATCH 01/12] add ProjectMembership --- pyvo/model/project.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pyvo/model/project.py b/pyvo/model/project.py index 1d32616..90ff44c 100644 --- a/pyvo/model/project.py +++ b/pyvo/model/project.py @@ -55,3 +55,18 @@ class MembershipSummary(Instantiated, PivotalResource): ) last_viewed_at = fields.DateTimeField() +class ProjectMembership(Instantiated, PivotalResource): + + created_at = fields.DateTimeField() + updated_at = fields.DateTimeField() + person_id = fields.IntField() + project_id = fields.IntField() + role = fields.StringField( + validators=OneOf('owner', + 'member', 'viewer', 'inactive')) + project_color = fields.StringField() + favorite = fields.BoolField() + last_viewed_at = fields.DateTimeField() + wants_comment_notification_emails = fields.BoolField() + will_receive_mention_notifications_or_emails = fields.BoolField() + kind = fields.StringField() From f3591c638dc760b9b068a585878bab03d4904ead Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 5 Feb 2019 15:04:14 +0100 Subject: [PATCH 02/12] wire up ProjectMembership and Person to be part of generators --- pyvo/model/__init__.py | 6 ++++-- pyvo/model/person.py | 21 +++++++++++++++++++-- pyvo/model/project.py | 16 ---------------- pyvo/model/story.py | 1 + 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/pyvo/model/__init__.py b/pyvo/model/__init__.py index 2979fcf..e1afe6e 100644 --- a/pyvo/model/__init__.py +++ b/pyvo/model/__init__.py @@ -4,7 +4,7 @@ class ModelNotFound(Exception): pass def generate_resources(response, client=None): - from person import Me + from person import Me, Person, ProjectMembership from project import Project from story import Story, Epic from metadata import Label @@ -20,7 +20,9 @@ def generate(resource): 'story': Story, 'epic': Epic, 'label': Label, - 'error': Error + 'error': Error, + 'project_membership': ProjectMembership, + 'person': Person }.get(kind) if resource_class is None: diff --git a/pyvo/model/person.py b/pyvo/model/person.py index d041761..d4c449f 100644 --- a/pyvo/model/person.py +++ b/pyvo/model/person.py @@ -1,4 +1,4 @@ -from base import PivotalResource, Instantiated, fields +from base import PivotalResource, Instantiated, fields, OneOf from metadata import TimeZone from project import MembershipSummary @@ -23,4 +23,21 @@ class Person(Instantiated, PivotalResource): email = fields.StringField(required=True) initials = fields.StringField() username = fields.StringField() - kind = fields.StringField() \ No newline at end of file + kind = fields.StringField() + +class ProjectMembership(Instantiated, PivotalResource): + + created_at = fields.DateTimeField() + updated_at = fields.DateTimeField() + person_id = fields.IntField() + project_id = fields.IntField() + role = fields.StringField( + validators=OneOf('owner', + 'member', 'viewer', 'inactive')) + project_color = fields.StringField() + favorite = fields.BoolField() + last_viewed_at = fields.DateTimeField() + wants_comment_notification_emails = fields.BoolField() + will_receive_mention_notifications_or_emails = fields.BoolField() + kind = fields.StringField() + person = fields.EmbeddedField(Person) \ No newline at end of file diff --git a/pyvo/model/project.py b/pyvo/model/project.py index 90ff44c..2b63329 100644 --- a/pyvo/model/project.py +++ b/pyvo/model/project.py @@ -54,19 +54,3 @@ class MembershipSummary(Instantiated, PivotalResource): validators=OneOf('owner', 'member', 'viewer', 'inactive') ) last_viewed_at = fields.DateTimeField() - -class ProjectMembership(Instantiated, PivotalResource): - - created_at = fields.DateTimeField() - updated_at = fields.DateTimeField() - person_id = fields.IntField() - project_id = fields.IntField() - role = fields.StringField( - validators=OneOf('owner', - 'member', 'viewer', 'inactive')) - project_color = fields.StringField() - favorite = fields.BoolField() - last_viewed_at = fields.DateTimeField() - wants_comment_notification_emails = fields.BoolField() - will_receive_mention_notifications_or_emails = fields.BoolField() - kind = fields.StringField() diff --git a/pyvo/model/story.py b/pyvo/model/story.py index 7e71a72..a510266 100644 --- a/pyvo/model/story.py +++ b/pyvo/model/story.py @@ -18,6 +18,7 @@ class Story(Instantiated, PivotalResource): accepted_at = fields.DateTimeField() deadline = fields.DateTimeField() requested_by_id = fields.IntField() + owned_by_id = fields.IntField() owner_ids = fields.ListField(int) label_ids = fields.ListField(int) task_ids = fields.ListField(int) From a17486725fd443d579324959a98a76d1fbe4c499 Mon Sep 17 00:00:00 2001 From: Charly Date: Wed, 6 Feb 2019 10:01:59 +0100 Subject: [PATCH 03/12] add Task to generator list --- pyvo/model/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyvo/model/__init__.py b/pyvo/model/__init__.py index e1afe6e..c844e95 100644 --- a/pyvo/model/__init__.py +++ b/pyvo/model/__init__.py @@ -6,7 +6,7 @@ class ModelNotFound(Exception): def generate_resources(response, client=None): from person import Me, Person, ProjectMembership from project import Project - from story import Story, Epic + from story import Story, Epic, Task from metadata import Label def generate(resource): @@ -22,7 +22,8 @@ def generate(resource): 'label': Label, 'error': Error, 'project_membership': ProjectMembership, - 'person': Person + 'person': Person, + 'task': Task }.get(kind) if resource_class is None: From 11016988585301759e396291b26924a1c5dc8081 Mon Sep 17 00:00:00 2001 From: Charly Date: Wed, 6 Feb 2019 12:02:51 +0100 Subject: [PATCH 04/12] add Comment and FileAttachment --- pyvo/model/__init__.py | 6 ++++-- pyvo/model/story.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/pyvo/model/__init__.py b/pyvo/model/__init__.py index c844e95..440efb9 100644 --- a/pyvo/model/__init__.py +++ b/pyvo/model/__init__.py @@ -6,7 +6,7 @@ class ModelNotFound(Exception): def generate_resources(response, client=None): from person import Me, Person, ProjectMembership from project import Project - from story import Story, Epic, Task + from story import Story, Epic, Task, Comment, FileAttachment from metadata import Label def generate(resource): @@ -23,7 +23,9 @@ def generate(resource): 'error': Error, 'project_membership': ProjectMembership, 'person': Person, - 'task': Task + 'task': Task, + 'comment': Comment, + 'file_attachment': FileAttachment }.get(kind) if resource_class is None: diff --git a/pyvo/model/story.py b/pyvo/model/story.py index a510266..4b3eef5 100644 --- a/pyvo/model/story.py +++ b/pyvo/model/story.py @@ -55,3 +55,31 @@ class Epic(Instantiated, PivotalResource): past_done_stories_no_point_count = fields.IntField() url = fields.StringField() +class FileAttachment(Instantiated, PivotalResource): + filename = fields.StringField() + created_at = fields.DateTimeField() + uploader_id = fields.IntField() + thumbnailable = fields.BoolField() + height = fields.IntField() + width = fields.IntField() + size = fields.IntField() + download_url = fields.StringField() + content_type = fields.StringField() + uploaded = fields.BoolField() + big_url = fields.StringField() + thumbnail_url = fields.StringField() + kind = fields.StringField() + +class Comment(Instantiated, PivotalResource): + story_id = fields.IntField() + epic_id = fields.IntField() + text = fields.StringField() + person_id = fields.IntField() + created_at = fields.DateTimeField() + updated_at = fields.DateTimeField() + file_attachment_ids = fields.ListField() + google_attachment_ids = fields.ListField() + attachment_ids = fields.ListField() + commit_identifier = fields.StringField() + commit_type = fields.StringField() + kind = fields.StringField() From 1b3db218eabde8792672d8ad872ebda480994ff5 Mon Sep 17 00:00:00 2001 From: Charly Date: Thu, 7 Feb 2019 09:49:57 +0100 Subject: [PATCH 05/12] add content type applicatoin/json --- pyvo/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyvo/client.py b/pyvo/client.py index fc59cf2..ba3f4ba 100644 --- a/pyvo/client.py +++ b/pyvo/client.py @@ -138,7 +138,8 @@ def __init__(self, token, def token_auth(self, request): request.headers.update({ - 'x-trackertoken': self.token + 'x-trackertoken': self.token, + 'Content-Type': 'application/json', }) return request From 8eccfa72c1fcfe42d8cb2438794aadd0d8fa5ac4 Mon Sep 17 00:00:00 2001 From: Charly Date: Thu, 7 Feb 2019 11:22:07 +0100 Subject: [PATCH 06/12] remove application/json header --- pyvo/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyvo/client.py b/pyvo/client.py index ba3f4ba..96eb667 100644 --- a/pyvo/client.py +++ b/pyvo/client.py @@ -139,7 +139,6 @@ def __init__(self, token, def token_auth(self, request): request.headers.update({ 'x-trackertoken': self.token, - 'Content-Type': 'application/json', }) return request From f29b93e9cd7a932a6ba5db6883f2d82eb65e6184 Mon Sep 17 00:00:00 2001 From: Charly Date: Fri, 8 Feb 2019 10:08:21 +0100 Subject: [PATCH 07/12] Comment file_attachment_ids needs ListField(int) to please jsonmodels --- pyvo/model/story.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyvo/model/story.py b/pyvo/model/story.py index 4b3eef5..eb71c7a 100644 --- a/pyvo/model/story.py +++ b/pyvo/model/story.py @@ -77,7 +77,7 @@ class Comment(Instantiated, PivotalResource): person_id = fields.IntField() created_at = fields.DateTimeField() updated_at = fields.DateTimeField() - file_attachment_ids = fields.ListField() + file_attachment_ids = fields.ListField(int) google_attachment_ids = fields.ListField() attachment_ids = fields.ListField() commit_identifier = fields.StringField() From 11f773d299a00e6495397a7617010b8b60226733 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 12 Feb 2019 08:31:14 +0100 Subject: [PATCH 08/12] clean up branch --- pyvo/model/__init__.py | 8 +------- pyvo/model/base.py | 3 --- pyvo/model/error.py | 1 - pyvo/model/person.py | 2 +- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/pyvo/model/__init__.py b/pyvo/model/__init__.py index 440efb9..67187c6 100644 --- a/pyvo/model/__init__.py +++ b/pyvo/model/__init__.py @@ -12,7 +12,7 @@ def generate_resources(response, client=None): def generate(resource): kind = resource['kind'] - print "generating {}".format(kind) + # print "generating {}".format(kind) resource_class = { 'project': Project, @@ -39,9 +39,3 @@ def generate(resource): return (generate(resource) for resource in response) else: return generate(response) - - - - - - diff --git a/pyvo/model/base.py b/pyvo/model/base.py index eabd9e1..da8cfbd 100644 --- a/pyvo/model/base.py +++ b/pyvo/model/base.py @@ -60,6 +60,3 @@ def __init__(self, *args): def validate(self, value): pass - - - diff --git a/pyvo/model/error.py b/pyvo/model/error.py index e6993cc..8269591 100644 --- a/pyvo/model/error.py +++ b/pyvo/model/error.py @@ -19,4 +19,3 @@ class Error(PivotalResource): def __str__(self): return "{}".format(self.general_problem or self.error) - diff --git a/pyvo/model/person.py b/pyvo/model/person.py index d4c449f..db1c9e6 100644 --- a/pyvo/model/person.py +++ b/pyvo/model/person.py @@ -40,4 +40,4 @@ class ProjectMembership(Instantiated, PivotalResource): wants_comment_notification_emails = fields.BoolField() will_receive_mention_notifications_or_emails = fields.BoolField() kind = fields.StringField() - person = fields.EmbeddedField(Person) \ No newline at end of file + person = fields.EmbeddedField(Person) From 63cbb419bc84b442952d98ea2149defd8a9457a1 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 12 Feb 2019 08:57:28 +0100 Subject: [PATCH 09/12] refactor print statement to work with python 3 --- pyvo/model/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyvo/model/__init__.py b/pyvo/model/__init__.py index 67187c6..3e91be6 100644 --- a/pyvo/model/__init__.py +++ b/pyvo/model/__init__.py @@ -12,7 +12,7 @@ def generate_resources(response, client=None): def generate(resource): kind = resource['kind'] - # print "generating {}".format(kind) + print("generating {}".format(kind)) resource_class = { 'project': Project, From 49bbc19d57987e0080e751ba8908db4eb7338e47 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 12 Feb 2019 10:37:10 +0100 Subject: [PATCH 10/12] use python 2.9 for pytest --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ef79f12..e162647 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ envlist = py27 commands = py.test {posargs} deps = -rrequirements.txt - pytest==2.7.2 + pytest==2.9 pytest-describe pytest-bdd pytest-sugar From d0a3d6d79cf9f224e6fd3deb74e3855be93ecb8b Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 12 Feb 2019 10:43:33 +0100 Subject: [PATCH 11/12] ensure consistent code style --- pyvo/model/base.py | 1 - pyvo/model/person.py | 7 +------ pyvo/model/project.py | 10 ++-------- pyvo/model/story.py | 6 ++---- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/pyvo/model/base.py b/pyvo/model/base.py index da8cfbd..4ec3203 100644 --- a/pyvo/model/base.py +++ b/pyvo/model/base.py @@ -3,7 +3,6 @@ class PivotalResource(models.Base): - @classmethod def with_client(cls, client, **data): resource = cls(**data) diff --git a/pyvo/model/person.py b/pyvo/model/person.py index db1c9e6..5b801ee 100644 --- a/pyvo/model/person.py +++ b/pyvo/model/person.py @@ -4,7 +4,6 @@ class Me(Instantiated, PivotalResource): - name = fields.StringField() initials = fields.StringField() username = fields.StringField() @@ -18,7 +17,6 @@ class Me(Instantiated, PivotalResource): class Person(Instantiated, PivotalResource): - name = fields.StringField(required=True) email = fields.StringField(required=True) initials = fields.StringField() @@ -26,14 +24,11 @@ class Person(Instantiated, PivotalResource): kind = fields.StringField() class ProjectMembership(Instantiated, PivotalResource): - created_at = fields.DateTimeField() updated_at = fields.DateTimeField() person_id = fields.IntField() project_id = fields.IntField() - role = fields.StringField( - validators=OneOf('owner', - 'member', 'viewer', 'inactive')) + role = fields.StringField(validators=OneOf('owner', 'member', 'viewer', 'inactive')) project_color = fields.StringField() favorite = fields.BoolField() last_viewed_at = fields.DateTimeField() diff --git a/pyvo/model/project.py b/pyvo/model/project.py index 2b63329..95ea52b 100644 --- a/pyvo/model/project.py +++ b/pyvo/model/project.py @@ -4,7 +4,6 @@ class Project(Instantiated, PivotalResource): - name = fields.StringField(validators=PostValidators(RequiredOnPost())) version = fields.IntField() iteration_length = fields.IntField() @@ -33,9 +32,7 @@ class Project(Instantiated, PivotalResource): current_velocity = fields.IntField() current_volatility = fields.FloatField() account_id = fields.IntField() - accounting_type = fields.StringField( - validators=OneOf('unbillable', - 'billable', 'overhead')) + accounting_type = fields.StringField(validators=OneOf('unbillable', 'billable', 'overhead')) featured = fields.BoolField() story_ids = fields.ListField() epic_ids = fields.ListField() @@ -46,11 +43,8 @@ class Project(Instantiated, PivotalResource): class MembershipSummary(Instantiated, PivotalResource): - project_id = fields.IntField() project_name = fields.StringField() project_color = fields.StringField() - role = fields.StringField( - validators=OneOf('owner', 'member', 'viewer', 'inactive') - ) + role = fields.StringField(validators=OneOf('owner', 'member', 'viewer', 'inactive')) last_viewed_at = fields.DateTimeField() diff --git a/pyvo/model/story.py b/pyvo/model/story.py index eb71c7a..3aeacc2 100644 --- a/pyvo/model/story.py +++ b/pyvo/model/story.py @@ -7,12 +7,10 @@ class Story(Instantiated, PivotalResource): name = fields.StringField() description = fields.StringField(validators=PostValidators(RequiredOnPost())) - story_type = fields.StringField( - validators=OneOf('feature', 'bug', 'chore', 'release') - ) + story_type = fields.StringField(validators=OneOf('feature', 'bug', 'chore', 'release')) current_state = fields.StringField( validators=OneOf('accepted', 'delivered', 'finished', - 'started', 'rejected', 'planned', 'unstarted', 'unscheduled') + 'started', 'rejected', 'planned', 'unstarted', 'unscheduled') ) estimate = fields.FloatField() accepted_at = fields.DateTimeField() From 912afedc1fb80032019d44ce0091ff7b53437bdf Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 12 Feb 2019 10:43:51 +0100 Subject: [PATCH 12/12] ensure consistent code style --- pyvo/__init__.py | 2 -- pyvo/client.py | 1 - 2 files changed, 3 deletions(-) diff --git a/pyvo/__init__.py b/pyvo/__init__.py index 635b821..be7c4e6 100644 --- a/pyvo/__init__.py +++ b/pyvo/__init__.py @@ -1,4 +1,2 @@ VERSION = 0, 2, 0 DEV_STATUS = 3 # Alpha - - diff --git a/pyvo/client.py b/pyvo/client.py index 96eb667..7604828 100644 --- a/pyvo/client.py +++ b/pyvo/client.py @@ -152,4 +152,3 @@ def __getattr__(self, k): except AttributeError: request = self.request(uriparts=[k]) return request -