1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
import os |
3
|
|
|
import unittest |
4
|
|
|
from oe_utils.deploy import * |
5
|
|
|
|
6
|
|
|
here = os.path.dirname(os.path.abspath(__file__)) |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
class DeployTest(unittest.TestCase): |
10
|
|
|
def setUp(self): |
11
|
|
|
pass |
12
|
|
|
|
13
|
|
|
def tearDown(self): |
14
|
|
|
pass |
15
|
|
|
|
16
|
|
|
def test_get_yaml(self): |
17
|
|
|
get_yaml(os.path.join(here, 'fixtures', 'input.ini')) |
18
|
|
|
res = get_yaml(os.path.join(here, 'fixtures', 'wildcards.yaml')) |
19
|
|
|
self.assertEqual({'variables': {'variabele': {'correct': 'True@'}}}, res) |
20
|
|
|
|
21
|
|
|
def test_get_wildcards(self): |
22
|
|
|
res = get_wildcards(os.path.join(here, 'fixtures', 'wildcards.yaml')) |
23
|
|
|
self.assertIn(('correct', 'True@'), res) |
24
|
|
|
|
25
|
|
|
def test_copy_and_replace(self): |
26
|
|
|
mapping = get_wildcards(os.path.join(here, 'fixtures', 'wildcards.yaml')) |
27
|
|
|
copy_and_replace(os.path.join(here, 'fixtures', 'input.ini'), os.path.join(here, 'fixtures', 'output.ini'), |
28
|
|
|
mapping, separator='@@') |
29
|
|
|
with open(os.path.join(here, 'fixtures', 'output.ini'), "r") as in_file: |
30
|
|
|
res = in_file.readlines() |
31
|
|
|
self.assertIn(u'correct = True@', res) |
32
|
|
|
|
33
|
|
|
def test_append_extension(self): |
34
|
|
|
append_extension(os.path.join(here, 'fixtures', 'output2.ini'), os.path.join(here, 'fixtures', 'outputext.ini'), |
35
|
|
|
'een test toevoeging') |
36
|
|
|
with open(os.path.join(here, 'fixtures', 'outputext.ini'), "r") as in_file: |
37
|
|
|
res = in_file.readlines() |
38
|
|
|
self.assertIn('een test toevoeging\n', res) |
39
|
|
|
|