help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
weather-chatbot
/
tests
RSK World
weather-chatbot
Weather Chatbot - Python + Flask + OpenWeatherMap + OpenAI + Weather Forecast + Weather Alerts + Natural Language Processing
tests
  • __init__.py110 B
  • conftest.py1.3 KB
  • test_app.py3.3 KB
  • test_utils.py1.8 KB
  • test_weather_api.py1.6 KB
.gitkeeptest_utils.py
sessions/.gitkeep
Raw Download
Find: Go to:
# Sessions directory
# This file ensures the sessions directory is tracked by git
3 lines•84 B
text
tests/test_utils.py
Raw Download
Find: Go to:
#!/usr/bin/env python3
"""
Utility Functions Tests
=======================

Author: RSK World (https://rskworld.in)
Year: 2026

Description: Unit tests for utility functions
"""

import pytest
import sys
import os

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from utils.weather_utils import (
    format_temperature,
    format_wind_speed,
    get_weather_emoji,
    validate_city_name,
    extract_city_from_query
)

def test_format_temperature():
    """Test temperature formatting."""
    assert format_temperature(20, 'metric') == '20°C'
    assert format_temperature(20, 'imperial') == '68°F'
    assert format_temperature(20, 'kelvin') == '293K'

def test_format_wind_speed():
    """Test wind speed formatting."""
    assert 'm/s' in format_wind_speed(10, 'metric')
    assert 'mph' in format_wind_speed(10, 'imperial')

def test_get_weather_emoji():
    """Test weather emoji selection."""
    assert get_weather_emoji('clear sky') == '☀️'
    assert get_weather_emoji('cloudy') == '☁️'
    assert get_weather_emoji('rain') == '🌧️'
    assert get_weather_emoji('snow') == '❄️'

def test_validate_city_name():
    """Test city name validation."""
    assert validate_city_name('London') == True
    assert validate_city_name('New York') == True
    assert validate_city_name('') == False
    assert validate_city_name('A') == False
    assert validate_city_name('123') == False

def test_extract_city_from_query():
    """Test city extraction from queries."""
    assert extract_city_from_query('weather in London') == 'London'
    assert extract_city_from_query('What is the weather in New York?') == 'New York'
    assert extract_city_from_query('forecast for Paris') == 'Paris'
57 lines•1.8 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer