Exemplo n.º 1
0
class TestSubprojects(TestCase):

    def setUp(self):
        self.project = get(Project, slug='kong')
        self.subproject = get(Project, slug='sub')
        self.symlink = Symlink(self.project)
        self.args = {
            'web_root': self.symlink.WEB_ROOT,
            'subproject_root': self.symlink.subproject_root,
        }
        self.commands = []

    @patched
    def test_subproject_normal(self):
        self.project.add_subproject(self.subproject)
        self.symlink.symlink_subprojects()
        self.args['subproject'] = self.subproject.slug
        commands = [
            'ln -nsf {web_root}/{subproject} {subproject_root}/{subproject}',
        ]

        for index, command in enumerate(commands):
            self.assertEqual(self.commands[index], command.format(**self.args))

    @patched
    def test_subproject_alias(self):
        self.project.add_subproject(self.subproject, alias='sweet-alias')
        self.symlink.symlink_subprojects()
        self.args['subproject'] = self.subproject.slug
        self.args['alias'] = 'sweet-alias'
        commands = [
            'ln -nsf {web_root}/{subproject} {subproject_root}/{subproject}',
            'ln -nsf {web_root}/{subproject} {subproject_root}/{alias}',
        ]

        for index, command in enumerate(commands):
            self.assertEqual(self.commands[index], command.format(**self.args))

    def test_remove_subprojects(self):
        self.project.add_subproject(self.subproject)
        self.symlink.symlink_subprojects()
        subproject_link = os.path.join(
            self.symlink.subproject_root, self.subproject.slug
        )
        self.assertTrue(os.path.lexists(subproject_link))
        self.project.remove_subproject(self.subproject)
        self.symlink.symlink_subprojects()
        self.assertTrue(not os.path.lexists(subproject_link))
Exemplo n.º 2
0
def symlink_subproject(project_pk):
    project = Project.objects.get(pk=project_pk)
    sym = Symlink(project=project)
    sym.symlink_subprojects()
Exemplo n.º 3
0
def symlink_subproject(project_pk):
    project = Project.objects.get(pk=project_pk)
    sym = Symlink(project=project)
    sym.symlink_subprojects()