示例#1
0
 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])
示例#2
0
 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)
示例#3
0
 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
示例#4
0
 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
示例#5
0
    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)
示例#6
0
 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)
示例#7
0
 def test_validate_event(self):
     e = Event("id", Date([], "street", "year"), "duration", "description")
     self.assertRaises(InvalidEventDataException,
                       self.validator.validate_event, e)
示例#8
0
 def setUp(self):
     validator = Validator()
     self.event = Event("id", Date("12", "month", "2019"), "duration",
                        "description")
     self.repo = EventRepo(validator, [self.event])
示例#9
0
 def setUp(self):
     self.address = Date("08", "september", "2000")
示例#10
0
 def test_equal(self):
     e = Event("id", Date("1", "month", "2000"), "duration", "description")
     self.assertTrue(self.event == e)
示例#11
0
 def setUp(self):
     self.date = Date("1", "month", "2000")
     self.event = Event("id", self.date, "duration", "description")