Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: Zero pad months in table names
Browse files Browse the repository at this point in the history
closes #653
  • Loading branch information
jrconlin committed Nov 4, 2016
1 parent 7665742 commit 5ca85e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autopush/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def make_rotating_tablename(prefix, delta=0, date=None):
month delta."""
if not date:
date = get_month(delta=delta)
return "{}_{}_{}".format(prefix, date.year, date.month)
return "{}_{:04d}_{:02d}".format(prefix, date.year, date.month)


def create_rotating_message_table(prefix="message", read_throughput=5,
Expand Down
6 changes: 6 additions & 0 deletions autopush/tests/test_db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
import uuid
from datetime import datetime

from autopush.websocket import ms_time
from boto.dynamodb2.exceptions import (
Expand Down Expand Up @@ -110,6 +111,11 @@ def test_get_month(self):
next_month = 1 if this_month == 12 else this_month + 1
eq_(next_month, month1.month)

def test_zero_fill_month(self):
from autopush.db import make_rotating_tablename
eq_('test_2016_03',
make_rotating_tablename('test', date=datetime(2016, 3, 15)))

def test_hasher(self):
import autopush.db as db
db.key_hash = "SuperSikkret"
Expand Down

0 comments on commit 5ca85e0

Please sign in to comment.