Ejemplo n.º 1
0
	def test_set_temp_dir(self):
		sys.argv[1:] = ['-config', './sample-config.json']
		parser = ProvisionArgsParser()
		tmp_dir = '%s%s%s' % (tempfile.gettempdir(), os.sep, 'git_repo')
		tmp_dir_expected = parser.set_tmp_dir()
		self.assertEqual(tmp_dir, tmp_dir_expected)
		self.assertEqual(os.path.exists(tmp_dir_expected), False)
Ejemplo n.º 2
0
	def test_validate_git_repo_cmd_with_no_git_ssh_key(self):
		py_django_provision.provision_args.subprocess.check_call = Mock(return_value=0)
		sys.argv[1:] = ['-config', './sample-config.json']
		parser = ProvisionArgsParser()
		parser.args = dict(repo = 'https://github.com/webiken/bvd.git')
		check = parser.valid_git_repo()

		tmpdir = tempfile.gettempdir()
		clone = 'git clone https://github.com/webiken/bvd.git %s%s%s' % (tmpdir, os.sep, 'git_repo')
		cmd = '%s' % clone
		self.assertEqual(parser.cmd, cmd)
Ejemplo n.º 3
0
	def test_parse_args(self):
		actual_args = dict(
			app_name = 'sample_django_app',
			server = 'maximus.webiken.net',
			server_ssh_key = '/Users/sam/.ssh/id_rsa',
			repo = 'https://github.com/webiken/bvd.git',
			username = '******',
			db_config = dict(
					db_system = 'mysql',
					db_app_user = '******',
				)
		)
		py_django_provision.provision_args.subprocess.check_call = Mock(return_value=0)
		py_django_provision.provision_args.socket.gethostbyname = Mock(return_value='127.0.0.1')
		py_django_provision.provision_args.ProvisionConfigParser.parse_args = Mock(return_value=actual_args)
		py_django_provision.provision_args.sshclient.paramiko.SSHClient.connect = Mock(return_value=True)

		sys.argv[1:] = ['-config', './sample-config.json']

		parser = ProvisionArgsParser() 
		args = parser.parse_args()

		self.assertEquals('app_name' in args, True)
Ejemplo n.º 4
0
def main():
	parser = ProvisionArgsParser()
	args, sshclient = parser.parse_args()

	installer = Provision(args, sshclient)
	installer.provision()
Ejemplo n.º 5
0
	def test_validate_git_repo_returns_true(self):
		py_django_provision.provision_args.subprocess.check_call = Mock(return_value=0)
		sys.argv[1:] = ['-config', './sample-config.json']
		parser = ProvisionArgsParser()
		parser.args = dict(repo = 'https://github.com/webiken/bvd.git')
		self.assertEquals(parser.valid_git_repo(), True)
Ejemplo n.º 6
0
	def test_validate_hostname_return_true(self):
		py_django_provision.provision_args.socket.gethostbyname = Mock(return_value='127.0.0.1')
		sys.argv[1:] = ['-config', './sample-config.json']
		parser = ProvisionArgsParser()
		parser.args = dict(server = 'example.com')
		self.assertEqual(parser.valid_hostname(), True)