From 8c92d22febd29f89cba4fa1d5fb928dd46a434b5 Mon Sep 17 00:00:00 2001 From: Abdullah Selek Date: Thu, 4 Jan 2018 17:33:07 +0100 Subject: [PATCH 1/4] Add dependency list for unit tests * pip install -r requirements.testing.txt --- requirements.testing.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 requirements.testing.txt diff --git a/requirements.testing.txt b/requirements.testing.txt new file mode 100644 index 0000000..466a229 --- /dev/null +++ b/requirements.testing.txt @@ -0,0 +1,3 @@ +pytest +pytest-cov +pytest-runner From 85a8fe72b417ce6fdd3b809c4e6ce9d1aec1b781 Mon Sep 17 00:00:00 2001 From: Abdullah Selek Date: Thu, 4 Jan 2018 17:57:59 +0100 Subject: [PATCH 2/4] Add unit tests for pki_builder * As I see IyzipayResource is not public so I started adding tests for pki_builder. * To run the tests `py.test -s -v` --- tests/test_pki_builder.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_pki_builder.py diff --git a/tests/test_pki_builder.py b/tests/test_pki_builder.py new file mode 100644 index 0000000..f5559f3 --- /dev/null +++ b/tests/test_pki_builder.py @@ -0,0 +1,19 @@ +import unittest +import iyzipay + +class PKIBuilderTest(unittest.TestCase): + + def test_append_when_value_available(self): + pki_builder = iyzipay.PKIBuilder('') + pki_builder.append('key', 'value') + self.assertEqual(pki_builder.get_request_string(), '[key=value]') + + def test_append_when_value_not_available(self): + pki_builder = iyzipay.PKIBuilder('') + pki_builder.append('key') + self.assertEqual(pki_builder.get_request_string(), '[]') + + def test_append_when_value_empty(self): + pki_builder = iyzipay.PKIBuilder('') + pki_builder.append('key', '') + self.assertEqual(pki_builder.get_request_string(), '[]') From daa497880927d0974e06f7c9f67c27ac2da9cf06 Mon Sep 17 00:00:00 2001 From: Abdullah Selek Date: Thu, 4 Jan 2018 18:07:25 +0100 Subject: [PATCH 3/4] Add tests for append_price --- tests/test_pki_builder.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_pki_builder.py b/tests/test_pki_builder.py index f5559f3..6b57ba0 100644 --- a/tests/test_pki_builder.py +++ b/tests/test_pki_builder.py @@ -17,3 +17,18 @@ def test_append_when_value_empty(self): pki_builder = iyzipay.PKIBuilder('') pki_builder.append('key', '') self.assertEqual(pki_builder.get_request_string(), '[]') + + def test_append_price_when_value_available(self): + pki_builder = iyzipay.PKIBuilder('') + pki_builder.append_price('price', 100) + self.assertEqual(pki_builder.get_request_string(), '[price=100.0]') + + def test_append_price_when_value_not_available(self): + pki_builder = iyzipay.PKIBuilder('') + pki_builder.append_price('price') + self.assertEqual(pki_builder.get_request_string(), '[]') + + def test_append_price_when_value_empty(self): + pki_builder = iyzipay.PKIBuilder('') + pki_builder.append_price('price', '') + self.assertEqual(pki_builder.get_request_string(), '[]') From dfd77485845211476511d053ecdbb33ea75da709 Mon Sep 17 00:00:00 2001 From: Abdullah Selek Date: Thu, 4 Jan 2018 18:42:58 +0100 Subject: [PATCH 4/4] Add tests for append_array --- tests/test_pki_builder.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_pki_builder.py b/tests/test_pki_builder.py index 6b57ba0..5b983b1 100644 --- a/tests/test_pki_builder.py +++ b/tests/test_pki_builder.py @@ -32,3 +32,19 @@ def test_append_price_when_value_empty(self): pki_builder = iyzipay.PKIBuilder('') pki_builder.append_price('price', '') self.assertEqual(pki_builder.get_request_string(), '[]') + + def test_append_array_when_value_available(self): + enabledInstallments = ['2', '3', '6', '9'] + pki_builder = iyzipay.PKIBuilder('') + pki_builder.append_array('data', enabledInstallments) + self.assertEqual(pki_builder.get_request_string(), '[data=[2, 3, 6, 9]]') + + def test_append_array_when_value_not_available(self): + pki_builder = iyzipay.PKIBuilder('') + pki_builder.append_array('data') + self.assertEqual(pki_builder.get_request_string(), '[]') + + def test_append_array_when_value_empty(self): + pki_builder = iyzipay.PKIBuilder('') + pki_builder.append_array('data', []) + self.assertEqual(pki_builder.get_request_string(), '[]')