def setUp(self): validator = Validator() self.person = Person("id", "name", Address("city", "street", "number")) event = Event("id", Date("12", "month", "2019"), "duration", "description") self.attendance = Attendance("id", "id", "id") self.repo = AttendanceRepo(validator, [self.attendance])
def test_validate_event_from_repo(self): e = Event("id", Date([], "street", "year"), "duration", "description") el = [] self.assertRaises(InvalidEventDataException, self.validator.validate_event_from_repo, el, e) el = [e] self.assertRaises(ExistentIdException, self.validator.validate_event_from_repo, el, e)
def read_event(self): self.write("\nPlease input an event's data: ") person = Event( self.read("Id: "), Date(self.read("Date:\n Day: "), self.read(" Month: "), self.read(" Year: ")), self.read("Duration: "), self.read("Description: ")) return person
def _random_event(self): from EventOrganiser.framework.randomization import Random rand = Random() event = Event( rand.string_of_chr(10), Date(rand.string_of_int(2), rand.string_of_chr(10), rand.string_of_int(4)), rand.string_of_chr(10), rand.string_of_chr(10)) return event
def load_from_file(self): file = open(self.file_name, "r") try: file_string = file.read() data = self.json.loads(file_string) events = [] for data_event in data: events.append( Event( data_event["id"], Date(data_event["date"]["day"], data_event["date"]["month"], data_event["date"]["year"]), data_event["duration"], data_event["description"])) self.items = events file.close() except Exception as ex: file.close() raise Exception(ex)
def test_validate_attendance(self): p = Person("id", 1234, Address("5678", "street", "number")) e = Event("id", Date([], "street", "year"), "duration", "description") a = Attendance("id", "id1", "id2") self.assertRaises(InvalidAttendanceDataException, self.validator.validate_attendance, [p], [e], a)
def test_validate_event(self): e = Event("id", Date([], "street", "year"), "duration", "description") self.assertRaises(InvalidEventDataException, self.validator.validate_event, e)
def setUp(self): validator = Validator() self.event = Event("id", Date("12", "month", "2019"), "duration", "description") self.repo = EventRepo(validator, [self.event])
def setUp(self): self.address = Date("08", "september", "2000")
def test_equal(self): e = Event("id", Date("1", "month", "2000"), "duration", "description") self.assertTrue(self.event == e)
def setUp(self): self.date = Date("1", "month", "2000") self.event = Event("id", self.date, "duration", "description")