Skip to content

Commit

Permalink
Merge pull request #5 from devopshq/develop
Browse files Browse the repository at this point in the history
Preparing for release 1.0
  • Loading branch information
Tim55667757 committed Jul 13, 2017
2 parents 2d61885 + 8cbff84 commit 01666ce
Show file tree
Hide file tree
Showing 12 changed files with 489 additions and 106 deletions.
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: python
python: '3.4'
branches:
only:
- master
- develop
install:
- pip install coverage codacy-coverage pytest==3.1.2 HTTPretty pytest_httpretty
script:
- printenv
- ls -la
- coverage run -m py.test tests
- coverage xml
- python-codacy-coverage -r coverage.xml
deploy:
provider: pypi
user: devopshq
password:
secure: "u7kqhFT32wLvGvdXLRg3RtTdfGcSzfFWTQb0p1cdRHWBm/771Q2H4bfvwv8GTVmSz+0txtW4O20/VMuMSULqAgW9ChLoNnpppsiEuwOL/KgFknOMgegM+QqdBU7OyB4c0XBxCEfoe8/+Z8lNlB1+UShwh6aJHjiUvR9U537ebtniMWyj0Nb93f53YQGsh29gbuqDNzIWPePFuSDBhKTRhKEHdBfol11YCgyNs2MXkdTUQ60G+DMtdAOM32mJEXi3n2yQWtnWdnsxApqZ4LLlEO1J7FJ0/6sXEd5Y8aQBoYPdE5RdGjo1gjxpp0tL3WxXisG1TlHdgNShKzO5CT4pUFD5qWqhbzlwDM8eI3xFS39I75bVeoPrQ9jn0MlBs8JQJIEFbn6HDW7G/hezMoQPwH2Sn2ET9/XH9axt3U7Wrqf9I10FuFMdBZ4hD62kml94WfxiC40sCNMgYW/zPYGSUQLXfzWImyFz32K8MTQErWVoiaDz8bx5rjLa+zmmwchhZCX4YdBh4BMIOy793YYx6/jLGUBhKuIyHGYREUF/ZlZg5rYssbKUP9G4TdzPix3dGCBgdtrsYwUZ79Odu/SjwV8uzOfcU2p9E0j1GjEK5BnfwY7b5ZpXeagBze34kDU3U89Jnmwc08eu0S+olv7/4iGn+gvQZOvM9s0CShhMI7I="
distributions: sdist bdist_wheel
on:
all_branches: true
skip_cleanup: true
after_script:
- echo "Deploy to PyPI finished."
env:
global:
- secure: "d67oNhecPXRl0HiTfcI29PKUPLo657VMaCLAt7BAyPk3LXLSgkz9X0fpz0I2dq3DrtREMrKNcoHjFY5x5FoMemYJfg/93PPk8hRbu3XWKiGVHVdj8xwu2hJSSxl/enmEs25qAs1c3Rss+9CyZ7rP4cY7J0hiVymgBZKWSG/8UL6P2D3iDpvxf3EKapPRrf8FP6l3Nmwk3iVlFrwzq4koBUlC2SEd2Hr1uL+iGHuOdNlH4bksMc0nIeC6f905YJ1x3hHMg46h75RkWBrPmj9nn5eAS3jva8Fg9WrDiieF9JrL6GZ0SpektgDS+SjZuinAgjmDZQOogLZtg8+cyDVSud5x0d1K1OQBatNb1ZWVDqLld2E6/6Pxp1x1Bg52OpQvxL23HZkg7XZtxhZzhOEI4f/TvG4123voygjQXSZXVrdqzLwwAxuGqtxym5lcAe7tRllmnXs/Nty/M5ICQhVU56pxoMvSjwwXySBdP69TC6YBNtLbDY9ySImd3lJpbJcc0ftuo2aU6FJjXMNFTuTjmVfw3g/fKvPcjVsTbHqVWOhyfI/smAJxgJx/ugEm9PFk7i2rIc3JkYtW1AyoIXGJBeytvZRlyDz9ulowYSEPCtKL6Z9tqMGPHUntKwwHKbRTBIGsDhnRLN095MYbb7d7aOagBIfOGSaxY3e/mpyXwQI="
4 changes: 4 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
AUTHORS
- Anton Fushta
- Alexey Burov (allburov)
- Timur Gilmullin (Tim55667757)
93 changes: 79 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,70 @@
### TFS Python Library (TFS API Python client).
## Quickstart
### Create connection
TFS Python Library (TFS API Python client)
==========================================

[![dohq-tfs build status](https://travis-ci.org/devopshq/tfs.svg)](https://travis-ci.org/devopshq/tfs) [![dohq-tfs code quality](https://api.codacy.com/project/badge/Grade/a533e2d46b9b471893b4991e89649212)](https://www.codacy.com/app/tim55667757/tfs/dashboard) [![dohq-tfs code coverage](https://api.codacy.com/project/badge/Coverage/a533e2d46b9b471893b4991e89649212)](https://www.codacy.com/app/tim55667757/tfs/dashboard) [![dohq-tfs on PyPI](https://img.shields.io/pypi/v/dohq-tfs.svg)](https://pypi.python.org/pypi/dohq-tfs) [![dohq-tfs license](https://img.shields.io/pypi/l/vspheretools.svg)](https://github.com/devopshq/tfs/blob/master/LICENSE)

*Index:*
- [Introduction](#introduction)
- [Quickstart](#quickstart)
- [Installation](#installation)
- [Create connection](#create-connection)
- [Workitem](#workitem)
- [Run Queries](#run-queries)
- [Changesets](#changesets)
- [Project and Team](#project--team)
- [Guide](#guide)
- [Compability](#compability)
- [Development](#development)
- [Tests](#tests)
- [TODO](#todo)

# Introduction

TFS Python Library is a TFS API Python client that can work with TFS workflow and workitems.

This tool allows:
1. Get WorkItems (WI).
2. Set WI fields.
3. Run WI search queries.
4. Work with TFVC changesets.
5. Work with TFS Projects.

## Installation
```
pip install dohq-tfs
```

## Create connection
```python
from tfs import TFSAPI

user="username"
password="password"

# Use DefaultCollection
client = TFSAPI("https://tfs.tfs.ru/tfs/", user=user, password=password)

# Use CustomCollection
client = TFSAPI("https://tfs.tfs.ru/tfs/", project="Development", user=user, password=password)
workitem = client.get_workitem(100) # Test connection with Workitem id

# Set path to ProjectName in project parameter
client = TFSAPI("https://tfs.tfs.ru/tfs/", project="Development/ProjectName", user=user, password=password)

workitem = client.get_workitem(100) # Test connection with Workitem id
```
### Workitem

## Workitem
```python
# For single Workitem
workitem = client.get_workitem(100)

# For multiple
workitem = client.get_workitems([100,101,102]) # list
workitem = client.get_workitems("100,101,102") # string separated with comma

# Get all fields
print(workitem.field_names)

# Case insensetive. Remove space in field name
print(workitem['assignedTo'])

Expand All @@ -37,7 +87,25 @@ if childs: # Child is empty list if Workitem hasn't Child link
print("Workitem with id={} have Childs={}".format(workitem.id, ",".join([x.id for x in childs])))
```

### Changesets
## Run Queries
You can run Saved Queries and get Workitems
```python
# Set path to ProjectName in project parameter
client = TFSAPI("https://tfs.tfs.ru/tfs/", project="Development/ProjectName", user=user, password=password)

# Run New query 1 in Shared Queries folder
quiery = client.run_query('Shared Queries/New query 1')

# result content raw data
result = quiery.result
print(quiery.columns)
print(quiery.column_names)

# Get all found workitems
workitems = quiery.workitems
```

## Changesets
```python
# Get changesets from 1000 to 1002
changesets = client.get_changesets(from_=1000, to_=1002)
Expand All @@ -47,7 +115,7 @@ changesets = client.get_changesets(top=1)
linked_workitems = changesets[0].workitems
```

### Project & Team
## Project & Team
```python
# Get all project
all_projects = client.get_projects()
Expand All @@ -59,20 +127,17 @@ project_name = client.get_project("MyProjectName")
project_team = project_name.team
```

## Installation
```
pip install dohq-tfs
```

## Guide
### Tested compability:
### Compability
- TFS 2015
- TFS 2017

## Development
### Tests
We use HTTPPrety. For GET-response locate you response.json to folder by URL. E.g:
- http://tfs.tfs.rutfs/Development/_apis/wit/workitems?ids=anyid&anyflag => **tests/resources/tfs/Development/_apis/wit/workitems/response.json**
- http://tfs.tfs.rutfs/Development/_apis/tfvc/changesets/10/workItems => **tests/resources/tfs/Development/_apis/tfvc/changesets/10/workItems/response.json**
- http://tfs.tfs.ru/tfs/Development/_apis/wit/workitems?ids=anyid&anyflag => **tests/resources/tfs/Development/_apis/wit/workitems/response.json**
- http://tfs.tfs.ru/tfs/Development/_apis/tfvc/changesets/10/workItems => **tests/resources/tfs/Development/_apis/tfvc/changesets/10/workItems/response.json**

### TODO
- Implemented Resources-API (like https://github.com/pycontribs/jira)
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
theme: jekyll-theme-minimal
theme: jekyll-theme-hacker
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[metadata]
description-file = README.md

[aliases]
test=pytest
101 changes: 101 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-


from setuptools import setup
import os

__version__ = '1.0' # identify main version of dohq-tfs tool
devStatus = '4 - Beta' # default build status, see: https://pypi.python.org/pypi?%3Aaction=list_classifiers

if 'TRAVIS_BUILD_NUMBER' in os.environ and 'TRAVIS_BRANCH' in os.environ:
print("This is TRAVIS-CI build")
print("TRAVIS_BUILD_NUMBER = {}".format(os.environ['TRAVIS_BUILD_NUMBER']))
print("TRAVIS_BRANCH = {}".format(os.environ['TRAVIS_BRANCH']))

__version__ += '.{}{}'.format(
'' if 'release' in os.environ['TRAVIS_BRANCH'] or os.environ['TRAVIS_BRANCH'] == 'master' else 'dev',
os.environ['TRAVIS_BUILD_NUMBER'],
)

devStatus = '5 - Production/Stable' if 'release' in os.environ['TRAVIS_BRANCH'] or os.environ[
'TRAVIS_BRANCH'] == 'master' else devStatus

else:
print("This is local build")
__version__ += '.dev0' # set version as major.minor.localbuild if local build: python setup.py install

print("dohq-tfs build version = {}".format(__version__))

setup(
name='dohq-tfs',

version=__version__,

description='dohq-tfs is a TFS API Python client that can work with TFS workflow and workitems.',

long_description='You can see detailed user manual here: https://devopshq.github.io/tfs/',

license='MIT',

author='Alexey Burov',

author_email='allburov@gmail.com',

url='https://devopshq.github.io/tfs/',

download_url='https://github.com/devopshq/tfs.git',

entry_points={},

classifiers=[
'Development Status :: {}'.format(devStatus),
'Environment :: Console',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3.4',
],

keywords=[
'TFS',
'library',
'api',
'client',
'utility',
'routines',
'workitem',
'changesets',
'TFS2015',
],

packages=[
'tfs',
],

setup_requires=[
'pytest-runner'
],

tests_require=[
'pytest==3.1.2',
'HTTPretty',
'pytest_httpretty',
],

install_requires=[
'requests',
],

package_data={
'': [
'./tfs/*'

'LICENSE',
'README.md',
],
},

zip_safe=True,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"queryType": "flat",
"queryResultType": "workItem",
"asOf": "2017-07-12T10:49:35.54Z",
"columns": [
{
"referenceName": "System.Id",
"name": "ID",
"url": "https:\/\/tfs.tfs.ru\/tfs\/DevelopmentTest\/_apis\/wit\/fields\/System.Id"
},
{
"referenceName": "System.WorkItemType",
"name": "Work Item Type",
"url": "https:\/\/tfs.tfs.ru\/tfs\/DevelopmentTest\/_apis\/wit\/fields\/System.WorkItemType"
},
{
"referenceName": "System.Title",
"name": "Title",
"url": "https:\/\/tfs.tfs.ru\/tfs\/DevelopmentTest\/_apis\/wit\/fields\/System.Title"
},
{
"referenceName": "System.AssignedTo",
"name": "Assigned To",
"url": "https:\/\/tfs.tfs.ru\/tfs\/DevelopmentTest\/_apis\/wit\/fields\/System.AssignedTo"
},
{
"referenceName": "System.State",
"name": "State",
"url": "https:\/\/tfs.tfs.ru\/tfs\/DevelopmentTest\/_apis\/wit\/fields\/System.State"
},
{
"referenceName": "System.Tags",
"name": "Tags",
"url": "https:\/\/tfs.tfs.ru\/tfs\/DevelopmentTest\/_apis\/wit\/fields\/System.Tags"
}
],
"workItems": [
{
"id": 100,
"url": "https:\/\/tfs.tfs.ru\/tfs\/DevelopmentTest\/_apis\/wit\/workItems\/100"
},
{
"id": 101,
"url": "https:\/\/tfs.tfs.ru\/tfs\/DevelopmentTest\/_apis\/wit\/workItems\/100"
}
]
}
Loading

0 comments on commit 01666ce

Please sign in to comment.