Skip to content

Commit

Permalink
Merge branch 'release/0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Dennis committed Jul 5, 2018
2 parents 6ad3b6b + 0708dca commit 24877e3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
13 changes: 9 additions & 4 deletions ship_it/manifest.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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'):
Expand All @@ -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):
Expand Down
22 changes: 18 additions & 4 deletions tests/test_manifest.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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')]),
Expand All @@ -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
({}, [], []),
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 24877e3

Please sign in to comment.