This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('Verify API response time', async ({ request }) => { | |
const response = await request.get('/users/1'); | |
expect(response.status()).toBe(200); | |
expect(response.timing().responseEnd - response.timing().requestStart).toBeLessThan(500); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('Validate user data', async ({ request }) => { | |
const response = await request.get('/users/1'); | |
expect(response.status()).toBe(200); | |
const responseBody = await response.json(); | |
expect(responseBody).toHaveProperty('id'); | |
expect(responseBody).toHaveProperty('name'); | |
expect(responseBody.name).toBe('John Updated'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('Delete a user', async ({ request }) => { | |
const response = await request.delete('/users/1'); | |
expect(response.status()).toBe(204); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('Partially update user details', async ({ request }) => { | |
const response = await request.patch('/users/1', { | |
data: { | |
job: 'Lead Engineer' | |
} | |
}); | |
expect(response.status()).toBe(200); | |
const responseBody = await response.json(); | |
console.log(responseBody); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('Update user details', async ({ request }) => { | |
const response = await request.put('/users/1', { | |
data: { | |
name: 'John Updated', | |
job: 'Senior Engineer' | |
} | |
}); | |
expect(response.status()).toBe(200); | |
const responseBody = await response.json(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('Fetch user details', async ({ request }) => { | |
const response = await request.get('/users/1'); | |
expect(response.status()).toBe(200); | |
const responseBody = await response.json(); | |
console.log(responseBody); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { test, expect } from '@playwright/test'; | |
test('Create a new user', async ({ request }) => { | |
const response = await request.post('/users', { | |
data: { | |
name: 'John Doe', | |
job: 'Software Engineer' | |
} | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
logging.basicConfig(level=logging.INFO) | |
def safe_run(agent, query): | |
try: | |
return agent.run(query) | |
except Exception as e: | |
logging.error(f"Error while processing query '{query}': {e}") | |
return "An error occurred. Please try again." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain.memory import ConversationBufferMemory | |
# Create a memory instance to store the conversation context. | |
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True) | |
# Initialize an agent with memory integration. | |
agent_with_memory = initialize_agent( | |
tools=tools, | |
llm=llm, | |
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain.tools import BaseTool | |
import math | |
class CalculatorTool(BaseTool): | |
"""A tool for performing basic arithmetic operations.""" | |
name = "calculator" | |
description = "Performs arithmetic calculations given a mathematical expression." | |
def _run(self, expression: str): |
NewerOlder