From 16891c52b9959f88fd5790b9fd60eb494c524ff3 Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Mon, 17 Dec 2018 13:48:03 +0530 Subject: [PATCH 01/15] Updating git ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d9de844..e2c5f9b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ __pycache__ venv +junk From 9639d618af00fb32065c4b13d71b13d37a04451d Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 16:48:42 +0530 Subject: [PATCH 02/15] Adding tests --- tests/tags | 24 ++++++++++++ tests/test_capitalize.py | 15 ++++++++ tests/test_wallet.py | 79 ++++++++++++++++++++++++++++++++++++++++ tests/wallet.py | 16 ++++++++ 4 files changed, 134 insertions(+) create mode 100644 tests/tags create mode 100644 tests/test_capitalize.py create mode 100644 tests/test_wallet.py create mode 100644 tests/wallet.py diff --git a/tests/tags b/tests/tags new file mode 100644 index 0000000..db358b8 --- /dev/null +++ b/tests/tags @@ -0,0 +1,24 @@ +!_TAG_FILE_SORTED 2 /0=unsorted, 1=sorted, 2=foldcase/ +add_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^ def add_cash(self, amount):$/;" m language:Python class:Wallet +capital_case /home/rahul/git/octopi_assembly/python-teamcity/tests/test_capitalize.py /^def capital_case(x):$/;" f language:Python +empty_wallet /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def empty_wallet():$/;" f language:Python +InsufficientAmount /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^class InsufficientAmount(Exception):$/;" c language:Python +my_wallet /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def my_wallet():$/;" f language:Python +spend_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^ def spend_cash(self, amount):$/;" m language:Python class:Wallet +test_capital_case /home/rahul/git/octopi_assembly/python-teamcity/tests/test_capitalize.py /^def test_capital_case():$/;" f language:Python +test_default_initial_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_default_initial_amount():$/;" f language:Python +test_default_initial_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_default_initial_amount(empty_wallet):$/;" f language:Python +test_raises_exception_on_non_string_arguments /home/rahul/git/octopi_assembly/python-teamcity/tests/test_capitalize.py /^def test_raises_exception_on_non_string_arguments():$/;" f language:Python +test_setting_initial_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_setting_initial_amount():$/;" f language:Python +test_setting_initial_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_setting_initial_amount(wallet):$/;" f language:Python +test_transactions /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_transactions(earned, spent, expected):$/;" f language:Python +test_transactions /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_transactions(my_wallet, earned, spent, expected):$/;" f language:Python +test_wallet_add_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_add_cash():$/;" f language:Python +test_wallet_add_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_add_cash(wallet):$/;" f language:Python +test_wallet_spend_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_spend_cash():$/;" f language:Python +test_wallet_spend_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_spend_cash(wallet):$/;" f language:Python +test_wallet_spend_cash_raises_exception_on_inufficient_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_spend_cash_raises_exception_on_inufficient_amount():$/;" f language:Python +test_wallet_spend_cash_raises_exception_on_inufficient_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_spend_cash_raises_exception_on_inufficient_amount(empty_wallet):$/;" f language:Python +wallet /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def wallet():$/;" f language:Python +Wallet /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^class Wallet(object):$/;" c language:Python +__init__ /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^ def __init__(self, initial_amount=0):$/;" m language:Python class:Wallet diff --git a/tests/test_capitalize.py b/tests/test_capitalize.py new file mode 100644 index 0000000..07040d0 --- /dev/null +++ b/tests/test_capitalize.py @@ -0,0 +1,15 @@ +import pytest + +def capital_case(x): + if not isinstance(x, str): + raise TypeError('Please provide a string argument') + return x.capitalize() + + +def test_capital_case(): + assert capital_case('semaphore') == 'Semaphore' + + +def test_raises_exception_on_non_string_arguments(): + with pytest.raises(TypeError): + capital_case(9) diff --git a/tests/test_wallet.py b/tests/test_wallet.py new file mode 100644 index 0000000..11adc22 --- /dev/null +++ b/tests/test_wallet.py @@ -0,0 +1,79 @@ +import pytest +from wallet import Wallet, InsufficientAmount + + +@pytest.fixture +def empty_wallet(): + '''Returns a wallet instance with a zero balance''' + return Wallet() + +@pytest.fixture +def wallet(): + '''Returns a wallet instance with the balance of 20''' + return Wallet(20) + + +def test_default_initial_amount(): + wallet = Wallet() + assert wallet.balance == 0 + +def test_setting_initial_amount(): + wallet = Wallet(100) + assert wallet.balance == 100 + +def test_wallet_add_cash(): + wallet = Wallet(10) + wallet.add_cash(90) + assert wallet.balance == 100 + +def test_wallet_spend_cash(): + wallet = Wallet(20) + wallet.spend_cash(10) + assert wallet.balance == 10 + +def test_wallet_spend_cash_raises_exception_on_inufficient_amount(): + wallet = Wallet() + with pytest.raises(InsufficientAmount): + wallet.spend_cash(100) + +def test_default_initial_amount(empty_wallet): + assert empty_wallet.balance == 0 + +def test_setting_initial_amount(wallet): + assert wallet.balance == 20 + +def test_wallet_add_cash(wallet): + wallet.add_cash(80) + assert wallet.balance == 100 + +def test_wallet_spend_cash(wallet): + wallet.spend_cash(10) + assert wallet.balance == 10 + +def test_wallet_spend_cash_raises_exception_on_inufficient_amount(empty_wallet): + with pytest.raises(InsufficientAmount): + empty_wallet.spend_cash(100) + +@pytest.mark.parametrize("earned,spent,expected", [ + (30, 10, 20), + (20, 2, 18) +]) +def test_transactions(earned, spent, expected): + my_wallet = Wallet() + my_wallet.add_cash(earned) + my_wallet.spend_cash(spent) + assert my_wallet.balance == expected + +@pytest.fixture +def my_wallet(): + '''Returns a Wallet instance with a zero balance''' + return Wallet() + +@pytest.mark.parametrize("earned,spent,expected", [ + (30, 10, 20), + (20, 2, 18) +]) +def test_transactions(my_wallet, earned, spent, expected): + my_wallet.add_cash(earned) + my_wallet.spend_cash(spent) + assert my_wallet.balance == expected diff --git a/tests/wallet.py b/tests/wallet.py new file mode 100644 index 0000000..39e3281 --- /dev/null +++ b/tests/wallet.py @@ -0,0 +1,16 @@ +class InsufficientAmount(Exception): + pass + + +class Wallet(object): + + def __init__(self, initial_amount=0): + self.balance = initial_amount + + def spend_cash(self, amount): + if self.balance < amount: + raise InsufficientAmount('Not enough available to spend {}'.format(amount)) + self.balance -= amount + + def add_cash(self, amount): + self.balance += amount From dca7ee0fb7a3e1fc8ca2fb764dfb351c4b3dd345 Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 16:51:54 +0530 Subject: [PATCH 03/15] Addnig pytest in requirements --- requirements.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/requirements.txt b/requirements.txt index bcd0e07..a17d3cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,13 @@ +atomicwrites==1.2.1 +attrs==18.2.0 certifi==2018.10.15 chardet==3.0.4 idna==2.7 +more-itertools==4.3.0 pkg-resources==0.0.0 +pluggy==0.8.0 +py==1.7.0 +pytest==4.0.2 python-dateutil==2.7.5 requests==2.20.1 six==1.12.0 From 10dd787df61a0a35fd4ef8613b298bc5a91714cc Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 17:06:27 +0530 Subject: [PATCH 04/15] Adding badge status --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fdb1eed..3c20423 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ README ====== +[![Build Status](https://semaphoreci.com/api/v1/srahul07-93/python-teamcity/branches/0-1/badge.svg)](https://semaphoreci.com/srahul07-93/python-teamcity) + + Python Teamcity is a python wrapper for the [Teamcity](https://www.jetbrains.com/teamcity/) REST API which aims to provide a more conventionally pythonic way of controlling a Teamcity server. It provides a higher-level API containing a number of @@ -64,7 +67,7 @@ Installing without setup.py Then install the required python packages using pip_:: $ sudo pip install python-teamcity - + Inspiration --------------- From 02ea08b363320718b8eefdc6b454f89d8f2c771d Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 17:30:34 +0530 Subject: [PATCH 05/15] Adding check for port to be in int --- teamcity/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teamcity/api.py b/teamcity/api.py index 884c6fd..bb8a994 100644 --- a/teamcity/api.py +++ b/teamcity/api.py @@ -34,7 +34,7 @@ def __init__(self, username, password, scheme="http", host="localhost", port=811 self.password = password if password else os.environ.get('TEAMCITY_PASSWORD') self.protocol = scheme self.host = host - self.port = port + self.port = port if isinstance(port, int) else int(port) self.session = kwargs.get('session', requests.Session()) self.session.auth = HTTPBasicAuth(self.username, self.password) From f6009c50fa1e9b6ac0e3a70062c445e23dc3752a Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 17:42:25 +0530 Subject: [PATCH 06/15] Addign tests for api --- tests/__init__.py | 1 + tests/test_api.py | 33 +++++++++++++++++ tests/test_capitalize.py | 15 -------- tests/test_wallet.py | 79 ---------------------------------------- tests/wallet.py | 16 -------- 5 files changed, 34 insertions(+), 110 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/test_api.py delete mode 100644 tests/test_capitalize.py delete mode 100644 tests/test_wallet.py delete mode 100644 tests/wallet.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..b974282 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +from . import * \ No newline at end of file diff --git a/tests/test_api.py b/tests/test_api.py new file mode 100644 index 0000000..c2a7049 --- /dev/null +++ b/tests/test_api.py @@ -0,0 +1,33 @@ +import pytest + +from teamcity.api import TeamcityApi + + +@pytest.fixture +def username(): + ''' Username for the tests + ''' + return "srahul07" + +@pytest.fixture +def password(): + """ Password for the tests + """ + return "rahul" + +class TestTeamcityApi(object): + + def test_default_initial_connect(self, username, password): + teamcity_api = TeamcityApi(username, password) + assert teamcity_api.protocol == "http" + assert teamcity_api.host == "localhost" + assert teamcity_api.port == 8111 + + @pytest.mark.parametrize("scheme, host, port", [ + ("http", "localhost", "8111") + ]) + def test_setting_initial_connect(self, username, password, scheme, host, port): + teamcity_api = TeamcityApi(username, password, scheme, host, port) + assert teamcity_api.protocol == "http" + assert teamcity_api.host == "localhost" + assert teamcity_api.port == 8111 \ No newline at end of file diff --git a/tests/test_capitalize.py b/tests/test_capitalize.py deleted file mode 100644 index 07040d0..0000000 --- a/tests/test_capitalize.py +++ /dev/null @@ -1,15 +0,0 @@ -import pytest - -def capital_case(x): - if not isinstance(x, str): - raise TypeError('Please provide a string argument') - return x.capitalize() - - -def test_capital_case(): - assert capital_case('semaphore') == 'Semaphore' - - -def test_raises_exception_on_non_string_arguments(): - with pytest.raises(TypeError): - capital_case(9) diff --git a/tests/test_wallet.py b/tests/test_wallet.py deleted file mode 100644 index 11adc22..0000000 --- a/tests/test_wallet.py +++ /dev/null @@ -1,79 +0,0 @@ -import pytest -from wallet import Wallet, InsufficientAmount - - -@pytest.fixture -def empty_wallet(): - '''Returns a wallet instance with a zero balance''' - return Wallet() - -@pytest.fixture -def wallet(): - '''Returns a wallet instance with the balance of 20''' - return Wallet(20) - - -def test_default_initial_amount(): - wallet = Wallet() - assert wallet.balance == 0 - -def test_setting_initial_amount(): - wallet = Wallet(100) - assert wallet.balance == 100 - -def test_wallet_add_cash(): - wallet = Wallet(10) - wallet.add_cash(90) - assert wallet.balance == 100 - -def test_wallet_spend_cash(): - wallet = Wallet(20) - wallet.spend_cash(10) - assert wallet.balance == 10 - -def test_wallet_spend_cash_raises_exception_on_inufficient_amount(): - wallet = Wallet() - with pytest.raises(InsufficientAmount): - wallet.spend_cash(100) - -def test_default_initial_amount(empty_wallet): - assert empty_wallet.balance == 0 - -def test_setting_initial_amount(wallet): - assert wallet.balance == 20 - -def test_wallet_add_cash(wallet): - wallet.add_cash(80) - assert wallet.balance == 100 - -def test_wallet_spend_cash(wallet): - wallet.spend_cash(10) - assert wallet.balance == 10 - -def test_wallet_spend_cash_raises_exception_on_inufficient_amount(empty_wallet): - with pytest.raises(InsufficientAmount): - empty_wallet.spend_cash(100) - -@pytest.mark.parametrize("earned,spent,expected", [ - (30, 10, 20), - (20, 2, 18) -]) -def test_transactions(earned, spent, expected): - my_wallet = Wallet() - my_wallet.add_cash(earned) - my_wallet.spend_cash(spent) - assert my_wallet.balance == expected - -@pytest.fixture -def my_wallet(): - '''Returns a Wallet instance with a zero balance''' - return Wallet() - -@pytest.mark.parametrize("earned,spent,expected", [ - (30, 10, 20), - (20, 2, 18) -]) -def test_transactions(my_wallet, earned, spent, expected): - my_wallet.add_cash(earned) - my_wallet.spend_cash(spent) - assert my_wallet.balance == expected diff --git a/tests/wallet.py b/tests/wallet.py deleted file mode 100644 index 39e3281..0000000 --- a/tests/wallet.py +++ /dev/null @@ -1,16 +0,0 @@ -class InsufficientAmount(Exception): - pass - - -class Wallet(object): - - def __init__(self, initial_amount=0): - self.balance = initial_amount - - def spend_cash(self, amount): - if self.balance < amount: - raise InsufficientAmount('Not enough available to spend {}'.format(amount)) - self.balance -= amount - - def add_cash(self, amount): - self.balance += amount From c76a5b9a7e661d434b292984de552bc8a3696019 Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 17:45:45 +0530 Subject: [PATCH 07/15] Removing tags --- tests/tags | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 tests/tags diff --git a/tests/tags b/tests/tags deleted file mode 100644 index db358b8..0000000 --- a/tests/tags +++ /dev/null @@ -1,24 +0,0 @@ -!_TAG_FILE_SORTED 2 /0=unsorted, 1=sorted, 2=foldcase/ -add_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^ def add_cash(self, amount):$/;" m language:Python class:Wallet -capital_case /home/rahul/git/octopi_assembly/python-teamcity/tests/test_capitalize.py /^def capital_case(x):$/;" f language:Python -empty_wallet /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def empty_wallet():$/;" f language:Python -InsufficientAmount /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^class InsufficientAmount(Exception):$/;" c language:Python -my_wallet /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def my_wallet():$/;" f language:Python -spend_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^ def spend_cash(self, amount):$/;" m language:Python class:Wallet -test_capital_case /home/rahul/git/octopi_assembly/python-teamcity/tests/test_capitalize.py /^def test_capital_case():$/;" f language:Python -test_default_initial_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_default_initial_amount():$/;" f language:Python -test_default_initial_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_default_initial_amount(empty_wallet):$/;" f language:Python -test_raises_exception_on_non_string_arguments /home/rahul/git/octopi_assembly/python-teamcity/tests/test_capitalize.py /^def test_raises_exception_on_non_string_arguments():$/;" f language:Python -test_setting_initial_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_setting_initial_amount():$/;" f language:Python -test_setting_initial_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_setting_initial_amount(wallet):$/;" f language:Python -test_transactions /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_transactions(earned, spent, expected):$/;" f language:Python -test_transactions /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_transactions(my_wallet, earned, spent, expected):$/;" f language:Python -test_wallet_add_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_add_cash():$/;" f language:Python -test_wallet_add_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_add_cash(wallet):$/;" f language:Python -test_wallet_spend_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_spend_cash():$/;" f language:Python -test_wallet_spend_cash /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_spend_cash(wallet):$/;" f language:Python -test_wallet_spend_cash_raises_exception_on_inufficient_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_spend_cash_raises_exception_on_inufficient_amount():$/;" f language:Python -test_wallet_spend_cash_raises_exception_on_inufficient_amount /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def test_wallet_spend_cash_raises_exception_on_inufficient_amount(empty_wallet):$/;" f language:Python -wallet /home/rahul/git/octopi_assembly/python-teamcity/tests/test_wallet.py /^def wallet():$/;" f language:Python -Wallet /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^class Wallet(object):$/;" c language:Python -__init__ /home/rahul/git/octopi_assembly/python-teamcity/tests/wallet.py /^ def __init__(self, initial_amount=0):$/;" m language:Python class:Wallet From 329cbc32888fe9e2f680f593a4c2e59e1e70782d Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 17:45:57 +0530 Subject: [PATCH 08/15] Ignoring tags files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e2c5f9b..00f724b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ .sonarlint .vscode +tags + __pycache__ venv junk From 75f791426ef455f6719a308921cc4d0b13de09f5 Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 17:51:38 +0530 Subject: [PATCH 09/15] Updating requirements --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index a17d3cd..160b606 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,14 @@ atomicwrites==1.2.1 attrs==18.2.0 -certifi==2018.10.15 +certifi==2018.11.29 chardet==3.0.4 -idna==2.7 +idna==2.8 more-itertools==4.3.0 pkg-resources==0.0.0 pluggy==0.8.0 py==1.7.0 pytest==4.0.2 python-dateutil==2.7.5 -requests==2.20.1 +requests==2.21.0 six==1.12.0 urllib3==1.24.1 From bd043efa4dc89dd1e64d27b5ffc692768381db63 Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 18:02:41 +0530 Subject: [PATCH 10/15] Updating requirements by removing pkg-resources --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 160b606..0d88385 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,6 @@ certifi==2018.11.29 chardet==3.0.4 idna==2.8 more-itertools==4.3.0 -pkg-resources==0.0.0 pluggy==0.8.0 py==1.7.0 pytest==4.0.2 From 0e2ccc8e573ae03dc56700afcb4825f82a6574b6 Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 18:10:02 +0530 Subject: [PATCH 11/15] Adding test for checking base url --- tests/test_api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_api.py b/tests/test_api.py index c2a7049..ff72bb7 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -30,4 +30,8 @@ def test_setting_initial_connect(self, username, password, scheme, host, port): teamcity_api = TeamcityApi(username, password, scheme, host, port) assert teamcity_api.protocol == "http" assert teamcity_api.host == "localhost" - assert teamcity_api.port == 8111 \ No newline at end of file + assert teamcity_api.port == 8111 + + def test_base_url(self, username, password): + teamcity_api = TeamcityApi(username, password) + assert teamcity_api.base_url == "http://localhost:8111" \ No newline at end of file From 2f27b8174635ca9220bb9cdd77f70d3f62d22b42 Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 18:15:51 +0530 Subject: [PATCH 12/15] Updating build badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c20423..25524bb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ README ====== -[![Build Status](https://semaphoreci.com/api/v1/srahul07-93/python-teamcity/branches/0-1/badge.svg)](https://semaphoreci.com/srahul07-93/python-teamcity) +[![Build Status](https://semaphoreci.com/api/v1/octopi-assembly/python-teamcity/branches/0-1/shields_badge.svg)](https://semaphoreci.com/octopi-assembly/python-teamcity) Python Teamcity is a python wrapper for the [Teamcity](https://www.jetbrains.com/teamcity/) From a0a220498a1dea358181d52f1e44d4dbc334de16 Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 18:38:29 +0530 Subject: [PATCH 13/15] Adding generated url test --- tests/test_api.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_api.py b/tests/test_api.py index ff72bb7..f366a4e 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -34,4 +34,11 @@ def test_setting_initial_connect(self, username, password, scheme, host, port): def test_base_url(self, username, password): teamcity_api = TeamcityApi(username, password) - assert teamcity_api.base_url == "http://localhost:8111" \ No newline at end of file + assert teamcity_api.base_url == "http://localhost:8111" + + @pytest.mark.parametrize("scheme, host, port, expected", [ + ("https", "example.com", 443, "https://example.com") + ]) + def test__generate_url(self, username, password, scheme, host, port, expected): + teamcity_api = TeamcityApi(username, password, scheme, host, port) + assert teamcity_api._generate_url() == expected \ No newline at end of file From fb89a73fdf93d329dfb49e2a0b6137dd9a88036c Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 19:01:54 +0530 Subject: [PATCH 14/15] Adding check for null auth --- teamcity/teamcity.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/teamcity/teamcity.py b/teamcity/teamcity.py index 4a7bb01..766c970 100644 --- a/teamcity/teamcity.py +++ b/teamcity/teamcity.py @@ -31,7 +31,10 @@ def _generate_api_endpoint(self): if os.environ.get('TEAMCITY_API_VERSION'): api = os.environ.get('TEAMCITY_API') auth = "{auth}/{api}/{version}".format(auth=auth, api=api, version=os.environ.get('TEAMCITY_API_VERSION')) - self.api_endpoint = "{base_url}/{auth}".format(base_url=self.base_url, auth=auth) + if auth: + self.api_endpoint = "{base_url}/{auth}".format(base_url=self.base_url, auth=auth) + else: + self.api_endpoint = "{base_url}".format(base_url=self.base_url) @classmethod def from_environ(cls): From 462bfed43ee8b430cbd36850e59cc2cae2b4f61c Mon Sep 17 00:00:00 2001 From: Rahul Shelke Date: Sat, 22 Dec 2018 19:02:06 +0530 Subject: [PATCH 15/15] Adding test for teamcity class --- tests/test_teamcity.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/test_teamcity.py diff --git a/tests/test_teamcity.py b/tests/test_teamcity.py new file mode 100644 index 0000000..3eb7c4f --- /dev/null +++ b/tests/test_teamcity.py @@ -0,0 +1,15 @@ +import pytest + +from teamcity.teamcity import Teamcity + + +class TestTeamcity(object): + + def test_username_password(self): + teamcity = Teamcity("srahul07", "rahul") + assert teamcity.username == "srahul07" + assert teamcity.password == "rahul" + + def test_default_initial_connect(self): + teamcity = Teamcity("srahul07", "rahul") + assert teamcity.api_endpoint != "http://localhost:8111/httpAuth" \ No newline at end of file