From 6af53891ae9bb8a56f4a697624294bf283cf04be Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Fri, 1 Nov 2019 11:37:53 +0100 Subject: [PATCH 01/17] Use positional arguments when rendering formats in strings --- phabfive/core.py | 16 ++++++++-------- setup.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/phabfive/core.py b/phabfive/core.py index e0589b6..cbe9d86 100644 --- a/phabfive/core.py +++ b/phabfive/core.py @@ -44,19 +44,19 @@ def __init__(self): if "PHABFIVE_DEBUG" in os.environ: log.setLevel(logging.DEBUG) log.info( - "Loglevel is: {}".format(logging.getLevelName(log.getEffectiveLevel())) + "Loglevel is: {0}".format(logging.getLevelName(log.getEffectiveLevel())) ) self.conf = self.load_config() maxlen = 8 + len(max(dict(self.conf).keys(), key=len)) for k, v in dict(self.conf).items(): - log.debug("{} {} {}".format(k, "." * (maxlen - len(k)), v)) + log.debug("{0} {1} {2}".format(k, "." * (maxlen - len(k)), v)) # check for required configurables for k, v in dict(self.conf).items(): if k in REQUIRED and not v: - error = "{} is not configured".format(k) + error = "{0} is not configured".format(k) example = CONFIG_EXAMPLES.get(k) if example: error += ", " + example @@ -65,7 +65,7 @@ def __init__(self): # check validity of configurables for k in VALIDATORS.keys(): if not re.match(VALIDATORS[k], self.conf[k]): - error = "{} is malformed".format(k) + error = "{0} is malformed".format(k) example = VALID_EXAMPLES.get(k) if example: error += ", " + example @@ -105,7 +105,7 @@ def load_config(self): os.environ["XDG_CONFIG_DIRS"] = "/etc" site_conf_file = os.path.join(appdirs.site_config_dir("phabfive") + ".yaml") - log.debug("Loading configuration file: {}".format(site_conf_file)) + log.debug("Loading configuration file: {0}".format(site_conf_file)) anyconfig.merge( conf, { @@ -120,7 +120,7 @@ def load_config(self): site_conf_dir = os.path.join( appdirs.site_config_dir("phabfive") + ".d", "*.yaml" ) - log.debug("Loading configuration files: {}".format(site_conf_dir)) + log.debug("Loading configuration files: {0}".format(site_conf_dir)) anyconfig.merge( conf, { @@ -131,7 +131,7 @@ def load_config(self): ) user_conf_file = os.path.join(appdirs.user_config_dir("phabfive")) + ".yaml" - log.debug("Loading configuration file: {}".format(user_conf_file)) + log.debug("Loading configuration file: {0}".format(user_conf_file)) anyconfig.merge( conf, { @@ -146,7 +146,7 @@ def load_config(self): user_conf_dir = os.path.join( appdirs.user_config_dir("phabfive") + ".d", "*.yaml" ) - log.debug("Loading configuration files: {}".format(user_conf_dir)) + log.debug("Loading configuration files: {0}".format(user_conf_dir)) anyconfig.merge( conf, { diff --git a/setup.py b/setup.py index 63abaef..bbcad85 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ install_requires = ["anyconfig", "appdirs", "phabricator", "pyyaml", "docopt"] tests_require = ["coverage", "flake8", "pytest", "tox"] docs_require = ["docs"] -download_url = "{}/tarball/v{}".format( +download_url = "{0}/tarball/v{1}".format( "https://github.com/dynamist/phabfive", phabfive.__version__ ) From e14e04ba69e781fdff6bc4843543364d4572be92 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Fri, 1 Nov 2019 13:47:05 +0100 Subject: [PATCH 02/17] all internal constants should be imported with * to avoid to many imports and having to explicitly define all variabels we can/will import --- phabfive/cli.py | 2 +- phabfive/diffusion.py | 7 +------ phabfive/passphrase.py | 2 +- phabfive/paste.py | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/phabfive/cli.py b/phabfive/cli.py index 45a897f..ac9af13 100644 --- a/phabfive/cli.py +++ b/phabfive/cli.py @@ -8,7 +8,7 @@ # phabfive imports from phabfive import passphrase, diffusion, paste, user -from phabfive.constants import MONOGRAMS, REPO_STATUS_CHOICES +from phabfive.constants import * from phabfive.exceptions import ( PhabfiveConfigException, PhabfiveDataException, diff --git a/phabfive/diffusion.py b/phabfive/diffusion.py index 9ded69f..0903754 100644 --- a/phabfive/diffusion.py +++ b/phabfive/diffusion.py @@ -4,12 +4,7 @@ import re # phabfive imports -from phabfive.constants import ( - DISPLAY_CHOICES, - IO_NEW_URI_CHOICES, - MONOGRAMS, - REPO_STATUS_CHOICES, -) +from phabfive.constants import * from phabfive.core import Phabfive from phabfive.exceptions import PhabfiveDataException, PhabfiveConfigException from phabfive import passphrase diff --git a/phabfive/passphrase.py b/phabfive/passphrase.py index 3894368..ec2a47b 100644 --- a/phabfive/passphrase.py +++ b/phabfive/passphrase.py @@ -7,7 +7,7 @@ # phabfive imports from phabfive.core import Phabfive -from phabfive.constants import MONOGRAMS +from phabfive.constants import * from phabfive.exceptions import PhabfiveDataException, PhabfiveRemoteException # 3rd party imports diff --git a/phabfive/paste.py b/phabfive/paste.py index fde2679..6813857 100644 --- a/phabfive/paste.py +++ b/phabfive/paste.py @@ -6,7 +6,7 @@ # phabfive imports from phabfive.core import Phabfive from phabfive.exceptions import PhabfiveDataException -from phabfive.constants import MONOGRAMS +from phabfive.constants import * # 3rd party imports from phabricator import APIError From cb66af6d649f1d193816da7f951b739d4f2ab576 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Fri, 1 Nov 2019 13:47:46 +0100 Subject: [PATCH 03/17] Some minor linting stuff --- phabfive/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phabfive/core.py b/phabfive/core.py index cbe9d86..52a0871 100644 --- a/phabfive/core.py +++ b/phabfive/core.py @@ -39,7 +39,6 @@ class Phabfive(object): def __init__(self): - # Get super-early debugging by `export PHABFIVE_DEBUG=1` if "PHABFIVE_DEBUG" in os.environ: log.setLevel(logging.DEBUG) @@ -70,6 +69,7 @@ def __init__(self): if example: error += ", " + example raise PhabfiveConfigException(error) + self.phab = Phabricator( host=self.conf.get("PHAB_URL"), token=self.conf.get("PHAB_TOKEN") ) From 4621ee15b34bb0d41269fb19e48f46ea5fb88a90 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Fri, 1 Nov 2019 13:51:00 +0100 Subject: [PATCH 04/17] Implement a few testing methods that do basic validation of the Core object and the functions and features of it --- tests/test_core.py | 86 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 tests/test_core.py diff --git a/tests/test_core.py b/tests/test_core.py new file mode 100644 index 0000000..e47ef57 --- /dev/null +++ b/tests/test_core.py @@ -0,0 +1,86 @@ +import mock +import os + +from phabricator import Phabricator, APIError +from phabfive.core import Phabfive +from phabfive.exceptions import PhabfiveConfigException, PhabfiveRemoteException + +# 3rd party imports +import pytest +from mock import patch, Mock + + +def test_class_init(): + """ + Should be possible to create the main core class w/o any errors when nothing is configred + """ + p = Phabfive() + + # This should always default to False + assert "PHABFIVE_DEBUG" in p.conf + assert p.conf["PHABFIVE_DEBUG"] == False + + +@mock.patch.dict(os.environ, {"PHABFIVE_DEBUG": "1"}) +def test_phabfive_debug_envrion(): + """ + """ + p = Phabfive() + # This should always default to False + assert "PHABFIVE_DEBUG" in p.conf + assert p.conf["PHABFIVE_DEBUG"] == "1" + + +@mock.patch.dict(os.environ, {"PHAB_URL": "", "PHAB_TOKEN": ""}) +def test_empty_url_or_token(): + """ + If the config can't figure out a valid url or token it should raise a exception in the code + """ + with pytest.raises(PhabfiveConfigException) as ex: + p = Phabfive() + + +@mock.patch.dict(os.environ, {"PHAB_URL": "foobar", "PHAB_TOKEN": "barfoo"}) +def test_validator_phab_url(): + """ + When providing some data to PHAB_URL it should raise a config validation error + """ + with pytest.raises(PhabfiveConfigException): + p = Phabfive() + + +@mock.patch.dict( + os.environ, {"PHAB_URL": "http://127.0.0.1/api", "PHAB_TOKEN": '1'}, +) +def test_validator_phab_token(): + """ + When providing some data to PHAB_URL it should raise a config validation error + """ + with pytest.raises(PhabfiveConfigException): + p = Phabfive() + + +@mock.patch.dict( + os.environ, + { + "PHAB_URL": "http://127.0.0.1/api/", + "PHAB_TOKEN": "api-bjmudcq4mjtxprkk7w3s4fkdqz6z", + }, +) +def test_whoami_api_error(): + """ + When creating the object, it tries to run user.whoami() method on Phabricator class. + + Validate that when whoami() call returns a internal APIError we should reraise it as a PhabfiveRemoteException exception. + """ + with patch.object( + Phabricator, "__getattr__", autospec=True + ) as dynamic_phabricator_getattr: + + def side_effect(self, *args, **kwargs): + raise APIError(1, "foobar") + + dynamic_phabricator_getattr.side_effect = side_effect + + with pytest.raises(PhabfiveRemoteException): + p = Phabfive() From 611ad7321508345be26d4ed67bf4fdff66b38626 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Fri, 1 Nov 2019 14:24:46 +0100 Subject: [PATCH 05/17] Implement basic tests for User, Passphrase, Diffusion and Paste classes --- tests/test_core.py | 2 +- tests/test_diffusion.py | 43 +++++++++++++++++++++++++++++++++++++++ tests/test_passphrase.py | 43 +++++++++++++++++++++++++++++++++++++++ tests/test_paste.py | 44 ++++++++++++++++++++++++++++++++++++++++ tests/test_user.py | 36 ++++++++++++++++++++++++++++++++ 5 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 tests/test_diffusion.py create mode 100644 tests/test_passphrase.py create mode 100644 tests/test_paste.py create mode 100644 tests/test_user.py diff --git a/tests/test_core.py b/tests/test_core.py index e47ef57..e6e84f0 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,4 +1,3 @@ -import mock import os from phabricator import Phabricator, APIError @@ -6,6 +5,7 @@ from phabfive.exceptions import PhabfiveConfigException, PhabfiveRemoteException # 3rd party imports +import mock import pytest from mock import patch, Mock diff --git a/tests/test_diffusion.py b/tests/test_diffusion.py new file mode 100644 index 0000000..73278e4 --- /dev/null +++ b/tests/test_diffusion.py @@ -0,0 +1,43 @@ +# python std lib +import os + +# phabfive imports +from phabfive.core import Phabfive +from phabfive.diffusion import Diffusion +from phabfive.exceptions import PhabfiveConfigException + +# 3rd party imports +import mock +import pytest +from mock import patch, Mock + + +def test_diffusion_class(): + """ + Basic class tests for issues caused when creating the object and that it inherits from + the correct parent class that we expect + """ + d = Diffusion() + + # Validate that Diffusion class inherits from Phabfive parent class + assert Phabfive in d.__class__.__bases__ + + +@mock.patch.dict(os.environ, {"PHAB_URL": "", "PHAB_TOKEN": ""}) +def test_empty_url_or_token(): + """ + Validate that Diffusion works the same way as Phabricator parent class + """ + with pytest.raises(PhabfiveConfigException) as ex: + d = Diffusion() + + +def test_validator(): + """ + We assume that passphrase identifier validator is + R[0-9]+ + """ + d = Diffusion() + + assert d._validate_identifier('R1') is not None + assert d._validate_identifier('foobar') is None diff --git a/tests/test_passphrase.py b/tests/test_passphrase.py new file mode 100644 index 0000000..aabf1d0 --- /dev/null +++ b/tests/test_passphrase.py @@ -0,0 +1,43 @@ +# python std lib +import os + +# phabfive imports +from phabfive.core import Phabfive +from phabfive.passphrase import Passphrase +from phabfive.exceptions import PhabfiveConfigException + +# 3rd party imports +import mock +import pytest +from mock import patch, Mock + + +def test_passphrase_class(): + """ + Basic class tests for issues caused when creating the object and that it inherits from + the correct parent class that we expect. + """ + p = Passphrase() + + # Validate that Passphrase class inherits from Phabfive parent class + assert Phabfive in p.__class__.__bases__ + + +@mock.patch.dict(os.environ, {"PHAB_URL": "", "PHAB_TOKEN": ""}) +def test_empty_url_or_token(): + """ + Validate that Diffusion works the same way as Phabricator parent class + """ + with pytest.raises(PhabfiveConfigException) as ex: + p = Passphrase() + + +def test_validator(): + """ + We assume that passphrase identifier validator is + K[0-9]+ + """ + p = Passphrase() + + assert p._validate_identifier('K1') is not None + assert p._validate_identifier('foobar') is None diff --git a/tests/test_paste.py b/tests/test_paste.py new file mode 100644 index 0000000..6410c24 --- /dev/null +++ b/tests/test_paste.py @@ -0,0 +1,44 @@ +# python std lib +import os + +# phabfive imports +from phabfive.core import Phabfive +from phabfive.exceptions import PhabfiveConfigException +from phabfive.paste import Paste + +# 3rd party imports +import mock +import pytest +from mock import patch, Mock + + +def test_paste_class(): + """ + Basic class tests for issues caused when creating the object and that it inherits from + the correct parent class that we expect + """ + p = Paste() + + # Validate that Paste class inherits from Phabfive parent class + assert Phabfive in p.__class__.__bases__ + + +@mock.patch.dict(os.environ, {"PHAB_URL": "", "PHAB_TOKEN": ""}) +def test_empty_url_or_token(): + """ + Validate that Diffusion works the same way as Phabricator parent class + """ + with pytest.raises(PhabfiveConfigException) as ex: + p = Paste() + + +def test_validator(): + """ + We assume that passphrase identifier validator is + P[0-9]+ + """ + p = Paste() + + assert p._validate_identifier('P1') is not None + assert p._validate_identifier('foobar') is None + diff --git a/tests/test_user.py b/tests/test_user.py new file mode 100644 index 0000000..0062280 --- /dev/null +++ b/tests/test_user.py @@ -0,0 +1,36 @@ +# python std lib +import os + +# phabfive imports +from phabfive.core import Phabfive +from phabfive.exceptions import PhabfiveConfigException +from phabfive.user import User + +# 3rd party imports +import mock +import pytest +from mock import patch, Mock + + +def test_user_class(): + """ + Basic class tests for issues caused when creating the object and that it inherits from + the correct parent class that we expect + """ + u = User() + + # Validate that User class inherits from Phabfive parent class + assert Phabfive in u.__class__.__bases__ + + +@mock.patch.dict(os.environ, {"PHAB_URL": "", "PHAB_TOKEN": ""}) +def test_empty_url_or_token(): + """ + Validate that Diffusion works the same way as Phabricator parent class + """ + with pytest.raises(PhabfiveConfigException) as ex: + u = User() + + +def test_whoami(): + pass From 98afa7b4fc98147be0b442302713908a9964d0f1 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Fri, 1 Nov 2019 14:32:42 +0100 Subject: [PATCH 06/17] Add tests for Paste._convert_ids and added more validation of the input data and raise Exceptions if we input the wrong data to the method --- phabfive/paste.py | 3 +++ tests/test_paste.py | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/phabfive/paste.py b/phabfive/paste.py index 6813857..8e62653 100644 --- a/phabfive/paste.py +++ b/phabfive/paste.py @@ -21,6 +21,9 @@ def _validate_identifier(self, id_): def _convert_ids(self, ids): """Method used by print function.""" + if not isinstance(ids, list): + raise PhabfiveDataException("variable ids must be of list type") + ids_list_int = [] for id_ in ids: diff --git a/tests/test_paste.py b/tests/test_paste.py index 6410c24..8943ee3 100644 --- a/tests/test_paste.py +++ b/tests/test_paste.py @@ -3,7 +3,7 @@ # phabfive imports from phabfive.core import Phabfive -from phabfive.exceptions import PhabfiveConfigException +from phabfive.exceptions import PhabfiveConfigException, PhabfiveDataException from phabfive.paste import Paste # 3rd party imports @@ -42,3 +42,20 @@ def test_validator(): assert p._validate_identifier('P1') is not None assert p._validate_identifier('foobar') is None + +def test_convert_ids(): + """ + """ + p = Paste() + + # No ID:s to convert so return empty list + with pytest.raises(PhabfiveDataException): + p._convert_ids(None) + + assert p._convert_ids([]) == [] + + # If we pass in a ID that will not validate against the MONOGRAMS + with pytest.raises(PhabfiveDataException): + p._convert_ids(['foobar']) + + assert p._convert_ids(['P1', 'P11']) == [1, 11] From f3cfdd35431be89ed70c90769d4b935878721d65 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sat, 2 Nov 2019 08:19:05 +0100 Subject: [PATCH 07/17] Added more tests for paste module. Fixed a file loading issue where any value was attempted to be loaded but only if a valid path is provided it should not cause a exception --- phabfive/paste.py | 8 ++-- tests/test_paste.py | 96 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 3 deletions(-) diff --git a/phabfive/paste.py b/phabfive/paste.py index 8e62653..75b2993 100644 --- a/phabfive/paste.py +++ b/phabfive/paste.py @@ -51,12 +51,14 @@ def create_paste( :rtype: dict """ - text = None tags = tags if tags else [] subscribers = subscribers if subscribers else [] - with open(file, "r") as f: - text = f.read() + if file: + with open(file, "r") as f: + text = f.read() + else: + text = None transactions = [] transactions_values = [ diff --git a/tests/test_paste.py b/tests/test_paste.py index 8943ee3..93b504f 100644 --- a/tests/test_paste.py +++ b/tests/test_paste.py @@ -2,6 +2,7 @@ import os # phabfive imports +from phabricator import APIError, Phabricator from phabfive.core import Phabfive from phabfive.exceptions import PhabfiveConfigException, PhabfiveDataException from phabfive.paste import Paste @@ -12,6 +13,24 @@ from mock import patch, Mock +class MockEditResource(): + def __init__(self, wanted_response): + self.wanted_response = wanted_response + + def edit(self, *args, **kwargs): + self.edit_args = args + self.edit_kwargs = kwargs + + return self.wanted_response + + +class MockPhabricator(): + + def __init__(self, wanted_response, *args, **kwargs): + self.wanted_response = wanted_response + self.paste = MockEditResource(self.wanted_response) + + def test_paste_class(): """ Basic class tests for issues caused when creating the object and that it inherits from @@ -59,3 +78,80 @@ def test_convert_ids(): p._convert_ids(['foobar']) assert p._convert_ids(['P1', 'P11']) == [1, 11] + + +def test_create_paste_api_error_on_edit(): + """ + When inputting valid arguments but the backend sends up APIError we should get a wrapped + PhabfiveDataException raised back up to us. + """ + with patch.object(Phabricator, "__call__", autospec=True) as dynamic_phabricator_call: + def side_effect(self, *args, **kwargs): + print("inside", args, kwargs) + raise APIError(1, "foobar") + + dynamic_phabricator_call.side_effect = side_effect + + with pytest.raises(PhabfiveDataException): + p = Paste() + p.create_paste( + title="title_foo", + file=None, + language="lang_foo", + subscribers="subs_foo", + ) + + +def test_create_paste_invalid_file_error(): + """ + If we input a file path that do not compute to a file on disk we should check + for the normal FileNotFoundError python exception. + """ + with pytest.raises(FileNotFoundError): + p = Paste() + p.create_paste( + title='title_foo', + file='random_foobar_file.txt', + language='lang_foo', + subscribers='subs_foo', + ) + + +def test_create_paste_transaction_values(): + """ + When inputting all valid data we need to check that transactions values is as expected and + built up propelry to all data that we need. + """ + p = Paste() + p.phab = MockPhabricator({'object': 'foobar'}) + + result = p.create_paste( + title="title_foo", + file=None, + language="lang_foo", + subscribers="subs_foo", + ) + assert result == 'foobar' + print(p.phab.paste.edit_args) + print(p.phab.paste.edit_kwargs) + + expected_transactions = { + "transactions": [ + { + "type": "title", + "value": "title_foo" + }, + { + "type": "language", + "value": "lang_foo" + }, + { + "type": "projects.add", + "value": [] + }, + { + "type": "subscribers.add", + "value": "subs_foo" + } + ] + } From 541a23c96a2f1364a4ead038d938297813ca7291 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sat, 2 Nov 2019 08:20:03 +0100 Subject: [PATCH 08/17] Added mock to requirements --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bbcad85..bd38835 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ CHANGELOG = f.read() install_requires = ["anyconfig", "appdirs", "phabricator", "pyyaml", "docopt"] -tests_require = ["coverage", "flake8", "pytest", "tox"] +tests_require = ["coverage", "flake8", "pytest", "tox", "mock"] docs_require = ["docs"] download_url = "{0}/tarball/v{1}".format( "https://github.com/dynamist/phabfive", phabfive.__version__ From 9100696314e46327c745cea68b65fde1a1d1558f Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Wed, 8 Jan 2020 16:25:12 +0100 Subject: [PATCH 09/17] Removed two sections of bug report template that is not supposed to be there in this git repo --- .github/ISSUE_TEMPLATE/bug_report.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index be1da76..d6db543 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -29,22 +29,6 @@ about: Report a reproducible bug in the current release of Phabfive 3. -### Schema - - -``` - -``` - - -### Data - - -``` - -``` - - ### Expected Behavior From 3feed8baf9d4b877df1eb1a54ce9b5c191280dff Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Wed, 8 Jan 2020 16:29:24 +0100 Subject: [PATCH 10/17] Minor cleanup in feature request template --- .github/ISSUE_TEMPLATE/feature_request.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 7d70428..e20ae4b 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -13,8 +13,11 @@ about: Propose a new Phabfive feature or enhancement --> ### Environment -* Phabfive version: -* Python version: + +* Phabfive version: + + +* Python version: ### Use Case + * None + ### Other? -None + * None From e174292199b0e74f60aabdacc363e0f8d78039cb Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Wed, 8 Jan 2020 16:35:44 +0100 Subject: [PATCH 11/17] Add env variabels override to test methods --- tests/test_diffusion.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_diffusion.py b/tests/test_diffusion.py index 73278e4..152d22d 100644 --- a/tests/test_diffusion.py +++ b/tests/test_diffusion.py @@ -12,6 +12,13 @@ from mock import patch, Mock +@mock.patch.dict( + os.environ, + { + "PHAB_URL": "http://127.0.0.1/api/", + "PHAB_TOKEN": "api-bjmudcq4mjtxprkk7w3s4fkdqz6z", + }, +) def test_diffusion_class(): """ Basic class tests for issues caused when creating the object and that it inherits from @@ -32,6 +39,13 @@ def test_empty_url_or_token(): d = Diffusion() +@mock.patch.dict( + os.environ, + { + "PHAB_URL": "http://127.0.0.1/api/", + "PHAB_TOKEN": "api-bjmudcq4mjtxprkk7w3s4fkdqz6z", + }, +) def test_validator(): """ We assume that passphrase identifier validator is From 3d5691c01b6fdc7d95261ece0b421b04b290f9f2 Mon Sep 17 00:00:00 2001 From: Grokzen Date: Wed, 8 Jan 2020 17:26:13 +0100 Subject: [PATCH 12/17] Add badges to README about the status of the repo --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index caccec8..f951910 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # phabfive +[![Travis CI](https://travis-ci.com/dynamist/phabfive.svg?branch=master)](https://travis-ci.com/dynamist/phabfive) +[![Current release](https://img.shields.io/github/v/release/dynamist/phabfive.svg)](https://github.com/dynamist/phabfive/releases) +[![GitHub issues](https://img.shields.io/github/issues/dynamist/phabfive.svg?maxAge=360)](https://github.com/dynamist/phabfive/issues) +[![License](https://img.shields.io/github/license/dynamist/phabfive?color=%23fe0000)](https://github.com/dynamist/phabfive/blob/master/LICENSE) + A command line tool to interact with Phabricator. The complete documentation for Phabfive can be found at [Read the Docs](https://phabfive.readthedocs.io/en/latest/) From e6a30ca158043b7bd1cb3010c57e42f2dfcf3d66 Mon Sep 17 00:00:00 2001 From: Grokzen Date: Wed, 8 Jan 2020 17:37:03 +0100 Subject: [PATCH 13/17] Add supported python versions badges to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f951910..5669c86 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ [![Current release](https://img.shields.io/github/v/release/dynamist/phabfive.svg)](https://github.com/dynamist/phabfive/releases) [![GitHub issues](https://img.shields.io/github/issues/dynamist/phabfive.svg?maxAge=360)](https://github.com/dynamist/phabfive/issues) [![License](https://img.shields.io/github/license/dynamist/phabfive?color=%23fe0000)](https://github.com/dynamist/phabfive/blob/master/LICENSE) +[![Python2](https://img.shields.io/badge/python2-2.7-blue.svg)](https://github.com/dynamist/phabfive/) +[![Python3](https://img.shields.io/badge/python3-3.6,3.7,3.8-blue.svg)](https://github.com/dynamist/phabfive/) A command line tool to interact with Phabricator. From b262a63125350f9e2aa7f386cd77a390f8975fae Mon Sep 17 00:00:00 2001 From: Grokzen Date: Wed, 8 Jan 2020 18:40:59 +0100 Subject: [PATCH 14/17] Add mkdocs-dev to Makefile. Fixed wrong requirements package for the docs install requirements --- Makefile | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 670de11..322d039 100644 --- a/Makefile +++ b/Makefile @@ -37,3 +37,6 @@ bdist: ## build a wheel distribution install: ## install package python setup.py install + +mkdocs-dev: + mkdocs serve diff --git a/setup.py b/setup.py index bd38835..0290ab5 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ install_requires = ["anyconfig", "appdirs", "phabricator", "pyyaml", "docopt"] tests_require = ["coverage", "flake8", "pytest", "tox", "mock"] -docs_require = ["docs"] +docs_require = ["mkdocs"] download_url = "{0}/tarball/v{1}".format( "https://github.com/dynamist/phabfive", phabfive.__version__ ) From 262e9b245f19d65916fd23fc556c834c0fd93b73 Mon Sep 17 00:00:00 2001 From: Grokzen Date: Wed, 8 Jan 2020 18:45:24 +0100 Subject: [PATCH 15/17] Move the features list from the README file into the docs site. Further text for each command will be added in later commits. --- README.md | 27 ++++----------------------- docs/modules/diffusion.md | 11 +++++++++++ docs/modules/passphrase.md | 6 ++++++ docs/modules/paste.md | 8 ++++++++ docs/modules/user.md | 6 ++++++ mkdocs.yml | 5 +++++ 6 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 docs/modules/diffusion.md create mode 100644 docs/modules/passphrase.md create mode 100644 docs/modules/paste.md create mode 100644 docs/modules/user.md diff --git a/README.md b/README.md index 5669c86..1ce048f 100644 --- a/README.md +++ b/README.md @@ -9,31 +9,10 @@ A command line tool to interact with Phabricator. -The complete documentation for Phabfive can be found at [Read the Docs](https://phabfive.readthedocs.io/en/latest/) +The complete documentation and detailed documentation of all implemented commands for Phabfive can be found at [Read the Docs](https://phabfive.readthedocs.io/en/latest/) -## Features - -A summary of the currently supported actions, as well as planned features: - -- Passphrase - - [X] Get specified secret -- Diffusion - - [X] List repositories names - - [X] Get branches for specified repository - - [X] Get clone URI:s for specified repository - - [X] Add repository - - [X] Edit URI - - [X] Observe repositories: create uri -- Paste - - [X] List pastes - - [X] Get specified paste - - [X] Add paste -- User - - [X] Who am I: information about the logged-in user - - -## Example usage +## Basic example Grab a Phabricator token at https:///settings/panel/apitokens/ @@ -47,6 +26,8 @@ Usage: phabfive passphrase K123 +More detailed examples can be found on the [Read the Docs](https://phabfive.readthedocs.io/en/latest/) website + ## LICENSE diff --git a/docs/modules/diffusion.md b/docs/modules/diffusion.md new file mode 100644 index 0000000..970f0b2 --- /dev/null +++ b/docs/modules/diffusion.md @@ -0,0 +1,11 @@ +# Module Diffusion + + +## Impelmented commands + +- List repositories names +- Get branches for specified repository +- Get clone URI:s for specified repository +- Add repository +- Edit URI +- Observe repositories: create uri diff --git a/docs/modules/passphrase.md b/docs/modules/passphrase.md new file mode 100644 index 0000000..e1daab7 --- /dev/null +++ b/docs/modules/passphrase.md @@ -0,0 +1,6 @@ +# Module Passphrase + + +## Impelmented commands + +- Get specified secret \ No newline at end of file diff --git a/docs/modules/paste.md b/docs/modules/paste.md new file mode 100644 index 0000000..23aa1e6 --- /dev/null +++ b/docs/modules/paste.md @@ -0,0 +1,8 @@ +# Module Paste + + +## Impelmented commands + +- List pastes +- Get specified paste +- Add paste diff --git a/docs/modules/user.md b/docs/modules/user.md new file mode 100644 index 0000000..2e0c06e --- /dev/null +++ b/docs/modules/user.md @@ -0,0 +1,6 @@ +# Module User + + +## Impelmented commands + +- Who am I: information about the logged-in user diff --git a/mkdocs.yml b/mkdocs.yml index 9c6de2f..d62ecb0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -5,6 +5,11 @@ repo_url: https://github.com/dynamist/phabfive nav: - Introduction: 'index.md' - Development: 'development.md' + - Modules: + - Diffusion: 'modules/diffusion.md' + - Passphrase: 'modules/passphrase.md' + - Paste: 'modules/paste.md' + - User: 'modules/user.md' markdown_extensions: - admonition: From 57f668adf5043338ca7b2a8cc7392334265044fb Mon Sep 17 00:00:00 2001 From: Grokzen Date: Wed, 8 Jan 2020 18:46:44 +0100 Subject: [PATCH 16/17] Drop python 3.5 and add python 3.6 as supported python versions --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0290ab5..a3ec111 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ extras_require={"test": tests_require, "docs": docs_require}, packages=["phabfive"], entry_points={"console_scripts": ["phabfive = phabfive.cli:cli_entrypoint"]}, - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", + python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", classifiers=[ # 'Development Status :: 1 - Planning', # "Development Status :: 2 - Pre-Alpha", @@ -56,9 +56,9 @@ "Environment :: Console", "Programming Language :: Python", "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", ], From c48d9a51d412a98cada3fcc433af867e4ed5deb6 Mon Sep 17 00:00:00 2001 From: Grokzen Date: Wed, 8 Jan 2020 18:47:29 +0100 Subject: [PATCH 17/17] Update copyright year to 2020 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ce048f..8c948aa 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,6 @@ More detailed examples can be found on the [Read the Docs](https://phabfive.read ## LICENSE -Copyright (c) 2017-2019 Dynamist AB +Copyright (c) 2017-2020 Dynamist AB See the LICENSE file provided with the source distribution for full details.