"""TestCase for Client class."""
import unittest
from mock import Mock

from playdeliver.client import Client


class TestClientMethods(unittest.TestCase):

    def setUp(self):
        self.service_mock = Mock()
        self.edits_mock = Mock()

        self.service_mock.edits.return_value = self.edits_mock

        self.request_mock = Mock()
        self.edits_mock.insert.return_value = self.request_mock

        self.request_mock.execute.side_effect = [
            {'id': '1'}, {'id': '2'}]

        self.client = Client('com.test.app', self.service_mock)

    def test_build_params_without_editId(self):
        """Test of build params retrurns correct dict."""
        returned_params = self.client.build_params()
        self.assertEqual(
            returned_params, {'editId': None,
                              'packageName': 'com.test.app'})

    def test_build_params_with_editId(self):
        """Test of build params retrurns correct dict."""
        self.client.ensure_edit_id()

        returned_params = self.client.build_params()
        self.assertEqual(
            returned_params, {'editId': '1',
                              'packageName': 'com.test.app'})

    def test_build_params_with_custom_params(self):
        """Test of build params retrurns correct dict."""
        self.client.ensure_edit_id()
        
        returned_params = self.client.build_params({'foo': 'bar'})
        self.assertEqual(
            returned_params, {'editId': '1',
                              'packageName': 'com.test.app',
                              'foo': 'bar'})

    def test_ensure_edit_id(self):
        """Test if edit_id is created once when not set."""

        self.assertEqual(self.client.edit_id, None)

        self.client.ensure_edit_id()

        self.assertEqual(self.client.edit_id, '1')

        self.client.ensure_edit_id()

        self.assertEqual(self.client.edit_id, '1')

        self.client.edit_id = None
        self.client.ensure_edit_id()

        self.assertEqual(self.client.edit_id, '2')

if __name__ == '__main__':
    unittest.main()

@@ -1331,17 +1331,9 @@
 d()%0A
-        
 %0A
+
     
@@ -1668,17 +1668,16 @@
 set.%22%22%22%0A
-%0A
         
@@ -1966,32 +1966,32 @@
 sure_edit_id()%0A%0A
-
         self.ass
@@ -2026,16 +2026,412 @@
 , '2')%0A%0A
+    def test_commit(self):%0A        %22%22%22Test if commit method executes commit.%22%22%22%0A        self.client.ensure_edit_id()%0A%0A        commit_mock = Mock()%0A        self.edits_mock.commit.return_value = commit_mock%0A        commit_mock.execute.return_value = %7B'id': '1'%7D%0A        %0A        self.client.commit()%0A        commit_mock.executes.assertCalled()%0A        self.assertEqual(self.client.edit_id, None)%0A%0A%0A
 if __nam

add test for commit methods