From 02348bb5e46aa2533c4c11895f08b0c5f1614576 Mon Sep 17 00:00:00 2001 From: Bradley Wogsland Date: Tue, 14 Jan 2020 14:02:55 -0600 Subject: [PATCH] POP-2466 rename src directory to facilitate library usage & improve documentation --- CONTRIBUTING.md | 13 +++++++++++++ {src => CmixAPIClient}/__init__.py | 0 {src => CmixAPIClient}/api.py | 0 {src => CmixAPIClient}/error.py | 0 README.md | 4 +++- tests/test_api.py | 26 +++++++++++++------------- 6 files changed, 29 insertions(+), 14 deletions(-) rename {src => CmixAPIClient}/__init__.py (100%) rename {src => CmixAPIClient}/api.py (100%) rename {src => CmixAPIClient}/error.py (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index deab5e3..e4bca88 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,4 +46,17 @@ to run the tests for this project. Please use the [GitHub Issues](https://github.com/dynata/python-cmixapi-client/issues/new) to file an issue. +### Releasing + +The release can be done completely on the command line: + + git tag -a 0.1.0 -m "Initial release with minimal functionality used by PopResearch" + git push origin 0.1.0 + python3 -m pip install --user --upgrade setuptools wheel + python3 setup.py sdist bdist_wheel + python3 -m pip install --user --upgrade twine + python3 -m twine upload dist/* + +but it's also a good idea to attach the `.whl` and `.tar.gz` files to the release in GitHub. + Thats it. diff --git a/src/__init__.py b/CmixAPIClient/__init__.py similarity index 100% rename from src/__init__.py rename to CmixAPIClient/__init__.py diff --git a/src/api.py b/CmixAPIClient/api.py similarity index 100% rename from src/api.py rename to CmixAPIClient/api.py diff --git a/src/error.py b/CmixAPIClient/error.py similarity index 100% rename from src/error.py rename to CmixAPIClient/error.py diff --git a/README.md b/README.md index 0071eec..5d9ace4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # python-cmixapi-client +[![PyPI version](https://badge.fury.io/py/python-cmixapi-client.svg)](https://pypi.org/project/python-cmixapi-client/) + GitHub Actions status A Python client library for the [Dynata Cmix API](https://wiki2.criticalmix.net/display/CA/Getting+started). @@ -38,7 +40,7 @@ A Python client library for the [Dynata Cmix API](https://wiki2.criticalmix.net/ ## Contributing -Information on [contributing](CONTRIBUTING.md). +Information on [contributing](https://github.com/dynata/python-cmixapi-client/blob/dev/CONTRIBUTING.md) to this python library. ## Testing diff --git a/tests/test_api.py b/tests/test_api.py index 0fde15f..b5ed2e1 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -4,8 +4,8 @@ import mock from unittest import TestCase -from src.api import CmixAPI, CMIX_SERVICES -from src.error import CmixError +from CmixAPIClient.api import CmixAPI, CMIX_SERVICES +from CmixAPIClient.error import CmixError def default_cmix_api(): @@ -72,7 +72,7 @@ def test_create_export_archive(self): self.assertEqual(response['response'], 1) def test_create_export_archive_errors_handled(self): - with mock.patch('src.api.requests.post') as mock_post: + with mock.patch('CmixAPIClient.api.requests.post') as mock_post: mock_post_response = mock.Mock() mock_post_response.status_code = 200 mock_post_response.json.return_value = { @@ -80,7 +80,7 @@ def test_create_export_archive_errors_handled(self): 'error': 'Oops!', } mock_post.return_value = mock_post_response - with mock.patch('src.api.requests.get') as mock_get: + with mock.patch('CmixAPIClient.api.requests.get') as mock_get: # Check CmixError is raised if POST response JSON includes an error. mock_response = mock.Mock() mock_response.status_code = 200 @@ -95,7 +95,7 @@ def test_create_export_archive_errors_handled(self): # Remove error from POST response. mock_post_response.json.return_value = {'response': 1} - with mock.patch('src.api.requests.get') as mock_get: + with mock.patch('CmixAPIClient.api.requests.get') as mock_get: # Check CmixError is raised on GET 500 response. (layout response) mock_response = mock.Mock() mock_response.status_code = 500 @@ -119,7 +119,7 @@ def test_create_export_archive_errors_handled(self): def test_get_survey_status(self): self.cmix_api._authentication_headers = {'Authentication': 'Bearer test'} - with mock.patch('src.api.requests') as mock_request: + with mock.patch('CmixAPIClient.api.requests') as mock_request: mock_get = mock.Mock() mock_get.status_code = 200 mock_get.json.return_value = {'status': 'LIVE'} @@ -134,7 +134,7 @@ def test_get_survey_status(self): def test_get_survey_status_error_handled(self): self.cmix_api._authentication_headers = {'Authentication': 'Bearer test'} - with mock.patch('src.api.requests') as mock_request: + with mock.patch('CmixAPIClient.api.requests') as mock_request: mock_get = mock.Mock() mock_get.status_code = 200 mock_get.json.return_value = {} @@ -148,7 +148,7 @@ def test_get_survey_test_url(self): correct_test_link = '{}/#/?cmixSvy={}&cmixTest={}'.format( CMIX_SERVICES['test']['BASE_URL'], self.survey_id, 'test') - with mock.patch('src.api.requests') as mock_request: + with mock.patch('CmixAPIClient.api.requests') as mock_request: mock_get = mock.Mock() mock_get.status_code = 200 mock_get.json.return_value = {'testToken': 'test'} @@ -158,7 +158,7 @@ def test_get_survey_test_url(self): def test_get_survey_test_url_no_token_handled(self): self.cmix_api._authentication_headers = {'Authentication': 'Bearer test'} - with mock.patch('src.api.requests') as mock_request: + with mock.patch('CmixAPIClient.api.requests') as mock_request: mock_get = mock.Mock() mock_get.status_code = 200 mock_get.json.return_value = {} @@ -168,7 +168,7 @@ def test_get_survey_test_url_no_token_handled(self): self.cmix_api.get_survey_test_url(self.survey_id) def test_get_survey_completes(self): - with mock.patch('src.api.requests') as mock_request: + with mock.patch('CmixAPIClient.api.requests') as mock_request: mock_post = mock.Mock() mock_post.status_code = 200 mock_post.json.return_value = { @@ -184,7 +184,7 @@ def test_get_survey_completes(self): self.assertEqual(self.cmix_api.get_survey_completes(self.survey_id), mock_respondents) def test_get_surveys(self): - with mock.patch('src.api.requests') as mock_request: + with mock.patch('CmixAPIClient.api.requests') as mock_request: mock_post = mock.Mock() mock_post.status_code = 200 mock_post.json.return_value = { @@ -208,7 +208,7 @@ def test_get_surveys(self): mock_request.get.assert_any_call(expected_url_with_params, headers=self.cmix_api._authentication_headers) def test_fetch_banner_filter(self): - with mock.patch('src.api.requests') as mock_request: + with mock.patch('CmixAPIClient.api.requests') as mock_request: mock_post = mock.Mock() mock_post.status_code = 200 mock_post.json.return_value = { @@ -245,7 +245,7 @@ def test_get_archive_status(self): survey_id = 1337 archive_id = 12 layout_id = 1 - with mock.patch('src.api.requests.get') as mock_request: + with mock.patch('CmixAPIClient.api.requests.get') as mock_request: mock_response = mock.Mock() mock_response.status_code = 200 mock_response.json.return_value = {