예제 #1
0
class TestCaseEvent(unittest.TestCase):
    def setUp(self):
        self.date = Date("1", "month", "2000")
        self.event = Event("id", self.date, "duration", "description")

    def test_equal(self):
        e = Event("id", Date("1", "month", "2000"), "duration", "description")
        self.assertTrue(self.event == e)

    def test_to_json(self):
        d = {
            "id": "id",
            "date": self.date.to_json(),
            "duration": "duration",
            "description": "description"
        }
        self.assertEqual(self.event.to_json(), d)

    def test_has_field_with_value(self):
        self.assertTrue(self.event.has_field_with_value("id", "id"))
        self.assertFalse(self.event.has_field_with_value("id", "no"))
        self.assertFalse(self.event.has_field_with_value("no", "id"))
        self.assertTrue(self.event.has_field_with_value("month", "month"))
        self.assertFalse(self.event.has_field_with_value("month", "no"))
        self.assertFalse(self.event.has_field_with_value("date", "month"))
예제 #2
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])
예제 #3
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)
예제 #4
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
예제 #5
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
예제 #6
0
class TestCaseDate(unittest.TestCase):
    def setUp(self):
        self.address = Date("08", "september", "2000")

    def test_to_json(self):
        d = {
            "day": "08",
            "month": "september",
            "year": "2000"
        }
        self.assertEqual(self.address.to_json(), d)
예제 #7
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)
예제 #8
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)
예제 #9
0
 def test_validate_event(self):
     e = Event("id", Date([], "street", "year"), "duration", "description")
     self.assertRaises(InvalidEventDataException,
                       self.validator.validate_event, e)
예제 #10
0
 def setUp(self):
     validator = Validator()
     self.event = Event("id", Date("12", "month", "2019"), "duration",
                        "description")
     self.repo = EventRepo(validator, [self.event])
예제 #11
0
 def setUp(self):
     self.address = Date("08", "september", "2000")
예제 #12
0
 def test_equal(self):
     e = Event("id", Date("1", "month", "2000"), "duration", "description")
     self.assertTrue(self.event == e)
예제 #13
0
 def setUp(self):
     self.date = Date("1", "month", "2000")
     self.event = Event("id", self.date, "duration", "description")