UNPKG

1.85 kBPlain TextView Raw
1import PythonSystemPackageLookup from '../src/PythonSystemPackageLookup'
2import { fixture } from './test-functions'
3
4const packageLookup = PythonSystemPackageLookup.fromFile(fixture('py-system-package-lookup.json'))
5
6/**
7 * Test reading the system requirements of a Python package where all matching values are found.
8 */
9test('python-sys-lookup:full-depth', () => {
10 const requirements = packageLookup.lookupSystemPackage(
11 'numpy',
12 3,
13 'deb',
14 'xenial')
15 expect(requirements).toEqual(['xenial-numpy-dependencies'])
16})
17
18/**
19 * Test reading the system requirements of a Python package where system name is not set so fall back to default
20 */
21test('python-sys-lookup:no-sysname', () => {
22 const requirements = packageLookup.lookupSystemPackage(
23 'numpy',
24 3,
25 'deb',
26 'test')
27 expect(requirements).toEqual(['deb-default-dependencies'])
28})
29
30/**
31 * Test reading the system requirements of a Python package where the package type is not defined
32 */
33test('python-sys-lookup:no-package-type', () => {
34 const requirements = packageLookup.lookupSystemPackage(
35 'numpy',
36 3,
37 'rpm',
38 'test')
39 expect(requirements).toEqual(['default-default-dependencies'])
40})
41
42/**
43 * Test reading the system requirements of a Python package where the python version being looked up is not set
44 */
45test('python-sys-lookup:no-python-version', () => {
46 const requirements = packageLookup.lookupSystemPackage(
47 'numpy',
48 2,
49 'deb',
50 'xenial')
51 expect(requirements).toEqual(['python-2-dependency'])
52})
53
54/**
55 * Test reading the system requirements of a Python package when there is no entry
56 */
57test('python-sys-lookup:no-package', () => {
58 const requirements = packageLookup.lookupSystemPackage(
59 'my-fake-package',
60 2,
61 'rpm',
62 'test')
63 expect(requirements).toEqual([])
64})