Merge pull request #8 from ypid/fixed-source-split-bug

Use /\s+/ to split source_directories to handle 1+ spaces.
This commit is contained in:
Dan Helfman 2016-02-13 10:29:31 -08:00
commit 31482ee559
3 changed files with 22 additions and 2 deletions

4
NEWS
View file

@ -1,3 +1,7 @@
0.1.8-dev
* Fixed handling of repeated spaces in source_directories which resulted in backup up everything.
0.1.7
* #11: Fixed parsing of punctuation in configuration file.

View file

@ -1,5 +1,6 @@
from datetime import datetime
import os
import re
import platform
import subprocess
@ -63,7 +64,7 @@ def create_archive(
list of source directories, a local or remote repository path, and a command to run, create an
attic archive.
'''
sources = tuple(source_directories.split(' '))
sources = tuple(re.split('\s+', source_directories))
exclude_flags = ('--exclude-from', excludes_filename) if excludes_filename else ()
compression = storage_config.get('compression', None)
compression_flags = ('--compression', compression) if compression else ()

View file

@ -71,6 +71,21 @@ def test_create_archive_should_call_attic_with_parameters():
)
def test_create_archive_with_two_spaces_in_source_directories():
insert_subprocess_mock(CREATE_COMMAND)
insert_platform_mock()
insert_datetime_mock()
module.create_archive(
excludes_filename='excludes',
verbosity=None,
storage_config={},
source_directories='foo bar',
repository='repo',
command='attic',
)
def test_create_archive_with_none_excludes_filename_should_call_attic_without_excludes():
insert_subprocess_mock(CREATE_COMMAND_WITHOUT_EXCLUDES)
insert_platform_mock()