Esempio n. 1
0
def premade_app():
    return DustySchema(
        app_schema, {
            'repo': '/tmp/fake-repo',
            'mount': '/repo',
            'image': 'busybox',
            'commands': {
                'always': ['sleep 999999999']
            }
        }, 'fake_app', 'apps')
Esempio n. 2
0
def get_app_dusty_schema(doc, name=None):
    if 'image' not in doc and 'build' not in doc:
        doc['image'] = ''
    if 'repo' in doc and 'mount' not in doc:
        doc['mount'] = '/repo'
    if 'mount' in doc and 'repo' not in doc:
        doc['repo'] = '/repo'
    if 'commands' not in doc:
        doc['commands'] = {'always': ['sleep 1']}
    return DustySchema(app_schema, doc, name, 'apps')
Esempio n. 3
0
def apply_required_keys(specs):
    for spec_type in ['apps', 'bundles', 'libs', 'services']:
        if spec_type not in specs.keys():
            specs[spec_type] = {}
    for k, v in specs['apps'].iteritems():
        specs['apps'][k] = get_app_dusty_schema(v, k)
    for k, v in specs['libs'].iteritems():
        specs['libs'][k] = get_lib_dusty_schema(v, k)
    for k, v in specs['services'].iteritems():
        specs['services'][k] = DustySchema(None, v, k, 'services')
    return specs
Esempio n. 4
0
 def test_get_dusty_status_active_1(self, fake_get_services, fake_get_libs,
                                    fake_get_apps, fake_get_specs,
                                    fake_get_dusty_containers,
                                    fake_pretty_table,
                                    fake_get_docker_client,
                                    fake_vm_is_running):
     fake_get_services.return_value = set(['ser1', 'ser2', 'ser3'])
     fake_get_libs.return_value = set(['lib1'])
     fake_get_apps.return_value = set(['app1', 'app2'])
     fake_table = Mock()
     fake_pretty_table.return_value = fake_table
     fake_get_dusty_containers.return_value = ['some_container']
     fake_get_specs.return_value = {
         'apps': {
             'app1': get_app_dusty_schema({}, 'app1'),
             'app2': get_app_dusty_schema({}, 'app2')
         },
         'libs': {
             'lib1': get_lib_dusty_schema({}, 'lib1')
         },
         'services': {
             'ser1': DustySchema(None, {}, 'ser1', 'services'),
             'ser2': DustySchema(None, {}, 'ser2', 'services'),
             'ser3': DustySchema(None, {}, 'ser3', 'services')
         },
         'bundles': get_lib_dusty_schema({}, 'bundle')
     }
     fake_get_docker_client.return_value = None
     fake_vm_is_running.return_value = True
     get_dusty_status()
     call_args_list = fake_table.add_row.call_args_list
     self.assertTrue(call(['app1', 'app', 'X']) in call_args_list)
     self.assertTrue(call(['app2', 'app', 'X']) in call_args_list)
     self.assertTrue(call(['lib1', 'lib', '']) in call_args_list)
     self.assertTrue(call(['ser1', 'service', 'X']) in call_args_list)
     self.assertTrue(call(['ser2', 'service', 'X']) in call_args_list)
     self.assertTrue(call(['ser3', 'service', 'X']) in call_args_list)
     self.assertTrue(
         call(['dustyInternalNginx', '', 'X']) in call_args_list)
     self.assertEquals(len(call_args_list), 7)
 def test_values(self):
     doc = {'street': 'dogstoon',
            'house_number': 1}
     dusty_schema = DustySchema(self.base_schema, doc)
     self.assertEquals(set(['dogstoon', 1]), set(dusty_schema.values()))
Esempio n. 6
0
def get_lib_dusty_schema(doc, name=None):
    if 'mount' not in doc:
        doc['mount'] = ''
    if 'repo' not in doc:
        doc['repo'] = ''
    return DustySchema(lib_schema, doc, name, 'libs')
Esempio n. 7
0
def get_bundle_dusty_schema(doc):
    return DustySchema(bundle_schema, doc)
Esempio n. 8
0
 def test_in_2(self):
     doc = {'first_name': 'dusty', 'address': {'street': 'dogstoon'}}
     dusty_schema = DustySchema(self.bigger_schema, doc)
     self.assertFalse('first_names' in dusty_schema)
Esempio n. 9
0
 def test_values(self):
     doc = {'street': 'dogstoon', 'house_number': 1}
     dusty_schema = DustySchema(self.base_schema, doc)
     self.assertEquals(set(['dogstoon', 1]), set(dusty_schema.values()))
Esempio n. 10
0
 def test_setting_defaults_more_complicated_2(self):
     doc = {'first_name': 'dusty', 'address': {'street': 'dogstoon'}}
     dusty_schema = DustySchema(self.bigger_schema, doc)
     self.assertEquals(dusty_schema['address']['street'], 'dogstoon')
     self.assertEquals(dusty_schema['address']['house_number'], 1)
Esempio n. 11
0
 def test_setting_defaults_more_complicated_1(self):
     doc = {'first_name': 'dusty'}
     dusty_schema = DustySchema(self.bigger_schema, doc)
     self.assertEquals(dusty_schema['first_name'], 'dusty')
     self.assertEquals(dusty_schema['last_name'], 'johnson')
     self.assertEquals(dusty_schema['address'], {'house_number': 1})
Esempio n. 12
0
 def test_setting_defaults(self):
     doc = {'street': 'dogstoon'}
     dusty_schema = DustySchema(self.base_schema, doc)
     self.assertEquals(dusty_schema['street'], 'dogstoon')
     self.assertEquals(dusty_schema['house_number'], 1)
Esempio n. 13
0
 def test_valid_doc(self):
     doc = {'street': 'dogstoon', 'house_number': 1}
     dusty_schema = DustySchema(self.base_schema, doc)
     self.assertEquals(dusty_schema['street'], 'dogstoon')
     self.assertEquals(dusty_schema['house_number'], 1)
Esempio n. 14
0
 def test_init_invalid_doc(self):
     doc = {'street': 'dogstoon', 'house_number': '1'}
     with self.assertRaises(ValidationException):
         DustySchema(self.base_schema, doc)