Created
March 29, 2022 08:15
-
-
Save apatard/b85c81fc5a569bafc489e66c4fec349e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -114,16 +114,14 @@ def teardown(): | |
# TEST-LEVEL SETUP AND TEARDOWN | |
[email protected](scope="module") | |
-def vm(request: FixtureRequest, vagrantfile=None) -> Generator[None, None, None]: | |
[email protected](scope="function") | |
+def vm(request: FixtureRequest) -> Generator[None, None, None]: | |
""" | |
Make and return a function that sets up the temporary directory with a | |
Vagrantfile. By default, use VM_VAGRANTFILE. | |
vagrantfile: path to a vagrantfile to use as Vagrantfile in the testing temporary directory. | |
""" | |
- if vagrantfile is None: | |
- vagrantfile = VM_VAGRANTFILE | |
- | |
+ vagrantfile = request.param | |
shutil.copy(vagrantfile, os.path.join(TD, "Vagrantfile")) | |
yield | |
# teardown: Attempts to destroy every VM in the Vagrantfile in the temporary directory, TD. | |
@@ -138,6 +136,7 @@ def vm(request: FixtureRequest, vagrantfile=None) -> Generator[None, None, None] | |
os.unlink(os.path.join(TD, "Vagrantfile")) | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_parse_plugin_list(vm): | |
""" | |
Test the parsing the output of the `vagrant plugin list` command. | |
@@ -159,6 +158,7 @@ def test_parse_plugin_list(vm): | |
) | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_parse_box_list(vm): | |
""" | |
Test the parsing the output of the `vagrant box list` command. | |
@@ -182,6 +182,7 @@ def test_parse_box_list(vm): | |
) | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_parse_status(vm): | |
""" | |
Test the parsing the output of the `vagrant status` command. | |
@@ -206,6 +207,7 @@ def test_parse_status(vm): | |
) | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_parse_aws_status(vm): | |
""" | |
Test the parsing the output of the `vagrant status` command for an aws instance. | |
@@ -238,6 +240,7 @@ def test_parse_aws_status(vm): | |
) | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_vm_status(vm): | |
""" | |
Test whether vagrant.status() correctly reports state of the VM, in a | |
@@ -266,6 +269,7 @@ def test_vm_status(vm): | |
), "After destroying status should be vagrant.NOT_CREATED" | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_vm_lifecycle(vm): | |
""" | |
Test methods controlling the VM - init(), up(), halt(), destroy(). | |
@@ -291,6 +295,7 @@ def test_vm_lifecycle(vm): | |
assert v.NOT_CREATED == v.status()[0].state | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_vm_config(vm): | |
""" | |
Test methods retrieving ssh config settings, like user, hostname, and port. | |
@@ -333,6 +338,7 @@ def test_vm_config(vm): | |
assert keyfile == parsed_config["IdentityFile"].lstrip('"').rstrip('"') | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_vm_sandbox_mode(vm): | |
""" | |
Test methods for enabling/disabling the sandbox mode | |
@@ -478,7 +484,8 @@ def test_boxesvm(): | |
], "There should be no dummy box after it has been removed." | |
-def test_provisioning(vm, vagrantfile=SHELL_PROVISION_VAGRANTFILE): | |
[email protected]('vm', [SHELL_PROVISION_VAGRANTFILE], indirect=['vm']) | |
+def test_provisioning(vm): | |
""" | |
Test provisioning support. The tested provision config creates a file on | |
the vm with the contents 'foo'. | |
@@ -495,7 +502,8 @@ def test_provisioning(vm, vagrantfile=SHELL_PROVISION_VAGRANTFILE): | |
assert test_file_contents == "foo", "The test file should contain 'foo'" | |
-def test_multivm_lifecycle(vm, vagrant_file=MULTIVM_VAGRANTFILE): | |
[email protected]('vm', [MULTIVM_VAGRANTFILE], indirect=['vm']) | |
+def test_multivm_lifecycle(vm): | |
v = vagrant.Vagrant(TD) | |
# test getting multiple statuses at once | |
@@ -528,7 +536,8 @@ def test_multivm_lifecycle(vm, vagrant_file=MULTIVM_VAGRANTFILE): | |
assert v.status(VM_2)[0].state == v.NOT_CREATED | |
-def test_multivm_config(vm, vagrantfile=MULTIVM_VAGRANTFILE): | |
[email protected]('vm', [MULTIVM_VAGRANTFILE], indirect=['vm']) | |
+def test_multivm_config(vm): | |
""" | |
Test methods retrieving configuration settings. | |
""" | |
@@ -570,6 +579,7 @@ def test_multivm_config(vm, vagrantfile=MULTIVM_VAGRANTFILE): | |
assert keyfile == parsed_config["IdentityFile"].lstrip('"').rstrip('"') | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_ssh_command(vm): | |
""" | |
Test executing a command via ssh on a vm. | |
@@ -580,7 +590,8 @@ def test_ssh_command(vm): | |
assert output.strip() == "hello" | |
-def test_ssh_command_multivm(vm, vagrantfile=MULTIVM_VAGRANTFILE): | |
[email protected]('vm', [MULTIVM_VAGRANTFILE], indirect=['vm']) | |
+def test_ssh_command_multivm(vm): | |
""" | |
Test executing a command via ssh on a specific vm | |
""" | |
@@ -592,6 +603,7 @@ def test_ssh_command_multivm(vm, vagrantfile=MULTIVM_VAGRANTFILE): | |
assert output.strip() == "I like your hat" | |
[email protected]('vm', [VM_VAGRANTFILE], indirect=['vm']) | |
def test_streaming_output(vm): | |
""" | |
Test streaming output of up or reload. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment