Пример #1
0
    def _test_url_strings(self, use_https):
        pv = Pivotal('ABCDEF', use_https=use_https)

        url = PROTO_SWITCH[use_https] + BASE_URL
        
        self.assertEqual(pv.projects().url, url + 'projects')
        self.assertEqual(pv.projects(123).url, url + 'projects/123')
        self.assertEqual(pv.projects('123').url, url + 'projects/123')
        self.assertEqual(pv.projects('123').stories().url, 
                      url + 'projects/123/stories')
        self.assertEqual(pv.projects('123').stories(filter='state:unstarted').url,
                      url + 'projects/123/stories?filter=state%3Aunstarted')
Пример #2
0
    def test_update_url_strings(self):
        """
        Testing multiple `update` kwargs is may fail due to unordered
        dictionary keys
        """
        pv = Pivotal('ABCDEF', use_https=True)
        url = PROTO_SWITCH[True] + BASE_URL

        self.assertEqual(pv.projects('123').stories().add('story', name='New Story').url,
                url + 'projects/123/stories?story%5Bname%5D=New+Story')
        self.assertEqual(pv.projects('123').stories().update('story', name='New Story').url,
                url + 'projects/123/stories?story%5Bname%5D=New+Story')
        self.assertEqual(pv.projects('123').stories('456').update('story', name='Updated Story').url,
                url + 'projects/123/stories/456?story%5Bname%5D=Updated+Story')
        self.assertEqual(pv.projects('123').stories('456').tasks('789').update('task', description='count shields', priority=2, complete='false').url,
                url + 'projects/123/stories/456/tasks/789?task%5Bdescription%5D=count+shields&task%5Bcomplete%5D=false&task%5Bpriority%5D=2')
Пример #3
0
def get_stories_from_pt():
    stories = {}
    pt = Pivotal(environ.get('PT_TOKEN'))
    etree = pt.projects(environ.get('PT_PROJECT_ID')).stories().get_etree()
    for story in etree.findall('story'):
        sid = story.findtext('id')
        comments = []
        commits = []
        for note in story.findall('notes/note'):
            comment = note.findtext('text')
            comments.append(comment)
            commits.extend(git_commit_hash.findall(comment))
        s = {
            'story': story.findtext('name'),
            'state': story.findtext('current_state'),
            'comments': comments,
            'commits': commits
        }
        stories[sid] = s
    return stories
]


def xml_get(node, field, default=""):
    try:
        return node.find(field).text
    except AttributeError:
        return ""


for person in team:
    pv = Pivotal(person["token"])

    data = {}

    xml = pv.projects().get_etree()
    for proj in xml.getchildren():
        proj_name = proj.find("name").text
        data[proj_name] = []
        id = int(proj.find("id").text)
        qs = {"filter": "state:started"}
        xml = pv.projects(id).stories(**qs).get_etree()
        for story in xml.getchildren():
            data[proj_name].append(
                {
                    "name": xml_get(story, "name"),
                    "url": xml_get(story, "url"),
                    "owner": xml_get(story, "owned_by").replace(" ", " "),
                    "state": "started",
                }
            )
Пример #5
0
        sys.exit(
            "Pivotal Tracker token not specified.\n \
            Add to the script or create in ~/.pivotal_token"
        )

boolmap = {"true": True, "false": False}

pv = Pivotal(pivotal_token)

##############################################################################
# Find all projects and create a dictionary of basic project info
##############################################################################
projects = {}
project_choices = []

_projects = pv.projects().get_etree().findall("project")
for pos, project in enumerate(_projects):
    pid = project.find("id").text
    pname = project.find("name").text
    use_https = boolmap[project.find("use_https").text]
    labels = project.find("labels").text.split(",")
    projects[pos + 1] = {"id": pid, "name": pname, "use_https": use_https, "labels": labels}
    project_choices.append("[%d] %s" % (pos + 1, pname))

project_choices.append("[Q(uit)] to Quit")


##############################################################################
# USER INPUT to choose a project from the available list
##############################################################################
print "Pivotal Tracker Projects"