Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start adding unit tests #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions requirements.testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
pytest-cov
pytest-runner
50 changes: 50 additions & 0 deletions tests/test_pki_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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(), '[]')

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(), '[]')

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(), '[]')