|
| 1 | +require 'spec_helper_acceptance' |
| 2 | + |
| 3 | +describe 'python::pyvenv defined resource' do |
| 4 | + context 'minimal parameters' do |
| 5 | + # Using puppet_apply as a helper |
| 6 | + it 'works with no errors' do |
| 7 | + pp = <<-PUPPET |
| 8 | + class { 'python': |
| 9 | + version => '3', |
| 10 | + dev => 'present', |
| 11 | + } |
| 12 | + user { 'agent': |
| 13 | + ensure => 'present', |
| 14 | + managehome => true, |
| 15 | + home => '/opt/agent', |
| 16 | + } |
| 17 | + group { 'agent': |
| 18 | + ensure => 'present', |
| 19 | + system => true, |
| 20 | + } |
| 21 | + python::pyvenv { '/opt/agent/venv': |
| 22 | + ensure => 'present', |
| 23 | + systempkgs => true, |
| 24 | + owner => 'agent', |
| 25 | + group => 'agent', |
| 26 | + mode => '0755', |
| 27 | + } |
| 28 | + PUPPET |
| 29 | + |
| 30 | + # Run it twice and test for idempotency |
| 31 | + apply_manifest(pp, catch_failures: true) |
| 32 | + apply_manifest(pp, catch_changes: true) |
| 33 | + end |
| 34 | + end |
| 35 | + |
| 36 | + context 'with python::pip' do |
| 37 | + it 'works with no errors' do |
| 38 | + pp = <<-PUPPET |
| 39 | + class { 'python': |
| 40 | + version => '3', |
| 41 | + dev => 'present', |
| 42 | + } |
| 43 | + user { 'agent': |
| 44 | + ensure => 'present', |
| 45 | + managehome => true, |
| 46 | + home => '/opt/agent', |
| 47 | + } |
| 48 | + group { 'agent': |
| 49 | + ensure => 'present', |
| 50 | + system => true, |
| 51 | + } |
| 52 | + python::pyvenv { '/opt/agent/venv': |
| 53 | + ensure => 'present', |
| 54 | + systempkgs => true, |
| 55 | + owner => 'agent', |
| 56 | + group => 'agent', |
| 57 | + mode => '0755', |
| 58 | + } |
| 59 | + python::pip { 'agent' : |
| 60 | + ensure => 'latest', |
| 61 | + pkgname => 'agent', |
| 62 | + pip_provider => 'pip', |
| 63 | + virtualenv => '/opt/agent/venv', |
| 64 | + owner => 'agent', |
| 65 | + group => 'agent', |
| 66 | + } |
| 67 | + PUPPET |
| 68 | + |
| 69 | + # Run it twice and test for idempotency |
| 70 | + apply_manifest(pp, catch_failures: true) |
| 71 | + apply_manifest(pp, catch_changes: true) |
| 72 | + end |
| 73 | + end |
| 74 | + |
| 75 | + context 'with minimal python::pip' do |
| 76 | + it 'works with no errors' do |
| 77 | + pp = <<-PUPPET |
| 78 | + class { 'python': |
| 79 | + version => '3', |
| 80 | + dev => 'present', |
| 81 | + } |
| 82 | + user { 'agent': |
| 83 | + ensure => 'present', |
| 84 | + managehome => true, |
| 85 | + home => '/opt/agent', |
| 86 | + } |
| 87 | + group { 'agent': |
| 88 | + ensure => 'present', |
| 89 | + system => true, |
| 90 | + } |
| 91 | + python::pyvenv { '/opt/agent/venv': |
| 92 | + ensure => 'present', |
| 93 | + systempkgs => true, |
| 94 | + owner => 'agent', |
| 95 | + group => 'agent', |
| 96 | + mode => '0755', |
| 97 | + } |
| 98 | + python::pip { 'agent' : |
| 99 | + virtualenv => '/opt/agent/venv', |
| 100 | + owner => 'agent', |
| 101 | + group => 'agent', |
| 102 | + } |
| 103 | + PUPPET |
| 104 | + |
| 105 | + # Run it twice and test for idempotency |
| 106 | + apply_manifest(pp, catch_failures: true) |
| 107 | + apply_manifest(pp, catch_changes: true) |
| 108 | + end |
| 109 | + end |
| 110 | + |
| 111 | + context 'with minimal python::pip and without systempkgs' do |
| 112 | + it 'works with no errors' do |
| 113 | + pp = <<-PUPPET |
| 114 | + class { 'python': |
| 115 | + version => '3', |
| 116 | + dev => 'present', |
| 117 | + } |
| 118 | + user { 'agent': |
| 119 | + ensure => 'present', |
| 120 | + managehome => true, |
| 121 | + home => '/opt/agent', |
| 122 | + } |
| 123 | + group { 'agent': |
| 124 | + ensure => 'present', |
| 125 | + system => true, |
| 126 | + } |
| 127 | + python::pyvenv { '/opt/agent/venv': |
| 128 | + ensure => 'present', |
| 129 | + systempkgs => false, |
| 130 | + owner => 'agent', |
| 131 | + group => 'agent', |
| 132 | + mode => '0755', |
| 133 | + } |
| 134 | + python::pip { 'agent' : |
| 135 | + virtualenv => '/opt/agent/venv', |
| 136 | + owner => 'agent', |
| 137 | + group => 'agent', |
| 138 | + } |
| 139 | + PUPPET |
| 140 | + |
| 141 | + # Run it twice and test for idempotency |
| 142 | + apply_manifest(pp, catch_failures: true) |
| 143 | + apply_manifest(pp, catch_changes: true) |
| 144 | + end |
| 145 | + end |
| 146 | +end |
0 commit comments