Ejemplo n.º 1
0
def test_latest_installed_but_outdated(monkeypatch):
    monkeypatch.setattr(
        NPM, 'run',
        build_run(
            fixture_subpath='npm',
            command_mappings=[
                CommandMapping(
                    command=[
                        'npm', 'list', '--json', '--depth 0', '--prefix',
                        '/Users/fots/project', 'express'
                    ],
                    stdout_filename='npm_list_installed_but_outdated.stdout'),
                CommandMapping(
                    command=['npm', 'view', '--json', 'express'],
                    stdout_filename='npm_view_installed_but_outdated.stdout'),
                CommandMapping(command=[
                    'npm', 'install', '--prefix', '/Users/fots/project',
                    'express'
                ])
            ]))

    npm = NPM(name='express',
              state='latest',
              executable='npm',
              path='/Users/fots/project')
    assert npm.process() == ActionResponse(changed=True)
Ejemplo n.º 2
0
def test_list_command_invalid(monkeypatch):
    monkeypatch.setattr(
        NPM, 'run',
        build_run(fixture_subpath='npm',
                  command_mappings=[
                      CommandMapping(command=[
                          'npm', 'list', '--json', '--depth 0', '--prefix',
                          '/Users/fots/project', 'express'
                      ],
                                     returncode=2)
                  ]))

    npm = NPM(name='express',
              state='present',
              executable='npm',
              path='/Users/fots/project')
    with pytest.raises(ActionError):
        npm.process()
Ejemplo n.º 3
0
def test_global_install(monkeypatch):
    monkeypatch.setattr(
        NPM, 'run',
        build_run(
            fixture_subpath='npm',
            command_mappings=[
                CommandMapping(command=[
                    'npm', 'list', '--json', '--depth 0', '--global', 'express'
                ],
                               stdout_filename='npm_list_installed.stdout')
            ]))

    npm = NPM(name='express', state='present', executable='npm', mode='global')
    assert npm.process() == ActionResponse(changed=False)
Ejemplo n.º 4
0
def test_executable_unspecified(monkeypatch):
    monkeypatch.setattr(
        NPM, 'run',
        build_run(fixture_subpath='npm',
                  command_mappings=[
                      CommandMapping(
                          command=[
                              'npm', 'list', '--json', '--depth 0', '--prefix',
                              '/Users/fots/project', 'express'
                          ],
                          stdout_filename='npm_list_installed.stdout')
                  ]))

    npm = NPM(name='express', state='present', path='/Users/fots/project')
    assert npm.process() == ActionResponse(changed=False)
Ejemplo n.º 5
0
def test_present_with_version_installed_different(monkeypatch):
    monkeypatch.setattr(
        NPM, 'run',
        build_run(fixture_subpath='npm',
                  command_mappings=[
                      CommandMapping(
                          command=[
                              'npm', 'list', '--json', '--depth 0', '--prefix',
                              '/Users/fots/project', 'express'
                          ],
                          stdout_filename='npm_list_installed.stdout'),
                      CommandMapping(command=[
                          'npm', 'install', '--prefix', '/Users/fots/project',
                          '[email protected]'
                      ])
                  ]))

    npm = NPM(name='express',
              version='4.15.5',
              state='present',
              executable='npm',
              path='/Users/fots/project')
    assert npm.process() == ActionResponse(changed=True)