DeployTest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
dl 0
loc 30
rs 10
c 4
b 1
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 2 1
A test_get_yaml() 0 4 1
A setUp() 0 2 1
A test_get_wildcards() 0 3 1
A test_append_extension() 0 6 2
A test_copy_and_replace() 0 7 2
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