def _load(self, name): for line in self._get_file_contents(name): print(line) line = line.split("-") print(line) date = "{}-{}-{}".format(line[0], line[1], line[2].strip()) app = Appointment(line[3].strip(), date) self.add_appointment(app)
class TestAppointments(): def setup(self): self.app = Appointment("World domination", "2014-04-01") def test_get_description(self): ok_("World domination", self.app.get_description()) def test_get_date(self): ok_("2014-04-01", self.app.get_date()) def test_create_datetime(self): expected = datetime.strptime("2014-04-01", "%Y-%m-%d").date() eq_(expected, self.app.create_datetime(self.app.get_date())) def test_occurs_on_false(self): eq_(False, self.app.occurs_on(2012, 5, 6)) def test_occurs_on_true(self): eq_(True, self.app.occurs_on(2014, 4, 1))
class TestAppointments: def setup(self): self.app = Appointment("World domination", "2014-04-01") def test_get_description(self): ok_("World domination", self.app.get_description()) def test_get_date(self): ok_("2014-04-01", self.app.get_date()) def test_create_datetime(self): expected = datetime.strptime("2014-04-01", "%Y-%m-%d").date() eq_(expected, self.app.create_datetime(self.app.get_date())) def test_occurs_on_false(self): eq_(False, self.app.occurs_on(2012, 5, 6)) def test_occurs_on_true(self): eq_(True, self.app.occurs_on(2014, 4, 1))
def create_appointment(self, description, date): # belongs to a higher level interface # description = input("description>") # date = input("date(yyyy-mm-dd)>") return Appointment(description, date)
def setup(self): self.app = Appointment("World domination", "2014-04-01")
def create_appointment(self): description = input("description>") date = input("date(yyyy-mm-dd)>") return Appointment(description, date)