diff --git a/.travis.yml b/.travis.yml index 85476d0..87025f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ matrix: include: - python: 2.7 env: TOX_ENV=py27 - - python: 3.5 - env: TOX_ENV=py35 + - python: 3.6 + env: TOX_ENV=py36 install: - pip install tox - pip install python-coveralls diff --git a/setup.py b/setup.py index 707722b..da3f812 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='ship_it', - version='0.8.0', + version='0.9.0', install_requires=['invoke', 'PyYaml', 'six', 'virtualenv', 'click'], packages=['ship_it'], url='https://github.com/robdennis/ship_it', diff --git a/ship_it/manifest.py b/ship_it/manifest.py index 3ca3fcf..84d1997 100644 --- a/ship_it/manifest.py +++ b/ship_it/manifest.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import pipes -import re from os import path +import pipes +import six +import time import yaml @@ -91,8 +92,8 @@ def get_single_flags(self): flags = { flag.replace('_', '-'): value for flag, value in self.contents.items() - if flag in ('name', 'version', 'iteration', 'before_install', - 'after_install', 'description') + if flag in ('name', 'version', 'iteration', 'epoch', + 'before_install', 'after_install', 'description') } for script_type in ('before-install', 'after-install'): @@ -101,6 +102,10 @@ def get_single_flags(self): flags[script_type] = path.normpath(path.join(self.manifest_dir, script_path)) + # Allow users to use 'timestamp' as a value + if isinstance(flags.get('epoch'), six.string_types) and flags.get('epoch').lower() == 'timestamp': + flags['epoch'] = str(int(time.time())) + return list(flags.items()) def get_bool_value(self, name): diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 7cc5948..143e708 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -1,17 +1,17 @@ # coding=utf-8 from __future__ import unicode_literals -import mock import os -import pytest +import time try: from StringIO import StringIO except ImportError: from io import StringIO -import ship_it -from ship_it.manifest import Manifest, get_manifest_from_path +import mock +import pytest import yaml +from ship_it.manifest import Manifest, get_manifest_from_path @pytest.fixture @@ -196,6 +196,7 @@ class TestGettingArgsAndFlags(object): (dict(version='test'), [('version', 'test')]), (dict(iteration='test'), [('iteration', 'test')]), (dict(description='test'), [('description', 'test')]), + (dict(epoch=1234), [('epoch', 1234)]), # We do do some normalization on some of them (dict(before_install='test'), [('before-install', '/test_dir/test')]), (dict(after_install='test'), [('after-install', '/test_dir/test')]), @@ -210,6 +211,19 @@ def test_single_flags(self, manifest, test_man, expected): manifest.contents = test_man assert sorted(manifest.get_single_flags()) == sorted(expected) + @pytest.mark.parametrize('epoch_value', [ + 'TIMESTAMP', + 'timestamp', + 'TimeStamp', + ]) + def test_epoch_flag(self, manifest, epoch_value): + """ + Test generating a timestamp for the epoch value. + """ + manifest.contents = {'epoch': epoch_value} + curtime = int(time.time()) + assert int(manifest.get_single_flags()[0][1]) in range(curtime, curtime + 10) + @pytest.mark.parametrize('test_cfg, expected_args, expected_flags', [ # we don't have to return config files ({}, [], []), diff --git a/tox.ini b/tox.ini index 530d6ee..0dab530 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ # content of: tox.ini, put in same dir as setup.py [tox] -envlist = py27,py35 +envlist = py27,py36 [testenv] deps=pytest mock