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 fc59cf2..7604828 100644 --- a/pyvo/client.py +++ b/pyvo/client.py @@ -138,7 +138,7 @@ def __init__(self, token, def token_auth(self, request): request.headers.update({ - 'x-trackertoken': self.token + 'x-trackertoken': self.token, }) return request @@ -152,4 +152,3 @@ def __getattr__(self, k): except AttributeError: request = self.request(uriparts=[k]) return request - diff --git a/pyvo/model/__init__.py b/pyvo/model/__init__.py index 2979fcf..3e91be6 100644 --- a/pyvo/model/__init__.py +++ b/pyvo/model/__init__.py @@ -4,15 +4,15 @@ 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 story import Story, Epic, Task, Comment, FileAttachment from metadata import Label def generate(resource): kind = resource['kind'] - print "generating {}".format(kind) + print("generating {}".format(kind)) resource_class = { 'project': Project, @@ -20,7 +20,12 @@ def generate(resource): 'story': Story, 'epic': Epic, 'label': Label, - 'error': Error + 'error': Error, + 'project_membership': ProjectMembership, + 'person': Person, + 'task': Task, + 'comment': Comment, + 'file_attachment': FileAttachment }.get(kind) if resource_class is None: @@ -34,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..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) @@ -60,6 +59,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 d041761..5b801ee 100644 --- a/pyvo/model/person.py +++ b/pyvo/model/person.py @@ -1,10 +1,9 @@ -from base import PivotalResource, Instantiated, fields +from base import PivotalResource, Instantiated, fields, OneOf from metadata import TimeZone from project import MembershipSummary class Me(Instantiated, PivotalResource): - name = fields.StringField() initials = fields.StringField() username = fields.StringField() @@ -18,9 +17,22 @@ class Me(Instantiated, PivotalResource): class Person(Instantiated, PivotalResource): - name = fields.StringField(required=True) 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) diff --git a/pyvo/model/project.py b/pyvo/model/project.py index 1d32616..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,12 +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 7e71a72..3aeacc2 100644 --- a/pyvo/model/story.py +++ b/pyvo/model/story.py @@ -7,17 +7,16 @@ 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() 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) @@ -54,3 +53,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(int) + google_attachment_ids = fields.ListField() + attachment_ids = fields.ListField() + commit_identifier = fields.StringField() + commit_type = fields.StringField() + kind = fields.StringField() 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