def test_generate_input(self): writer = Writer(self.data, content='random') config, param = writer.generate_input([['5fa34fc', 'a16e0bb','8924a5f'], ['abc', 'abc', 'xyz']]) self.assertEqual(config, expanduser('~/tmp/config.tar.gz')) tar = tarfile.open(expanduser(config)) tar.extractall(path=expanduser('./config')) tar.close() os.chdir('./config') num_files = len([name for name in os.listdir('.')]) self.assertEquals(num_files, 3) self.assertEqual(param, expanduser('~/tmp/params.tar.gz')) tar = tarfile.open(expanduser(param)) tar.extractall(path=expanduser('./test-param')) tar.close() os.chdir('./test-param') num_files = len([name for name in os.listdir('.')]) self.assertEquals(num_files, 3) self.assertItemsEqual(os.listdir('.'), ['cl-params-1.txt','cl-params-2.txt','cl-params-3.txt']) with open('cl-params-2.txt', 'r') as f: buf = f.read() self.assertIn("--tests 'abc$'", buf) self.assertIn('-o ~/tmp/out.csv', buf) self.assertIn('-f ~/tmp/config/cloud-config-2.xml', buf) self.assertIn('--cloud ~/storage-credentials.json clopper-storage', buf)
def test_generate_input5(self): writer = Writer(self.data, content='random') config, param = writer.generate_input([['a16e0bb', '5fa34fc', '01bc2b2', '4a5af86', '5030820', '54af3bd', '8b83879'],['foo','bar','baz']]) self.assertEqual(config, expanduser('~/tmp/config.tar.gz')) tar = tarfile.open(expanduser(config)) tar.extractall(path=expanduser('./config')) tar.close() os.chdir('./config') num_files = len([name for name in os.listdir('.')]) self.assertEquals(num_files, 7) self.assertEqual(param, expanduser('~/tmp/params.tar.gz')) tar = tarfile.open(expanduser(param)) tar.extractall(path=expanduser('./test-param')) tar.close() os.chdir('./test-param') num_files = len([name for name in os.listdir('.')]) self.assertEquals(num_files, 7)
def test_generate_input3(self): writer = Writer(self.data, content='') config, param = writer.generate_input([[None],['foo','bar','baz']]) self.assertEqual(config, expanduser('~/tmp/config.tar.gz')) tar = tarfile.open(expanduser(config)) tar.extractall(path=expanduser('./config')) tar.close() os.chdir('./config') num_files = len([name for name in os.listdir('.')]) self.assertEquals(num_files, 1) self.assertEqual(param, expanduser('~/tmp/params.tar.gz')) tar = tarfile.open(expanduser(param)) tar.extractall(path=expanduser('./test-param')) tar.close() os.chdir('./test-param') num_files = len([name for name in os.listdir('.')]) self.assertEquals(num_files, 1) self.assertEqual(os.listdir('.')[0], 'cl-params-1.txt')