Exemple #1
0
 def test_empty_config_raises_exception(self):
     """
     Create a Messier object with no config and ensure config is empty.
     """
     temp_dir = tempfile.mkdtemp()
     with self.assertRaises(VagrantfileNotFound):
         with cd(temp_dir):
             m = messier.Messier()
Exemple #2
0
 def test_empty_config(self):
     """
     Create a Messier object with no config and ensure config is empty.
     """
     temp_dir = tempfile.mkdtemp()
     with cd(temp_dir):
         m = messier.Messier()
     self.assertEqual(m.config, {})
Exemple #3
0
 def test_init_creates_vagrantfile_if_none(self):
     """
     Create a new Messier project with a Vagrantfile.
     """
     temp_dir = tempfile.mkdtemp()
     assert not os.path.exists(os.path.join(temp_dir, 'Vagrantfile'))
     with cd(temp_dir):
         m = messier.Messier()
     assert os.path.exists(os.path.join(temp_dir, 'Vagrantfile'))
Exemple #4
0
    def test_missing_playbook_raises_exception(self):
        temp_dir = tempfile.mkdtemp()
        # Write Vagrantfile, otherwise VagrantfileNotFound will be raised first.
        shutil.copy('Vagrantfile', temp_dir)

        with cd(temp_dir):
            m = messier.Messier(playbook="test/default.yml")
            with self.assertRaises(AnsiblePlaybookNotFound):
                m.verify_vms()
Exemple #5
0
 def test_list_vms(self, content=None):
     """
     Ensure named VM in Vagrantfile is returned by `messier list`.
     """
     # Uses tests directory?
     with cd(os.path.abspath(os.path.curdir)):
         m = messier.Messier()
         for vm in ("client", "server"):
           assert vm in [vm.name for vm in m.vms]
Exemple #6
0
 def test_init_does_not_clobber_vagrantfile(self):
     """
     Create a new Messier project and refuse to overwrite preexisting Vagrantfile.
     """
     temp_dir = tempfile.mkdtemp()
     vagrantfile = tempfile.mktemp(dir=temp_dir)
     assert os.path.exists(os.path.join(temp_dir, 'Vagrantfile'))
     original_checksum = hashlib.sha256(vagrantfile).hexdigest()
     with cd(temp_dir):
         m = messier.Messier()
     assert os.path.exists(os.path.join(temp_dir, 'Vagrantfile'))
     new_checksum = hashlib.sha256(vagrantfile).hexdigest()
     assert new_checksum == original_checksum