Skip to content

Commit

Permalink
test(base): basic test for merge_software helper
Browse files Browse the repository at this point in the history
!22 #43
  • Loading branch information
jon-nfc committed Jun 7, 2024
1 parent 23c43ed commit b3b5ad6
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions app/app/tests/test_helpers_merge_software.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from django.conf import settings as django_settings
from django.shortcuts import reverse
from django.test import TestCase, Client

from app.helpers.merge_software import merge_software


import pytest
import unittest


class MergeSoftwareHelper(TestCase):
""" tests for function `merge_software` """

@classmethod
def setUpTestData(self):
self.data: dict = {
'first_list': [
{
'name': 'software_1',
'state': 'install'
},
{
'name': 'software_2',
'state': 'install'
}
],
'second_list': [
{
'name': 'software_1',
'state': 'absent'
},
{
'name': 'software_2',
'state': 'absent'
}
],
'third_list': [
{
'name': 'software_1',
'state': 'other'
},
{
'name': 'software_2',
'state': 'other'
},
{
'name': 'software_3',
'state': 'install'
}
]
}

self.software_list_one = merge_software(self.data['first_list'], self.data['second_list'])

self.software_list_two = merge_software(self.software_list_one, self.data['third_list'])


def test_merging_0_0(self):
""" ensure Second list overwrites the first app1 """

assert self.software_list_one[0]['state'] == 'absent'


def test_merging_0_1(self):
""" ensure Second list overwrites the first app2 """

assert self.software_list_one[1]['state'] == 'absent'



def test_merging_1_0(self):
""" ensure Second list overwrites the first app1 again """

assert self.software_list_two[0]['state'] == 'other'


def test_merging_1_1(self):
""" ensure Second list overwrites the first app2 again """

assert self.software_list_two[1]['state'] == 'other'


def test_merging_1_new_list_item(self):
""" ensure Second list overwrites the first app2 again """

assert len(self.software_list_two) == 3

0 comments on commit b3b5ad6

Please sign in to comment.