Repository: popylar/popylar

Issue:
opt_out fails with TypeError
Nice simple package, just what I need, but:
Calling popylar.opt_out() leads to an error:

```
>>> import popylar
>>> r = popylar.track_event('UA-86484662-2', 'test', 'test_track_event')
>>> print r.status_code
200
>>> popylar.opt_out()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pazcal/Library/Python/2.7/lib/python/site-packages/popylar/popylar.py", line 29, in opt_out
    parser['user']['track'] = False
  File "/Users/pazcal/Library/Python/2.7/lib/python/site-packages/backports/configparser/__init__.py", line 1283, in __setitem__
    _, key, value = self._parser._validate_value_types(option=key, value=value)
  File "/Users/pazcal/Library/Python/2.7/lib/python/site-packages/backports/configparser/__init__.py", line 1221, in _validate_value_types
    raise TypeError("option values must be strings")
TypeError: option values must be strings
>>> 
```
I can fix this by changing line 29 in popylar.py from:
```
   parser['user']['track'] = False
```
to:
```
   parser['user']['track'] = "False"
```
I don't mind cloning and doing this via a pull request but seems so minor a fix it's not really worth it.
Charlie

Discussion:

Patch:
diff --git a/.travis.yml b/.travis.yml
index 737b58e..c18718d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,15 +11,19 @@ deploy:
 env:
   global:
   - PIP_DEPS="coveralls pytest-cov flake8"
+
 python:
 - '2.7'
-- '3.5'
+- '3.6'
+
 install:
-- pip install $PIP_DEPS
-- pip install -r requirements.txt
-- python setup.py install
+- travis_retry pip install $PIP_DEPS
+- travis_retry pip install -r requirements.txt
+- travis_retry pip install -e .
+
 script:
 - flake8 --ignore N802,N806 `find . -name \*.py | grep -v setup.py | grep -v version.py | grep -v __init__.py | grep -v /docs/`
 - py.test --pyargs popylar --cov-report term-missing --cov=popylar
+
 after_success:
 - coveralls
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0bd6e3a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,2 @@
+test:
+	py.test --pyargs popylar --cov-report term-missing --cov=popylar
diff --git a/popylar/popylar.py b/popylar/popylar.py
index 39c0c9a..aa5bf8f 100644
--- a/popylar/popylar.py
+++ b/popylar/popylar.py
@@ -26,7 +26,7 @@ def opt_out():
     To opt-in again, run ``popylar.reset_uid()``
     """
     parser = get_or_create_config()
-    parser['user']['track'] = False
+    parser['user']['track'] = "False"
     with open(popylar_path, 'w') as fhandle:
         parser.write(fhandle)
 


Test patch:
diff --git a/popylar/tests/test_popylar.py b/popylar/tests/test_popylar.py
index e690377..229f0db 100644
--- a/popylar/tests/test_popylar.py
+++ b/popylar/tests/test_popylar.py
@@ -18,3 +18,12 @@ def test_track_event_with_version():
                             'test_track_event_with_version',
                             software_version=VERSION)
     assert r.status_code == 200, "response is not OK"
+
+
+def test_opt():
+    popylar.opt_out()
+    parser = popylar.get_or_create_config()
+    assert parser['user']['track'] == "False"
+    popylar.opt_in()
+    parser = popylar.get_or_create_config()
+    assert parser['user']['track'] == "True"