Compare commits
4 Commits
python-0.1
...
0.14.0-cli
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b8fd70bdd | ||
|
|
55a467f2df | ||
|
|
0adb5164d7 | ||
|
|
147e0ab567 |
@@ -46,5 +46,7 @@ cd $(git rev-parse --show-toplevel)/test
|
||||
python run_tests.py --host=$YOUR_HOST $YOUR_USERNAME $YOUR_API_KEY
|
||||
```
|
||||
|
||||
## TODO
|
||||
- Move dependencies expressed in `requirements.txt` to `setup.py`
|
||||
## Versioning
|
||||
Once you're satisfied with your changes, it is time to bump the version number in the `setup.py`. A couple of rules:
|
||||
- **Backwards compatibility**: in general all changes shall be backwards compatible. Do not remove any code used from the server public `pl/python` functions or you'll run into problems when deploying.
|
||||
- **Semantic versioning**: we try to stick to [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html)
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
from datetime import date, timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from calendar import monthrange
|
||||
|
||||
def last_day_of_month(year, month):
|
||||
"""last valid day of a month"""
|
||||
return monthrange(year, month)[1]
|
||||
|
||||
def latest_valid_date(year, month, day):
|
||||
"""latest date not later than the day specified"""
|
||||
valid_day = min(day, last_day_of_month(year, month))
|
||||
return date(year, month, valid_day)
|
||||
|
||||
class UserMetricsService:
|
||||
""" Class to manage all the user info """
|
||||
@@ -152,9 +143,9 @@ class UserMetricsService:
|
||||
today = date.today()
|
||||
if end_period_day > today.day:
|
||||
temp_date = today + relativedelta(months=-1)
|
||||
date_from = latest_valid_date(temp_date.year, temp_date.month, end_period_day)
|
||||
date_from = date(temp_date.year, temp_date.month, end_period_day)
|
||||
else:
|
||||
date_from = latest_valid_date(today.year, today.month, end_period_day)
|
||||
date_from = date(today.year, today.month, end_period_day)
|
||||
|
||||
return date_from, today
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from setuptools import setup, find_packages
|
||||
setup(
|
||||
name='cartodb_services',
|
||||
|
||||
version='0.12.4',
|
||||
version='0.12.3',
|
||||
|
||||
description='CartoDB Services API Python Library',
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@ class TestUserService(TestCase):
|
||||
amount=400)
|
||||
assert us.used_quota(self.NOKIA_GEOCODER, date.today()) == 400
|
||||
|
||||
def test_user_quota_for_a_month_shorter_than_end_day(self):
|
||||
us = self.__build_user_service('test_user', end_date=date(2016,1,31))
|
||||
assert us.used_quota(self.NOKIA_GEOCODER, date(2016,2,10)) == 0
|
||||
|
||||
def test_org_used_quota_for_a_day(self):
|
||||
us = self.__build_user_service('test_user', orgname='test_org')
|
||||
increment_service_uses(self.redis_conn, 'test_user',
|
||||
@@ -34,10 +30,6 @@ class TestUserService(TestCase):
|
||||
amount=400)
|
||||
assert us.used_quota(self.NOKIA_GEOCODER, date.today()) == 400
|
||||
|
||||
def test_org_quota_quota_for_a_month_shorter_than_end_day(self):
|
||||
us = self.__build_user_service('test_user', orgname='test_org', end_date=date(2016,1,31))
|
||||
assert us.used_quota(self.NOKIA_GEOCODER, date(2016,2,10)) == 0
|
||||
|
||||
def test_user_not_amount_in_used_quota_for_month_should_be_0(self):
|
||||
us = self.__build_user_service('test_user')
|
||||
assert us.used_quota(self.NOKIA_GEOCODER, date.today()) == 0
|
||||
|
||||
Reference in New Issue
Block a user