Example #1
0
 def test_get_system(self):
     d = Damnode()
     test = lambda a, b: self.assertEqual(d._get_system(a), b)
     test('AIX', 'aix')
     test('Darwin', 'darwin')
     test('Linux', 'linux')
     test('Solaris', 'sunos')
     test('Windows', 'win')
Example #2
0
 def test_parse_version(self):
     d = Damnode()
     self.assertEqual((4, None, None), d.parse_version('v4'))
     self.assertEqual((5, 12, None), d.parse_version('5.12'))
     self.assertEqual((6, 11, 0), d.parse_version('v6.11.0'))
     self.assertRaisesRegexp(
         ValueError,
         r"Invalid version '6.11.0.0', it does not match regex ",
         d.parse_version, '6.11.0.0')
     self.assertRaises(ValueError, d.parse_version, '6.11.0.0')
     self.assertRaises(ValueError, d.parse_version, 'node-v6.11.0')
Example #3
0
    def test_parse_package_name(self):
        d = Damnode()

        self.assertRaisesRegexp(
            ValueError,
            r"Invalid package name 'node.*', suffix must be one of \[",
            d.parse_package_name, 'node-v8.1.2-win-x64.superzip')

        self.assertEqual(((8, 1, 2), 'linux', 'x64', 'tar.gz'),
                         d.parse_package_name('node-v8.1.2-linux-x64.tar.gz'))

        self.assertRaisesRegexp(
            ValueError,
            r"Invalid package name 'foobar.*', it does not match regex \^node-",
            d.parse_package_name, 'foobar-v8.1.2-darwin-x64.tar.gz')
Example #4
0
    def test_get_compatible_arch(self):
        d = Damnode()
        test = lambda m, p, a: self.assertEqual(d._get_compatible_arch(m, p), a
                                                )

        # https://en.wikipedia.org/wiki/Uname
        test('armv7l', '', 'armv7l')
        test('armv6l', '', 'armv6l')
        test('i686', '', 'x86')
        test('i686', 'i686', 'x86')
        test('x86_64', '', 'x64')
        test('x86_64', 'x86_64', 'x64')
        test('i686-AT386', '', 'x86')
        test('amd64', '', 'x64')
        test('amd64', 'amd64', 'x64')
        test('x86', 'Intel_x86_Family6_Model28_Stepping10', 'x86')
        test('i686-64', 'x64', 'x64')

        # PowerPC
        # - https://en.wikipedia.org/wiki/Uname
        # - https://github.com/ansible/ansible/pull/2311
        test('ppc', '', 'ppc64')  # no ppc packages
        test('ppc64', 'ppc64', 'ppc64')
        test('ppc64le', 'ppc64le', 'ppc64le')
        test('00C57D4D4C00', 'powerpc', 'ppc64')
        test('Power Macintosh', 'powerpc', 'ppc64')

        # https://stackoverflow.com/questions/31851611/differences-between-arm64-and-aarch64
        test('arm64', '', 'arm64')
        test('aarch64', '', 'arm64')

        # https://en.wikipedia.org/wiki/Linux_on_z_Systems
        test('s390', 's390', 's390x')  # no s390 packages
        test('s390x', 's390x', 's390x')

        # Unsupported
        test('sparc64', 'sparc64', 'sparc64')
Example #5
0
 def test_is_url(self):
     d = Damnode()
     self.assertTrue(d.is_url('http://localhost'))
     self.assertTrue(d.is_url('https://localhost'))
     self.assertTrue(d.is_url('file://localhost'))
     self.assertFalse(d.is_url('~/Download'))
Example #6
0
 def test_has_package_suffix(self):
     d = Damnode()
     self.assertTrue(d.has_package_suffix('file.tar.gz'))
     self.assertTrue(d.has_package_suffix('file.zip'))
Example #7
0
def create_damnode():
    d = Damnode()
    d.cache_dir = data_dir('cache')
    d.verbose = True
    return d
Example #8
0
 def download_install(self, url, prefix, check_sys_arch=False):
     d = Damnode()
     d.prefix = prefix
     # d.verbose = True
     d.check_sys_arch = check_sys_arch
     d.download_install_package(url)