Пример #1
0
def test_required_bare_fields():
    settings = Settings()

    assert settings["CLOUD"] == "bare"

    with pytest.raises(AssertionError):
        settings.validate_fields()

    settings["NODES"] = []
    settings["USERNAME"] = "******"
    settings["KEYPAIR"] = "~/.ssh/something"
    settings.validate_fields()
Пример #2
0
 def read_settings(self):
     """
     Read the "dsbfile" file
     Populates `self.settings`
     """
     logger.debug('Reading settings from: %s', self.settings_path)
     self.settings = Settings.from_dsbfile(self.settings_path)
Пример #3
0
 def read_settings(self):
     """
     Read the "dsbfile" file
     Populates `self.settings`
     """
     logger.debug('Reading settings from: %s', self.settings_path)
     self.settings = Settings.from_dsbfile(self.settings_path)
Пример #4
0
def test_required_aws_fields():
    settings = Settings()
    settings["CLOUD"] = "aws"

    with pytest.raises(AssertionError):
        settings.validate_fields()

    settings["AWS_KEY"] = "1"
    settings["AWS_SECRET"] = "1"
    settings["AWS_KEYNAME"] = "1"
    settings["AWS_REGION"] = "1"
    settings["AWS_SECURITY_GROUPS"] = "1"
    settings["AWS_IMAGE"] = "1"
    settings["AWS_SIZE"] = "1"
    settings["USERNAME"] = "******"
    settings["KEYPAIR"] = "~/.ssh/something"
    settings["NUMBER_NODES"] = 3
    settings.validate_fields()
Пример #5
0
 def read_settings(self):
     """
     Read the settings "dsbfile" file
     Populates `self.settings`
     """
     logger.debug('Reading settings from: %s' % self.settings_path)
     if os.path.exists(self.settings_path):
         self.settings = Settings.from_dsbfile(self.settings_path)
     else:
         pass    # TODO: do something?
Пример #6
0
def test_required_bare_fields():
    settings = Settings()

    assert settings['CLOUD'] == 'bare'

    with pytest.raises(AssertionError):
        settings.validate_fields()

    settings['NODES'] = []
    settings['USERNAME'] = '******'
    settings['KEYPAIR'] = '~/.ssh/something'
    settings.validate_fields()
Пример #7
0
def test_required_aws_fields():
    settings = Settings()
    settings['CLOUD'] = 'aws'

    with pytest.raises(AssertionError):
        settings.validate_fields()

    settings['AWS_KEY'] = '1'
    settings['AWS_SECRET'] = '1'
    settings['AWS_KEYNAME'] = '1'
    settings['AWS_REGION'] = '1'
    settings['AWS_SECURITY_GROUPS'] = '1'
    settings['AWS_IMAGE'] = '1'
    settings['AWS_SIZE'] = '1'
    settings['USERNAME'] = '******'
    settings['KEYPAIR'] = '~/.ssh/something'
    settings['NUMBER_NODES'] = 3
    settings.validate_fields()
Пример #8
0
import pytest

from datasciencebox.core.settings import Settings
from datasciencebox.core.cloud.instance import Instance, BareInstance, AWSInstance, GCPInstance

default_username = '******'
default_keypair = 'default_keypair'

settings = Settings()
settings['USERNAME'] = default_username
settings['KEYPAIR'] = default_keypair


def test_new_bare():
    instance = Instance.new(settings=settings)
    assert isinstance(instance, BareInstance)

    instance = Instance.new(settings=settings, uid='myid')
    assert instance.uid == 'myid'
    assert instance.port == 22
    assert instance.username == default_username
    assert instance.keypair == default_keypair

    instance = Instance.new(settings=settings,
                            uid='myid',
                            ip='1.1.1.1',
                            port=33,
                            username='******',
                            keypair='mykey')
    assert instance.ip == '1.1.1.1'
    assert instance.port == 33