From c1d367b89a95277b25c8e3cffc0b82fb4d081fa0 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 28 Jun 2021 12:18:30 +0300 Subject: Add a diffing function For now the diff function uses the Linux tool "diff" to generate the diff since it is efficient and straightforward. * gn3/computations/diff.py (generate_diff): New function. * tests/unit/computations/test_diff.py: Test cases for ☝🏾. --- tests/unit/computations/test_diff.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/unit/computations/test_diff.py (limited to 'tests/unit') diff --git a/tests/unit/computations/test_diff.py b/tests/unit/computations/test_diff.py new file mode 100644 index 0000000..e4f5dde --- /dev/null +++ b/tests/unit/computations/test_diff.py @@ -0,0 +1,28 @@ +"""This contains unit-tests for gn3.computations.diff""" +import unittest +import os + +from gn3.computations.diff import generate_diff + +TESTDIFF = """3,4c3,4 +< C57BL/6J,x,x,x +< BXD1,18.700,x,x +--- +> C57BL/6J,19.000,x,x +> BXD1,15.700,x,x +6c6 +< BXD11,18.900,x,x +--- +> BXD11,x,x,x +""" + + +class TestDiff(unittest.TestCase): + """Test cases for computations.diff""" + def test_generate_diff(self): + """Test that the correct diff is generated""" + data = os.path.join(os.path.dirname(__file__).split("unit")[0], + "test_data/trait_data_10007.csv") + edited_data = os.path.join(os.path.dirname(__file__).split("unit")[0], + "test_data/edited_trait_data_10007.csv") + self.assertEqual(generate_diff(data, edited_data), TESTDIFF) -- cgit v1.2.3