Skip to content

Commit

Permalink
Add test for utils.timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc committed Feb 28, 2016
1 parent cf6eace commit 969b1db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions dbmigrator/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
# See LICENCE.txt for details.
# ###

import datetime
import os.path
import unittest
try:
from unittest import mock
except ImportError:
import mock

import psycopg2

Expand Down Expand Up @@ -203,3 +208,12 @@ def test_rollback_migration(self):
stdout, 'Rolling back migration {} {}\n'.format(version, name))

self.assertIn((version, name), after_migrations)

def test_timestamp(self):
from ..utils import timestamp

now = datetime.datetime(2016, 2, 28, 22, 51, 56)

with mock.patch('datetime.datetime') as mock_datetime:
mock_datetime.utcnow.return_value = now
self.assertEqual(timestamp(), '20160228225156')
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
tests_require = [
]

if sys.version_info.major < 3:
tests_require.append('mock')

LONG_DESC = '\n\n~~~~\n\n'.join([open('README.rst').read(),
open('CHANGELOG.rst').read()])

Expand Down

0 comments on commit 969b1db

Please sign in to comment.