def test_ssh_client_copies(ssh_client): ssh_client_kwargs = { 'username': generate_random_string(), 'password': generate_random_string(), 'hostname': generate_random_string(), } # Make sure the ssh copy mechanism works ssh_client_copy = ssh_client(**ssh_client_kwargs) orig_kwargs = ssh_client._connect_kwargs copy_kwargs = ssh_client_copy._connect_kwargs Assert.not_equal(orig_kwargs['username'], copy_kwargs['username']) Assert.not_equal(orig_kwargs['password'], copy_kwargs['password']) Assert.not_equal(orig_kwargs['hostname'], copy_kwargs['hostname']) # And also make sure the ssh copy only updates new kwargs ssh_client_copy = ssh_client(hostname=generate_random_string()) copy_kwargs = ssh_client_copy._connect_kwargs Assert.equal(orig_kwargs['username'], copy_kwargs['username']) Assert.equal(orig_kwargs['password'], copy_kwargs['password']) Assert.not_equal(orig_kwargs['hostname'], copy_kwargs['hostname'])
def test_generate_random_string_args(): length = 16 random_string = randomness.generate_random_string(length) Assert.equal(len(random_string), length)
def random_string(): '''Generate a random string for use in tests''' return randomness.generate_random_string()
def test_generate_random_string_noargs(): random_string = randomness.generate_random_string() # 8 is the default length Assert.equal(len(random_string), 8)
def test_generate_random_string_args(): length = 16 random_string = randomness.generate_random_string(length) assert len(random_string) == length
def test_generate_random_string_noargs(): random_string = randomness.generate_random_string() # 8 is the default length assert len(random_string) == 8