This commit is contained in:
Dale Myers 2019-07-23 16:48:11 +01:00
Родитель 69133e5390
Коммит e3eb699102
8 изменённых файлов: 117 добавлений и 12 удалений

4
.gitignore поставляемый
Просмотреть файл

@ -1,8 +1,10 @@
__pycache__
.DS_Store
.mypy_cache
.pytest_cache
bin/
dist/
lib/
pip-wheel-metadata/
pyvenv.cfg
simple_ado.egg-info/
simple_ado.egg-info/

8
.vscode/settings.json поставляемый
Просмотреть файл

@ -1,5 +1,11 @@
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.pythonPath": "${workspaceFolder}/bin/python3"
"python.pythonPath": "${workspaceFolder}/bin/python3",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true
}

Просмотреть файл

@ -43,6 +43,8 @@ jobs:
- script: |
source bin/activate
python -m pytest tests --cov=simple_ado --cov-report html --cov-report xml --doctest-modules --junitxml=junit/test-results.xml
env:
SIMPLE_ADO_BASE_TOKEN: $(SIMPLE_ADO_BASE_TOKEN)
displayName: 'pytest'
- script: |

21
poetry.lock сгенерированный
Просмотреть файл

@ -110,7 +110,7 @@ description = "More routines for operating on iterables, beyond itertools"
name = "more-itertools"
optional = false
python-versions = ">=3.4"
version = "7.1.0"
version = "7.2.0"
[[package]]
category = "dev"
@ -217,6 +217,14 @@ optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*"
version = "1.12.0"
[[package]]
category = "dev"
description = "Python Library for Tom's Obvious, Minimal Language"
name = "toml"
optional = false
python-versions = "*"
version = "0.10.0"
[[package]]
category = "dev"
description = "a fork of Python 2 and 3 ast modules with type comment support"
@ -247,11 +255,11 @@ description = "Backport of pathlib-compatible object wrapper for zip files"
name = "zipp"
optional = false
python-versions = ">=2.7"
version = "0.5.1"
version = "0.5.2"
[metadata]
content-hash = "2ed7c6765b9f13c79c1988be92225ddfd6970712e6d56220a8897f28bdacf545"
python-versions = "^3.7"
content-hash = "3d37460b008bc10d5083c431dcc12e3920fdcbe535b8524003505cf794f5c92c"
python-versions = "^3.6"
[metadata.hashes]
astroid = ["6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4", "b65db1bbaac9f9f4d190199bb8680af6f6f84fd3769a5ea883df8a91fe68b4c4"]
@ -266,7 +274,7 @@ importlib-metadata = ["6dfd58dfe281e8d240937776065dd3624ad5469c835248219bd16cf2e
isort = ["54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", "6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd"]
lazy-object-proxy = ["159a745e61422217881c4de71f9eafd9d703b93af95618635849fe469a283661", "23f63c0821cc96a23332e45dfaa83266feff8adc72b9bcaef86c202af765244f", "3b11be575475db2e8a6e11215f5aa95b9ec14de658628776e10d96fa0b4dac13", "3f447aff8bc61ca8b42b73304f6a44fa0d915487de144652816f950a3f1ab821", "4ba73f6089cd9b9478bc0a4fa807b47dbdb8fad1d8f31a0f0a5dbf26a4527a71", "4f53eadd9932055eac465bd3ca1bd610e4d7141e1278012bd1f28646aebc1d0e", "64483bd7154580158ea90de5b8e5e6fc29a16a9b4db24f10193f0c1ae3f9d1ea", "6f72d42b0d04bfee2397aa1862262654b56922c20a9bb66bb76b6f0e5e4f9229", "7c7f1ec07b227bdc561299fa2328e85000f90179a2f44ea30579d38e037cb3d4", "7c8b1ba1e15c10b13cad4171cfa77f5bb5ec2580abc5a353907780805ebe158e", "8559b94b823f85342e10d3d9ca4ba5478168e1ac5658a8a2f18c991ba9c52c20", "a262c7dfb046f00e12a2bdd1bafaed2408114a89ac414b0af8755c696eb3fc16", "acce4e3267610c4fdb6632b3886fe3f2f7dd641158a843cf6b6a68e4ce81477b", "be089bb6b83fac7f29d357b2dc4cf2b8eb8d98fe9d9ff89f9ea6012970a853c7", "bfab710d859c779f273cc48fb86af38d6e9210f38287df0069a63e40b45a2f5c", "c10d29019927301d524a22ced72706380de7cfc50f767217485a912b4c8bd82a", "dd6e2b598849b3d7aee2295ac765a578879830fb8966f70be8cd472e6069932e", "e408f1eacc0a68fed0c08da45f31d0ebb38079f043328dce69ff133b95c29dc1"]
mccabe = ["ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", "dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"]
more-itertools = ["3ad685ff8512bf6dc5a8b82ebf73543999b657eded8c11803d9ba6b648986f4d", "8bb43d1f51ecef60d81854af61a3a880555a14643691cc4b64a6ee269c78f09a"]
more-itertools = ["409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832", "92b8c4b06dac4f0611c0729b2f2ede52b2e1bac1ab48f089c7ddc12e26bb60c4"]
mypy = ["308c274eb8482fbf16006f549137ddc0d69e5a589465e37b99c4564414363ca7", "e80fd6af34614a0e898a57f14296d0dacb584648f0339c2e000ddbf0f4cc2f8d"]
mypy-extensions = ["37e0e956f41369209a3d5f34580150bcacfabaa57b33a15c0b25f4b5725e0812", "b16cabe759f55e3409a7d231ebd2841378fb0c27a5d1994719e340e4f429ac3e"]
pluggy = ["0825a152ac059776623854c1543d65a4ad408eb3d33ee114dff91e57ec6ae6fc", "b9817417e95936bf75d85d3f8767f7df6cdde751fc40aed3bb3074cbcb77757c"]
@ -276,7 +284,8 @@ pytest = ["1d131cc532be0023ef8ae265e2a779938d0619bb6c2510f52987ffcba7fa1ee4", "c
pytest-cov = ["513c425e931a0344944f84ea47f3956be0e416d95acbd897a44970c8d926d5d7", "e360f048b7dae3f2f2a9a4d067b2dd6b6a015d384d1577c994a43f3f7cbad762"]
requests = ["11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", "9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"]
six = ["3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"]
toml = ["229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", "235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e", "f1db651f9657708513243e61e6cc67d101a39bad662eaa9b5546f789338e07a3"]
typed-ast = ["132eae51d6ef3ff4a8c47c393a4ef5ebf0d1aecc96880eb5d6c8ceab7017cc9b", "18141c1484ab8784006c839be8b985cfc82a2e9725837b0ecfa0203f71c4e39d", "2baf617f5bbbfe73fd8846463f5aeafc912b5ee247f410700245d68525ec584a", "3d90063f2cbbe39177e9b4d888e45777012652d6110156845b828908c51ae462", "4304b2218b842d610aa1a1d87e1dc9559597969acc62ce717ee4dfeaa44d7eee", "4983ede548ffc3541bae49a82675996497348e55bafd1554dc4e4a5d6eda541a", "5315f4509c1476718a4825f45a203b82d7fdf2a6f5f0c8f166435975b1c9f7d4", "6cdfb1b49d5345f7c2b90d638822d16ba62dc82f7616e9b4caa10b72f3f16649", "7b325f12635598c604690efd7a0197d0b94b7d7778498e76e0710cd582fd1c7a", "8d3b0e3b8626615826f9a626548057c5275a9733512b137984a68ba1598d3d2f", "8f8631160c79f53081bd23446525db0bc4c5616f78d04021e6e434b286493fd7", "912de10965f3dc89da23936f1cc4ed60764f712e5fa603a09dd904f88c996760", "b010c07b975fe853c65d7bbe9d4ac62f1c69086750a574f6292597763781ba18", "c908c10505904c48081a5415a1e295d8403e353e0c14c42b6d67f8f97fae6616", "c94dd3807c0c0610f7c76f078119f4ea48235a953512752b9175f9f98f5ae2bd", "ce65dee7594a84c466e79d7fb7d3303e7295d16a83c22c7c4037071b059e2c21", "eaa9cfcb221a8a4c2889be6f93da141ac777eb8819f077e1d09fb12d00a09a93", "f3376bc31bad66d46d44b4e6522c5c21976bf9bca4ef5987bb2bf727f4506cbb", "f9202fa138544e13a4ec1a6792c35834250a85958fde1251b6a22e07d1260ae7"]
urllib3 = ["b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", "dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232"]
wrapt = ["565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1"]
zipp = ["8c1019c6aad13642199fbe458275ad6a84907634cc9f0989877ccc4a2840139d", "ca943a7e809cc12257001ccfb99e3563da9af99d52f261725e96dfe0f9275bc3"]
zipp = ["4970c3758f4e89a7857a973b1e2a5d75bcdc47794442f2e2dd4fe8e0466e809a", "8a5712cfd3bb4248015eb3b0b3c54a5f6ee3f2425963ef2a0125b8bc40aafaec"]

Просмотреть файл

@ -37,6 +37,8 @@ mypy = "=0.670"
pylint = "=2.3.1"
pytest = "=4.0.1"
pytest-cov = "=2.6.0"
toml = "^0.10.0"
[build-system]
requires = ["poetry>=0.12"]

Просмотреть файл

@ -1,2 +1,66 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""Base test cases."""
import os
from typing import Any, Dict, List, Optional
import toml
class TestDetails:
"""Holds the test details."""
repository_id: str
token_identifier: str
token: str
username: str
tenant: str
project_id: str
def __init__(
self,
*,
repository_id: str,
token_identifier: str,
username: str,
tenant: str,
project_id: str
) -> None:
self.repository_id = repository_id
self.token_identifier = token_identifier
self.username = username
self.tenant = tenant
self.project_id = project_id
token = os.environ.get(token_identifier)
if token:
self.token = token
else:
raise Exception(f"No token was available for identifier: {token_identifier}")
def load_test_details() -> TestDetails:
"""Load the test details from disk."""
module_path = os.path.dirname(os.path.realpath(__file__))
config_path = os.path.join(module_path, "test_config.toml")
with open(config_path, 'r') as config_file:
config = toml.load(config_file)
repository_id = config["repository_id"]
token_identifier = config["token_identifier"]
username = config["username"]
tenant = config["tenant"]
project_id = config["project_id"]
return TestDetails(
repository_id=repository_id,
token_identifier=token_identifier,
username=username,
tenant=tenant,
project_id=project_id
)

5
tests/test_config.toml Normal file
Просмотреть файл

@ -0,0 +1,5 @@
repository_id = "25bb970f-4717-4baa-a215-1ef568f0e86a"
token_identifier = "SIMPLE_ADO_BASE_TOKEN"
username = "dalemy@microsoft.com"
tenant = "outlookmobile"
project_id = "40e534ca-7cf4-4e59-aa42-753d88b314e2"

Просмотреть файл

@ -11,13 +11,28 @@ import os
import sys
import unittest
from . import load_test_details
sys.path.insert(0, os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..")))
import simple_ado
import simple_ado # pylint: disable=wrong-import-order
class LibraryTests(unittest.TestCase):
"""Basic tests."""
def test_existence(self):
"""Test existence."""
self.assertIsNotNone(simple_ado)
def setUp(self) -> None:
"""Set up method."""
self.test_config = load_test_details()
self.client = simple_ado.ADOClient(
username=self.test_config.username,
tenant=self.test_config.tenant,
project_id=self.test_config.project_id,
repository_id=self.test_config.repository_id,
credentials=(self.test_config.username, self.test_config.token),
status_context="simple_ado",
)
def test_list_repos(self):
"""Test list repos."""
repos = self.client.git.all_repositories()
self.assertTrue(len(repos) > 0, "Failed to find any repos")