Skip to content

Commit

Permalink
add the test file
Browse files Browse the repository at this point in the history
  • Loading branch information
ATOUIYakoub committed Sep 15, 2024
1 parent 1bbe82b commit 0e769aa
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 2 deletions.
Binary file modified analytics/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified analytics/__pycache__/admin.cpython-312.pyc
Binary file not shown.
Binary file modified analytics/__pycache__/apps.cpython-312.pyc
Binary file not shown.
Binary file modified analytics/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file modified analytics/__pycache__/serializers.cpython-312.pyc
Binary file not shown.
Binary file modified analytics/__pycache__/views.cpython-312.pyc
Binary file not shown.
Binary file modified analytics/migrations/__pycache__/0001_initial.cpython-312.pyc
Binary file not shown.
Binary file modified analytics/migrations/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
36 changes: 34 additions & 2 deletions analytics/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
from django.test import TestCase
from django.test import TestCase, Client
from django.urls import reverse
import json
from unittest.mock import patch

# Create your tests here.
class HubSpotIntegrationTest(TestCase):
def setUp(self):
self.client = Client()
self.update_url = reverse('update_hubspot_lead', kwargs={'pk': '36659094211'})
self.valid_payload = {
"properties": {
"firstname": "new_firstname",
"lastname": "new_lastname"
}
}

@patch('analytics.views.update_hubspot_lead')
def test_update_hubspot_lead(self, mock_update_hubspot_lead):
mock_update_hubspot_lead.return_value.status_code = 200
mock_update_hubspot_lead.return_value.json.return_value = {
"properties": {
"firstname": "new_firstname",
"lastname": "new_lastname"
}
}

response = self.client.put(
self.update_url,
data=json.dumps(self.valid_payload),
content_type='application/json'
)

self.assertEqual(response.status_code, 200)
self.assertIn('new_firstname', response.json()['results'][0]['firstname'])
self.assertIn('new_lastname', response.json()['results'][0]['lastname'])
Binary file modified crm_analytics/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified crm_analytics/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file modified crm_analytics/settings/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified crm_analytics/settings/__pycache__/base.cpython-312.pyc
Binary file not shown.
Binary file modified crm_analytics/settings/__pycache__/local.cpython-312.pyc
Binary file not shown.

0 comments on commit 0e769aa

Please sign in to comment.