예제 #1
0
class TestCity(unittest.TestCase):
    """Tests the city class"""
    def setUp(self):
        self._city = City()

    def test_name(self):
        """Tests setter and getter of name of a city"""
        name = "City"
        self._city.set_name(name)
        self.assertEqual(self._city.get_name(), name)
예제 #2
0
def main():
    """Main function to be called when executing the script"""

    franks_city = City().set_name('City')
    franks_address = Address()\
        .set_street('Sample street')\
        .set_zip('01234')\
        .set_city(franks_city)

    frank = Person().set_first_name('Frank')\
        .set_last_name('Lastname')\
        .set_address(franks_address)

    print str(frank)
예제 #3
0
    def test_string_casting(self):
        """Tests casting of an Address object"""
        street = "Mystreet 1"
        zip_number = "12345"
        city = City().set_name("City")

        self._address.set_street(street)
        self._address.set_zip(zip_number)
        self._address.set_city(city)

        expected_output = "%s\n%s %s" % (
            self._address.get_street(),
            self._address.get_zip(),
            self._address.get_city()
        )

        self.assertEqual(str(self._address), expected_output)
예제 #4
0
 def setUp(self):
     self._city = City()
예제 #5
0
 def test_city(self):
     """Tests setter and getter of city of an address"""
     city = City()
     self._address.set_city(city)
     self.assertIsInstance(self._address.get_city(), City)