![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
The decorator and context manager to mock and verify HTTP requests made by requests
library for unittest
.
pip install requests-asserts
Make a list of RequestMock
elements that contain all information about the expected request and response.
Use RequestMock.assert_requests(request_mocks)
with the list as a decorator or context manager.
import requests
from unittests import TestCase
def get_likes_on_post(username, password, post_id):
access_token = requests.post(
'http://my.site/login',
json={'username': username, 'password': password}
).json()['access_token']
likes = requests.get(
f'http://my.site/posts/{post_id}',
headers={
'Accept': 'application/json',
'Authorization': f'Bearer {access_token}'
}
).json()['likes']
return likes
class TestGetLikesOnPost(TestCase):
@RequestMock.assert_requests([
RequestMock(
request_url='http://my.site/login',
request_json={'username': 'the name', 'password': 'the password'},
request_method=RequestMock.Method.POST,
response_json={"access_token": 'the-token'}
),
RequestMock(
request_url='http://my.site/posts/3',
request_headers_contains={'Authorization': 'Bearer the-token'},
response_json={'name': 'The cool story', 'likes': 42}
)
])
def test_get_likes_on_post(self):
self.assertEqual(42, get_likes_on_post('the name', 'the password', 3))
FAQs
The library to help test your HTTP requests using unittests
We found that requests-asserts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.