"""
Tests for nap module.

These tests only focus that requests is called properly.
Everything related to HTTP requests should be tested in requests' own tests.
"""

from mock import MagicMock, patch
import unittest
import requests

from nap.api import Api


class NewApi(Api):

    def before_request(self, method, request_kwargs):
        request_kwargs['test'] = 'test'
        return request_kwargs

    def after_request(self, response):
        return None

    def default_kwargs(self):
        # Remove all default kwargs
        return {}


class TestNapInherit(unittest.TestCase):

    @patch('requests.request')
    def test_before_request_and_after_request(self, r_request):
        """Test overriding before_request() and after_request()"""
        api = NewApi('')
        r_request = MagicMock(return_value=1)

        # Make sure defaults are passed for each request
        response = api.resource.get()
        requests.request.assert_called_with(
            'GET',
            '/resource',
            test='test'
        )

        # Mocker will return 1 to after_request and we have modified it
        # to return just None
        self.assertEquals(
            response,
            None,
            'after_request overriding not working'
        )

    @patch('requests.request')
    def test_default_kwargs(self, r_request):
        """Test overriding default_kwargs()"""
        # We give default arguments, but the overriding implementation
        # of default_kwargs() method should throw them away
        api = NewApi('', auth=('user', 'pass'))
        r_request = MagicMock(return_value=1)

        # Make sure defaults were removed from kwargs
        api.resource.get()
        requests.request.assert_called_with(
            'GET',
            '/resource',
            # This will still be in kwargs because manipulation
            # of default_kwargs and request_kwargs are separated
            test='test'
        )

@@ -239,19 +239,19 @@
 nap.
-api
+url
  import 
 Api%0A
@@ -246,19 +246,19 @@
  import 
-Api
+Url
 %0A%0A%0Aclass
@@ -265,15 +265,15 @@
  New
-Api(Api
+Url(Url
 ):%0A%0A
@@ -560,15 +560,22 @@
 tNap
-Inherit
+ExtendBehavior
 (uni
@@ -762,30 +762,47 @@
         
-api
+url
  = New
-Api('
+Url('http://domain.com
 ')%0A     
@@ -919,28 +919,33 @@
 ponse = 
-api.
+url.get('
 resource
 .get()%0A 
@@ -928,37 +928,33 @@
 rl.get('resource
-.get(
+'
 )%0A        reques
@@ -1008,32 +1008,49 @@
 ',%0A            '
+http://domain.com
 /resource',%0A    
@@ -1578,22 +1578,39 @@
     
-api
+url
  = New
-Api('
+Url('http://domain.com
 ', a
@@ -1744,20 +1744,25 @@
     
-api.
+url.get('
 resource
 .get
@@ -1757,21 +1757,17 @@
 resource
-.get(
+'
 )%0A      
@@ -1837,16 +1837,33 @@
        '
+http://domain.com
 /resourc

Fix behavior extend tests according to refactor