From e938d88209861f51d00859da9582d87773076a7b Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Dec 2020 15:30:40 +0100 Subject: [PATCH] Add pyvenv acceptance test Co-authored-by: Ewoud Kohl van Wijngaarden --- spec/acceptance/pyvenv_spec.rb | 146 +++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 spec/acceptance/pyvenv_spec.rb diff --git a/spec/acceptance/pyvenv_spec.rb b/spec/acceptance/pyvenv_spec.rb new file mode 100644 index 00000000..1b9ad1f3 --- /dev/null +++ b/spec/acceptance/pyvenv_spec.rb @@ -0,0 +1,146 @@ +require 'spec_helper_acceptance' + +describe 'python::pyvenv defined resource' do + context 'minimal parameters' do + # Using puppet_apply as a helper + it 'works with no errors' do + pp = <<-PUPPET + class { 'python': + version => '3', + dev => 'present', + } + user { 'agent': + ensure => 'present', + managehome => true, + home => '/opt/agent', + } + group { 'agent': + ensure => 'present', + system => true, + } + python::pyvenv { '/opt/agent/venv': + ensure => 'present', + systempkgs => true, + owner => 'agent', + group => 'agent', + mode => '0755', + } + PUPPET + + # Run it twice and test for idempotency + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + end + + context 'with python::pip' do + it 'works with no errors' do + pp = <<-PUPPET + class { 'python': + version => '3', + dev => 'present', + } + user { 'agent': + ensure => 'present', + managehome => true, + home => '/opt/agent', + } + group { 'agent': + ensure => 'present', + system => true, + } + python::pyvenv { '/opt/agent/venv': + ensure => 'present', + systempkgs => true, + owner => 'agent', + group => 'agent', + mode => '0755', + } + python::pip { 'agent' : + ensure => 'latest', + pkgname => 'agent', + pip_provider => 'pip', + virtualenv => '/opt/agent/venv', + owner => 'agent', + group => 'agent', + } + PUPPET + + # Run it twice and test for idempotency + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + end + + context 'with minimal python::pip' do + it 'works with no errors' do + pp = <<-PUPPET + class { 'python': + version => '3', + dev => 'present', + } + user { 'agent': + ensure => 'present', + managehome => true, + home => '/opt/agent', + } + group { 'agent': + ensure => 'present', + system => true, + } + python::pyvenv { '/opt/agent/venv': + ensure => 'present', + systempkgs => true, + owner => 'agent', + group => 'agent', + mode => '0755', + } + python::pip { 'agent' : + virtualenv => '/opt/agent/venv', + owner => 'agent', + group => 'agent', + } + PUPPET + + # Run it twice and test for idempotency + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + end + + context 'with minimal python::pip and without systempkgs' do + it 'works with no errors' do + pp = <<-PUPPET + class { 'python': + version => '3', + dev => 'present', + } + user { 'agent': + ensure => 'present', + managehome => true, + home => '/opt/agent', + } + group { 'agent': + ensure => 'present', + system => true, + } + python::pyvenv { '/opt/agent/venv': + ensure => 'present', + systempkgs => false, + owner => 'agent', + group => 'agent', + mode => '0755', + } + python::pip { 'agent' : + virtualenv => '/opt/agent/venv', + owner => 'agent', + group => 'agent', + } + PUPPET + + # Run it twice and test for idempotency + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + end +end