Exemplo n.º 1
0
    def test_create_symlink_no_link_parent(self):
        source_path = os.path.join(self.working_dir, 'source')
        link_path = os.path.join(self.published_dir, 'foo/bar/baz/link')

        touch(source_path)
        self.assertFalse(os.path.exists(os.path.dirname(link_path)))

        PublishStep._create_symlink(source_path, link_path)

        self.assertTrue(os.path.exists(link_path))
Exemplo n.º 2
0
 def test_publish_distribution_packages_link_with_packagedir_delete_existing_packages(self):
     packages_dir = os.path.join(self.working_dir, 'Packages')
     old_directory = os.path.join(self.working_dir, "foo")
     os.mkdir(old_directory)
     PublishStep._create_symlink(old_directory, packages_dir)
     self.assertEquals(os.path.realpath(packages_dir), old_directory)
     unit = self._generate_distribution_unit('one', {'packagedir': 'Packages'})
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     step._publish_distribution_packages_link(unit)
     self.assertFalse(os.path.islink(packages_dir))
Exemplo n.º 3
0
 def test_publish_distribution_packages_link_with_packagedir_delete_existing_packages(self):
     packages_dir = os.path.join(self.working_dir, 'Packages')
     old_directory = os.path.join(self.working_dir, "foo")
     os.mkdir(old_directory)
     PublishStep._create_symlink(old_directory, packages_dir)
     self.assertEquals(os.path.realpath(packages_dir), old_directory)
     unit = self._generate_distribution_unit('one', {'packagedir': 'Packages'})
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     step._publish_distribution_packages_link(unit)
     self.assertFalse(os.path.islink(packages_dir))
Exemplo n.º 4
0
    def test_create_symlink(self):
        source_path = os.path.join(self.working_dir, 'source')
        link_path = os.path.join(self.published_dir, 'link')

        touch(source_path)
        self.assertFalse(os.path.exists(link_path))

        PublishStep._create_symlink(source_path, link_path)

        self.assertTrue(os.path.exists(link_path))
        self.assertTrue(os.path.islink(link_path))
        self.assertEqual(os.readlink(link_path), source_path)
Exemplo n.º 5
0
    def test_create_symlink_link_exists_and_is_correct(self):
        new_source_path = os.path.join(self.working_dir, 'new_source')
        link_path = os.path.join(self.published_dir, 'link')

        touch(new_source_path)

        os.symlink(new_source_path, link_path)

        self.assertEqual(os.readlink(link_path), new_source_path)

        PublishStep._create_symlink(new_source_path, link_path)

        self.assertEqual(os.readlink(link_path), new_source_path)
Exemplo n.º 6
0
    def test_create_symlink_link_exists(self):
        old_source_path = os.path.join(self.working_dir, 'old_source')
        new_source_path = os.path.join(self.working_dir, 'new_source')
        link_path = os.path.join(self.published_dir, 'link')

        touch(old_source_path)
        touch(new_source_path)

        os.symlink(old_source_path, link_path)

        self.assertEqual(os.readlink(link_path), old_source_path)

        link_path_with_slash = link_path + '/'

        PublishStep._create_symlink(new_source_path, link_path_with_slash)

        self.assertEqual(os.readlink(link_path), new_source_path)
Exemplo n.º 7
0
 def test_create_symlink(self, mock_symlink):
     step = PublishStep("foo")
     step._create_symlink('foo', 'bar')
     mock_symlink.assert_called_once_with('foo', 'bar')