Exemplo n.º 1
0
    def test_willInstallFirstPackageFound(self):
        remote_location1 = os.path.abspath(os.path.join(os.pathsep, 'opt1'))
        remote_location2 = os.path.abspath(os.path.join(os.pathsep, 'opt2'))
        self.fs.CreateFile('devenv.yaml', contents='''
            config:
                remote-locations: [\'''' + remote_location1 + '\', \'' + remote_location2 + '''\']
            packages:
                json:
                    version: 1.8
                    type: archive''')

        os.makedirs(remote_location1)
        os.makedirs(remote_location2)
        self.fs.CreateFile('json/eggs.txt', contents='''
            I like my eggs runny.''')
        self.fs.CreateFile('json/not_my_eggs.txt', contents='''
            I like my eggs runny.''')

        with ZipFile(os.path.join(remote_location1, 'json-1.8.zip'), 'w') as myzip:
            myzip.write('json/eggs.txt')
        with ZipFile(os.path.join(remote_location2, 'json-1.8.zip'), 'w') as myzip:
            myzip.write('json/not_my_eggs.txt')

        go.get_dem_packages(self.project)

        self.assertTrue(os.path.exists(os.path.join('.devenv', self.project, 'dependencies', 'json', 'eggs.txt')))
        self.assertFalse(os.path.exists(os.path.join('.devenv', self.project, 'dependencies', 'json', 'not_my_eggs.txt')))
Exemplo n.º 2
0
    def test_will_not_install_already_installed_rpm(self, mock_stdout, mock_subprocess):
        remote_location = os.path.abspath(os.path.join(os.pathsep, 'opt'))
        self.fs.CreateFile('devenv.yaml', contents='''
            config:
                remote-locations: ''' + remote_location + '''
            packages:
                json:
                    version: 1.8
                    type: rpm''')
        os.makedirs(remote_location)

        go.get_dem_packages(self.project)
        with open('devenv.yaml', 'a+') as f:
            f.write('\n\n')

        go.get_dem_packages(self.project)

        self.assertTrue('json-1.8 already installed' in mock_stdout.getvalue())
Exemplo n.º 3
0
    def test_willPrintMessageWhenArchivedPackageCannotBeFound(self, mock_stdout):
        remote_location = os.path.abspath(os.path.join(os.pathsep, 'opt'))
        self.fs.CreateFile('devenv.yaml', contents='''
            config:
                remote-locations: ''' + remote_location + '''
            packages:
                json:
                    version: 1.8
                    type: archive''')
        os.makedirs('not_opts')
        self.fs.CreateFile('eggs.txt', contents='''
            I like my eggs runny.''')

        with ZipFile(os.path.join('not_opts', 'json-1.8.zip'), 'w') as myzip:
            myzip.write('eggs.txt')

        go.get_dem_packages(self.project)

        self.assertTrue('Could not find package: json, version: 1.8\n' in mock_stdout.getvalue())
Exemplo n.º 4
0
    def test_willUnzipDependencyIntoDependenciesDirectory(self):
        remote_location = os.path.abspath(os.path.join(os.pathsep, 'opt'))
        self.fs.CreateFile('devenv.yaml', contents='''
            config:
                remote-locations: ''' + remote_location + '''
            packages:
                json:
                    version: 1.8
                    type: archive''')
        os.makedirs(remote_location)
        self.fs.CreateFile('json/eggs.txt', contents='''
            I like my eggs runny.''')

        with ZipFile(os.path.join(remote_location, 'json-1.8.zip'), 'w') as myzip:
            myzip.write('json/eggs.txt')

        go.get_dem_packages(self.project)

        self.assertTrue(os.path.exists(os.path.join('.devenv', self.project, 'dependencies', 'json', 'eggs.txt')))
Exemplo n.º 5
0
    def test_willUnzipToBinaryDestinationLinuxStrippingParentDirectory(self):
        remote_location = os.path.abspath(os.path.join(os.pathsep, 'opt'))
        self.fs.CreateFile('devenv.yaml', contents='''
               config:
                   remote-locations: ''' + remote_location + '''
               packages:
                   json:
                       version: 1.8
                       type: archive
                       destination: bin''')
        os.makedirs(remote_location)
        self.fs.CreateFile('eggs.exe', contents='''
               I like my eggs runny.''')

        with ZipFile(os.path.join(remote_location, 'json-1.8.zip'), 'w') as myzip:
            myzip.write('eggs.exe')

        go.get_dem_packages(self.project)
        self.assertTrue(os.path.exists(os.path.join('.devenv', self.project, 'bin', 'eggs.exe')))
Exemplo n.º 6
0
    def test_willNotInstallWindowsPackagesForLinuxOS(self):
        remote_location = os.path.abspath(os.path.join(os.pathsep, 'opt'))
        self.fs.CreateFile('devenv.yaml', contents='''
                config:
                    remote-locations: ''' + remote_location + '''
                packages-win32:
                    json:
                        version: 1.8
                        type: archive''')
        os.makedirs(remote_location)
        self.fs.CreateFile('eggs.txt', contents='''
                I like my eggs runny.''')

        with ZipFile(os.path.join(remote_location, 'json-1.8.zip'), 'w') as myzip:
            myzip.write('eggs.txt')

        go.get_dem_packages(self.project)

        self.assertFalse(os.path.exists(os.path.join('.devenv', 'libs', 'json', 'eggs.txt')))
Exemplo n.º 7
0
    def test_willCloneGitRepositoryAndCheckoutShaToARelativeDirectory(self, mock_clone):
        self.fs.CreateFile('devenv.yaml', contents='''
                   config:
                   packages:
                       qtcwatchdog:
                           version: 72f3588eef1019bac8788fa58c52722dfa7c4d28
                           type: git
                           url: https://github.com/ismacaulay/qtcwatchdog
                           destination: code/python/''')

        mock_repo = MagicMock()
        def clone_side_effect(url, destination):
            os.makedirs(destination)
            self.fs.CreateFile(os.path.join(destination, 'qtc.py'), contents='''
                          I like my eggs runny.''')
            return mock_repo

        mock_clone.side_effect = clone_side_effect
        go.get_dem_packages(self.project)
        self.assertTrue(
            os.path.exists(os.path.join('code/python/', 'qtcwatchdog')))
Exemplo n.º 8
0
    def test_will_not_extract_already_installed_archive(self, mock_stdout):
        remote_location = os.path.abspath(os.path.join(os.pathsep, 'opt'))
        self.fs.CreateFile('devenv.yaml', contents='''
            config:
                remote-locations: ''' + remote_location + '''
            packages:
                json:
                    version: 1.8
                    type: archive''')
        os.makedirs(remote_location)
        self.fs.CreateFile('eggs.txt', contents='''
            I like my eggs runny.''')

        with ZipFile(os.path.join(remote_location, 'json-1.8.zip'), 'w') as myzip:
            myzip.write('eggs.txt')

        go.get_dem_packages(self.project)
        with open('devenv.yaml', 'a+') as f:
            f.write('\n\n')

        go.get_dem_packages(self.project)

        self.assertTrue('json-1.8 already installed' in mock_stdout.getvalue())
Exemplo n.º 9
0
    def test_willDownloadUrlToPythonSitePackagesDestinationWindowsStrippingParentDirectory(self, mock_wget):
        self.fs.CreateFile('devenv.yaml', contents='''
                packages:
                    qtcwatchdog:
                        version: 1.0.1
                        type: url
                        url: https://github.com/ismacaulay/qtcwatchdog/archive/v1.0.1.zip
                        destination: python-site-packages''')

        def wget_side_effect(url, out):
            remote_location = os.path.join('.devenv', self.project, 'downloads')
            self.fs.CreateFile(os.path.join('qtcwatchdog', 'qtc.py'), contents='''
                       I like my eggs runny.''')

            with ZipFile(os.path.join(remote_location, 'qtcwatchdog-1.0.1.zip'), 'w') as myzip:
                myzip.write(os.path.join('qtcwatchdog', 'qtc.py'))

        mock_wget.side_effect = wget_side_effect
        go.get_dem_packages(self.project)

        self.assertTrue(
            os.path.exists(os.path.join('.devenv', self.project, 'Lib', 'site-packages', 'qtcwatchdog')))
        self.assertTrue(
            os.path.exists(os.path.join('.devenv', self.project, 'Lib', 'site-packages', 'qtcwatchdog', 'qtc.py')))
Exemplo n.º 10
0
def main():
	dem.get_dem_packages()
	write_environment_bash()
Exemplo n.º 11
0
    def test_willInstallLatestDem(self, mock_pip):
        self.fs.CreateFile('devenv.yaml')

        go.get_dem_packages(self.project)

        mock_pip.assert_any_call('dem', 'latest')
Exemplo n.º 12
0
    def test_willCreateDependenciesFolder(self):
        self.fs.CreateFile('devenv.yaml')

        go.get_dem_packages(self.project)

        self.assertTrue(os.path.exists('.devenv'))