Skip to content

Commit

Permalink
POP-2466 rename src directory to facilitate library usage & improve d…
Browse files Browse the repository at this point in the history
…ocumentation
  • Loading branch information
wogsland committed Jan 14, 2020
1 parent 05d0055 commit 02348bb
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/)

<a href="https://github.com/dynata/python-cmixapi-client/actions"><img alt="GitHub Actions status" src="https://github.com/dynata/python-cmixapi-client/workflows/python-tests/badge.svg"></a>

A Python client library for the [Dynata Cmix API](https://wiki2.criticalmix.net/display/CA/Getting+started).
Expand Down Expand Up @@ -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

Expand Down
26 changes: 13 additions & 13 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -72,15 +72,15 @@ 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 = {
'response': 1,
'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
Expand All @@ -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
Expand All @@ -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'}
Expand All @@ -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 = {}
Expand All @@ -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'}
Expand All @@ -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 = {}
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 02348bb

Please sign in to comment.