Ejemplo n.º 1
0
 def test_real_path(self):
     symlink = getattr(os, 'symlink', None)
     skipIf(symlink is None, "No symlink support")
     tempdir = self.mkdtemp()
     source = os.path.join(tempdir, 'source')
     self.touch(source)
     target = os.path.join(tempdir, 'target')
     symlink(source, target)
     self.assertThat(source, SamePath(target))
     self.assertThat(target, SamePath(source))
Ejemplo n.º 2
0
 def test_get_bind_config_dir_checks_environ_first(self):
     directory = self.make_dir()
     self.useFixture(EnvironmentVariable("MAAS_BIND_CONFIG_DIR", directory))
     self.assertThat(
         config.get_bind_config_dir(),
         MatchesAll(SamePath(directory), IsInstance(str)),
     )
Ejemplo n.º 3
0
 def test_get_dns_config_dir_defaults_to_etc_bind_maas(self):
     self.useFixture(EnvironmentVariable("MAAS_DNS_CONFIG_DIR"))
     self.assertThat(
         config.get_dns_config_dir(),
         MatchesAll(SamePath(locate_config("../bind/maas")),
                    IsInstance(str)),
     )
Ejemplo n.º 4
0
 def test_atomic_symlink_creates_symlink(self):
     filename = self.make_file(contents=factory.make_string())
     target_dir = self.make_dir()
     link_name = factory.make_name("link")
     target = os.path.join(target_dir, link_name)
     atomic_symlink(filename, target)
     self.assertTrue(os.path.islink(target),
                     "atomic_symlink didn't create a symlink")
     self.assertThat(target, SamePath(filename))
Ejemplo n.º 5
0
 def test_creates_populates_and_removes_new_directory(self):
     fixture = MAASRootFixture()
     with fixture:
         self.assertThat(fixture.path, PathExists())
         self.assertThat(fixture.path, Not(SamePath(self.skel)))
         files_expected = set(listdirs(self.skel))
         files_observed = set(listdirs(fixture.path))
         self.assertThat(files_observed, Equals(files_expected))
     self.assertThat(fixture.path, Not(PathExists()))
Ejemplo n.º 6
0
 def test_atomic_symlink_overwrites_dest_file(self):
     filename = self.make_file(contents=factory.make_string())
     target_dir = self.make_dir()
     link_name = factory.make_name("link")
     # Create a file that will be overwritten.
     factory.make_file(location=target_dir, name=link_name)
     target = os.path.join(target_dir, link_name)
     atomic_symlink(filename, target)
     self.assertTrue(os.path.islink(target),
                     "atomic_symlink didn't create a symlink")
     self.assertThat(target, SamePath(filename))
Ejemplo n.º 7
0
 def test_updates_MAAS_ROOT_in_the_environment(self):
     self.assertThat(os.environ["MAAS_ROOT"], Not(SamePath(self.skel)))
     with MAASRootFixture() as fixture:
         self.assertThat(os.environ["MAAS_ROOT"], SamePath(fixture.path))
     self.assertThat(os.environ["MAAS_ROOT"], Not(SamePath(self.skel)))
Ejemplo n.º 8
0
 def test_relative_and_absolute(self):
     path = 'foo'
     abspath = os.path.abspath(path)
     self.assertThat(path, SamePath(abspath))
     self.assertThat(abspath, SamePath(path))
Ejemplo n.º 9
0
 def test_same_string(self):
     self.assertThat('foo', SamePath('foo'))