from django.test import TestCase
from rest_framework.test import APIClient
from rest_framework import status
+from requests.auth import HTTPBasicAuth
from catalog.packages.biz.nsdm_subscription import NsdmSubscription
from catalog.pub.database.models import NsdmSubscriptionModel
class TestNsdmSubscription(TestCase):
-
def setUp(self):
self.client = APIClient()
NsdmSubscriptionModel.objects.all().delete()
response.data["callbackUri"])
expected_data = {
'status': 303,
- 'detail': 'Already Subscription exists with'
+ 'detail': 'Subscription has already existed with'
' the same callbackUri and filter'
}
response = self.client.post("/api/nsd/v1/subscriptions",
expected_data = {
"status": 404,
"detail": "Subscription(" + self.subscription_id + ") "
- "doesn't exists"
+ "doesn't exist"
}
response = self.client.get('/api/nsd/v1/'
'subscriptions/' + self.subscription_id,
}
}
}
- mock_requests_post.assert_called_with(expect_callbackuri, data=expect_notification, headers={'Connection': 'close'})
+ mock_requests_post.assert_called_with(expect_callbackuri, data=expect_notification,
+ auth=HTTPBasicAuth("username", "password"),
+ headers={'Connection': 'close',
+ 'content-type': 'application/json',
+ 'accept': 'application/json'},
+ verify=False)
class NotificationTest(TestCase):
}
}
}
- mock_requests_post.assert_called_with(expect_callbackuri, data=expect_notification, headers={'Connection': 'close'})
+ mock_requests_post.assert_called_with(expect_callbackuri,
+ data=expect_notification,
+ headers={'Connection': 'close',
+ 'content-type': 'application/json',
+ 'accept': 'application/json'},
+ verify=False
+ )
@mock.patch("requests.post")
@mock.patch("uuid.uuid4")
}
}
mock_requests_post.assert_called_with(expect_callbackuri, data=expect_notification,
- headers={'Connection': 'close'})
+ headers={'Connection': 'close',
+ 'content-type': 'application/json',
+ 'accept': 'application/json'},
+ verify=False)