Question: from copy import deepcopy import unittest from booking _ system import get _ most _ popular _ countries as get _ mpcs class TestGetMostPopularCountries (

from copy import deepcopy
import unittest
from booking_system import get_most_popular_countries as get_mpcs
class TestGetMostPopularCountries(unittest.TestCase):
"""Test the function get_most_popular_countries."""
def setUp(self):
self.example ={
'137': {
'identifier': '137',
'headline': 'Beautiful 4-bedroom home on lakeside',
'listed': '2024-07-17',
'features': ['4 bedroom', '3 bath', 'Pool'],
'location': ('New York', 'USA'),
'description': 'This is a beautiful 4-bedroom, 3-bath detached'
' house
with an outdoor pool.'},
'001': {
'identifier': '001',
'headline': 'House',
'listed': None,
'features': ['clean'],
'location': ('Hamilton', 'Canada'),
'description': None},
'05': {
'identifier': '05',
'headline': 'Stunning lakeside cottage',
'listed': '2021-02-08',
'features': [],
'location': ('Oxford','UK'),
'description': 'This is lakeside!'}
}
def test_handout_example(self):
"""Test get_most_popular_countries with the handout example."""
book_sys_copy = deepcopy(self.example)
expected =['Canada','UK', 'USA']
actual = get_mpcs(self.example)
msg = message(book_sys_copy, expected, actual)
self.assertEqual(actual, expected, msg)
# TODO: add a complete test suite here
def message(test_case: dict, expected: list, actual: object)-> str:
"""Return an error message saying the function call
get_most_popular_countries(test_case) resulted in the value
actual, when the correct value is expected.
"""
return ('When we called get_most_popular_countries('+ str(test_case)
+') we expected '+ str(expected)
+', but got '+ str(actual))
if __name__=='__main__':
unittest.main(exit=False)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!