def test_invalid_creds(self): data = json.loads(self.data) data['CL-params']['--cloud'] = 'foo.json clopper-storage' config = "./test-config.json" with open(config, 'w') as conf: conf.write(json.dumps(data)) with self.assertRaises(IOError): cm.parse_json(config)
def test_invalid_b_flag(self): data = json.loads(self.data) data['CL-params']['-b'] = 'foo' config = "./test-config.json" with open(config, 'w') as conf: conf.write(json.dumps(data)) with self.assertRaises(ValueError): cm.parse_json(config)
def test_invalid_project(self): data = json.loads(self.data) data['project'] = 'foo' config = "./test-config.json" with open(config, 'w') as conf: conf.write(json.dumps(data)) with self.assertRaises(IOError): cm.parse_json(config)
def test_invalid_distribution(self): data = json.loads(self.data) data['distribution'] = 'foo' config = "./test-config.json" with open(config, 'w') as conf: conf.write(json.dumps(data)) with self.assertRaises(ValueError): cm.parse_json(config)
def test_no_ip_list(self): data = json.loads(self.data) del data['ip-list'] config = "./test-config.json" with open(config, 'w') as conf: conf.write(json.dumps(data)) with self.assertRaises(ValueError): cm.parse_json(config)
def test_parse_json(self): data = json.loads(self.data) config = "./test-config.json" with open(config, 'w') as conf: conf.write(json.dumps(data)) test_data = cm.parse_json(config) self.assertEqual(data, test_data)
def test_username_set(self): data = json.loads(self.data) config = "./test-config.json" with open(config, 'w') as conf: conf.write(json.dumps(data)) test_data = cm.parse_json(config) self.assertNotEqual(data, test_data) self.assertIn('username', test_data) self.assertEquals(test_data['username'], 'selin')
def test_cloud_splitted(self): data = json.loads(self.data) config = "./test-config.json" with open(config, 'w') as conf: conf.write(json.dumps(data)) test_data = cm.parse_json(config) self.assertNotIn('credentials', data) self.assertNotIn('bucket-name', data) self.assertIn('credentials', test_data) self.assertEquals(test_data['credentials'], "/home/selin/storage-credentials.json") self.assertIn('bucket-name', test_data) self.assertEquals(test_data['bucket-name'], 'clopper-storage')