Esempio 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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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()
Esempio 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)
Esempio n. 6
0
def test_argument_state_invalid():
    with pytest.raises(ValueError):
        NPM(name='express', state='hmmm', path='/Users/fots/project')
Esempio n. 7
0
def test_argument_path_after_init_invalid():
    npm = NPM(name='express', mode='local', path='/Users/fots/project')
    with pytest.raises(ValueError):
        npm.path = None
Esempio n. 8
0
def test_argument_mode_after_init_invalid():
    npm = NPM(name='express', mode='global')
    with pytest.raises(ValueError):
        npm.mode = 'local'
Esempio n. 9
0
def test_argument_mode_path_combination_invalid():
    with pytest.raises(ValueError):
        NPM(name='express', mode='local')
Esempio n. 10
0
def test_argument_state_after_init_invalid():
    npm = NPM(name='express', version='4.16.3', path='/Users/fots/project')
    with pytest.raises(ValueError):
        npm.state = 'latest'
Esempio n. 11
0
def test_argument_version_state_combination_invalid():
    with pytest.raises(ValueError):
        NPM(name='express',
            state='latest',
            version='4.16.3',
            path='/Users/fots/project')