mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-27 23:09:28 +01:00
Merge pull request #92 from efiop/master
Misc changes for build and testing
This commit is contained in:
@@ -7,5 +7,11 @@ python:
|
||||
install:
|
||||
- pip install --upgrade pip
|
||||
- pip install -r requirements.txt
|
||||
- pip install -r test-requirements.txt
|
||||
- git config --global user.email "[email protected]"
|
||||
- git config --global user.name "DVC Tester"
|
||||
- mkdir -p ~/.aws && printf "[default]\naws_access_key_id = ABCDEFG\naws_secret_access_key = 123456789" > ~/.aws/credentials
|
||||
script:
|
||||
- ./unittests.sh
|
||||
after_sucess:
|
||||
- CODECLIMATE_REPO_TOKEN=b27257bacc4812c8e6d37285ba34559804e4a207bf6932723a1c9966e5807670 codeclimate-test-reporter
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ install_dependencies()
|
||||
elif command_exists yum; then
|
||||
sudo yum install ruby-devel gcc make rpm-build
|
||||
elif command_exists apt-get; then
|
||||
sudo apt-get install ruby ruby-dev rubygems build-essential
|
||||
sudo apt-get install ruby ruby-dev rubygems build-essential rpm
|
||||
else
|
||||
echo "Unable to install fpm dependencies" && exit 1
|
||||
fi
|
||||
|
||||
@@ -13,6 +13,7 @@ from dvc.exceptions import DvcException
|
||||
from dvc.runtime import Runtime
|
||||
from dvc.system import System
|
||||
from dvc.config import ConfigError
|
||||
from dvc.settings import Settings
|
||||
|
||||
class DataCloudError(DvcException):
|
||||
def __init__(self, msg):
|
||||
@@ -333,6 +334,8 @@ class DataCloud(object):
|
||||
}
|
||||
|
||||
def __init__(self, settings):
|
||||
assert isinstance(settings, Settings)
|
||||
|
||||
#To handle ConfigI case
|
||||
if not hasattr(settings.config, '_config'):
|
||||
self._cloud = DataCloudBase(None, None, None)
|
||||
@@ -345,6 +348,9 @@ class DataCloud(object):
|
||||
if self.typ not in self.CLOUD_MAP.keys():
|
||||
raise ConfigError('Wrong cloud type %s specified' % self.typ)
|
||||
|
||||
if self.typ not in self._config.keys():
|
||||
raise ConfigError('Can\'t find cloud section \'[%s]\' in config' % self.typ)
|
||||
|
||||
self._cloud = self.CLOUD_MAP[self.typ](self._settings, self._config, self._config[self.typ])
|
||||
|
||||
self.sanity_check()
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
coverage
|
||||
+30
-16
@@ -1,16 +1,28 @@
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
import StringIO
|
||||
import traceback
|
||||
from unittest import TestCase
|
||||
import mock
|
||||
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
# Python 3
|
||||
from io import StringIO
|
||||
|
||||
try:
|
||||
import __builtin__
|
||||
builtin_module_name = '__builtin__'
|
||||
except ImportError:
|
||||
# Python 3
|
||||
builtin_module_name = 'builtins'
|
||||
|
||||
from dvc.path.path import Path
|
||||
from dvc.system import System
|
||||
from dvc.config import Config
|
||||
from dvc.command.data_cloud import DataCloud
|
||||
from dvc.data_cloud import DataCloud
|
||||
from dvc.settings import Settings
|
||||
|
||||
class TestConfigTest(TestCase):
|
||||
def setUp(self):
|
||||
@@ -32,10 +44,10 @@ class TestConfigTest(TestCase):
|
||||
"[GCP]",
|
||||
"StoragePath = googlesb/google_storage_path"
|
||||
)
|
||||
s = StringIO.StringIO('\n'.join(c))
|
||||
s = StringIO('\n'.join(c))
|
||||
conf = Config(s, conf_pseudo_file = s)
|
||||
cloud = DataCloud(conf)
|
||||
self.assertEqual(cloud.typ, 'aws')
|
||||
cloud = DataCloud(Settings(None, None, conf))
|
||||
self.assertEqual(cloud.typ, 'AWS')
|
||||
self.assertEqual(cloud._cloud.storage_bucket, 'globalsb')
|
||||
self.assertEqual(cloud._cloud.storage_prefix, 'global_storage_path')
|
||||
|
||||
@@ -51,10 +63,10 @@ class TestConfigTest(TestCase):
|
||||
"[GCP]",
|
||||
"StoragePath = googlesb/google_storage_path"
|
||||
)
|
||||
s = StringIO.StringIO('\n'.join(c))
|
||||
s = StringIO('\n'.join(c))
|
||||
conf = Config(s, conf_pseudo_file=s)
|
||||
cloud = DataCloud(conf)
|
||||
self.assertEqual(cloud.typ, 'aws')
|
||||
cloud = DataCloud(Settings(None, None, conf))
|
||||
self.assertEqual(cloud.typ, 'AWS')
|
||||
self.assertEqual(cloud._cloud.storage_bucket, 'awssb')
|
||||
self.assertEqual(cloud._cloud.storage_prefix, 'aws_storage_path')
|
||||
|
||||
@@ -65,13 +77,13 @@ class TestConfigTest(TestCase):
|
||||
creds0 = ("[default]",
|
||||
"aws_access_key_id = default_access_id",
|
||||
"aws_secret_access_key = default_sekret")
|
||||
return io.BytesIO('\n'.join(creds0))
|
||||
return StringIO('\n'.join(creds0))
|
||||
|
||||
creds1 = ("[default]",
|
||||
"aws_access_key_id = override_access_id",
|
||||
"aws_secret_access_key = override_sekret")
|
||||
|
||||
return io.BytesIO('\n'.join(creds1))
|
||||
return StringIO('\n'.join(creds1))
|
||||
|
||||
def aws_credentials_default_test(self):
|
||||
""" in absence of [AWS] -> CredentialPath, aws creds should be read from ~/.aws/credentials """
|
||||
@@ -87,12 +99,13 @@ class TestConfigTest(TestCase):
|
||||
"StoragePath = awssb/aws_storage_path",
|
||||
"CredentialPath =",
|
||||
)
|
||||
s = StringIO.StringIO('\n'.join(c))
|
||||
s = StringIO('\n'.join(c))
|
||||
|
||||
patcher = mock.patch(builtin_module_name + '.open', side_effect=self.mocked_open_aws_default_credentials)
|
||||
|
||||
patcher = mock.patch('__builtin__.open', side_effect=self.mocked_open_aws_default_credentials)
|
||||
patcher.start()
|
||||
conf = Config(s, conf_pseudo_file=s)
|
||||
cloud = DataCloud(conf)
|
||||
cloud = DataCloud(Settings(None, None, conf))
|
||||
aws_creds = cloud._cloud.get_aws_credentials()
|
||||
patcher.stop()
|
||||
|
||||
@@ -118,12 +131,13 @@ class TestConfigTest(TestCase):
|
||||
"StoragePath = awssb/aws_storage_path",
|
||||
"CredentialPath = some_credential_path",
|
||||
)
|
||||
s = StringIO.StringIO('\n'.join(c))
|
||||
s = StringIO('\n'.join(c))
|
||||
|
||||
patcher = mock.patch(builtin_module_name + '.open', side_effect=self.mocked_open_aws_default_credentials)
|
||||
|
||||
patcher = mock.patch('__builtin__.open', side_effect=self.mocked_open_aws_default_credentials)
|
||||
patcher.start()
|
||||
conf = Config(s, conf_pseudo_file=s)
|
||||
cloud = DataCloud(conf)
|
||||
cloud = DataCloud(Settings(None, None, conf))
|
||||
aws_creds = cloud._cloud.get_aws_credentials()
|
||||
patcher.stop()
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
nosetests --cover-inclusive --cover-erase --cover-package=dvc --with-coverage
|
||||
|
||||
if [ "$1" = "report" ]; then
|
||||
|
||||
Reference in New Issue
Block a user