예제 #1
0
파일: event.py 프로젝트: dooma/Events
 def __init__(self, filename = 'event.json'):
     '''
     EventRepository class constructor
     :param filename: Default value 'event.json'
     :return:
     '''
     self.__datafile = filename
     Event.set_class_id(self.get_max_id())
예제 #2
0
파일: test_event.py 프로젝트: dooma/Events
    def test_get_max_id(self):
        Event.set_class_id(0)
        io = IO('test.json')
        io.set([])
        repo = EventRepository('test.json')
        self.assertEqual(repo.get_max_id(), 0)
        content = repo.get_all()
        self.assertEqual(content, [])

        event1 = Event('14/01/2015', '14:00', 'Colectiv')
        event2 = Event('14/01/2015', '14:00', 'Colectiv')
        repo.insert(event1)
        repo.insert(event2)

        content = repo.get_all()
        self.assertEqual(repo.get_max_id(), 2)
예제 #3
0
파일: test_event.py 프로젝트: dooma/Events
    def test_delete(self):
        Event.set_class_id(0)
        io = IO('test.json')
        io.set([])
        repo = EventRepository('test.json')

        event1 = Event('14/01/2015', '14:00', 'Colectiv')
        event2 = Event('14/01/2015', '14:00', 'Colectiv')
        repo.insert(event1)
        repo.insert(event2)

        event = repo.get(0)
        self.assertIs(type(event), Event)

        repo.delete(event)

        with self.assertRaisesRegex(ValueError, 'Event not found!'):
            updated_event = repo.get(0)
예제 #4
0
파일: test_event.py 프로젝트: dooma/Events
    def test_get(self):
        Event.set_class_id(0)
        io = IO('test.json')
        io.set([])
        repo = EventRepository('test.json')

        event1 = Event('14/01/2015', '14:00', 'Colectiv')
        event2 = Event('14/01/2015', '14:00', 'Colectiv')
        repo.insert(event1)
        repo.insert(event2)

        content = repo.get(0)
        self.assertIs(type(content), Event)

        self.assertEqual(content.get_date(), '14/01/2015')
        self.assertEqual(content.get_time(), '14:00')
        self.assertEqual(content.get_description(), 'Colectiv')

        with self.assertRaisesRegex(ValueError, 'Event not found!'):
            content = repo.get(10)
예제 #5
0
파일: test_event.py 프로젝트: dooma/Events
    def test_update(self):
        Event.set_class_id(0)
        io = IO('test.json')
        io.set([])
        repo = EventRepository('test.json')

        event1 = Event('14/01/2015', '14:00', 'Colectiv')
        event2 = Event('14/01/2015', '14:00', 'Colectiv')
        repo.insert(event1)
        repo.insert(event2)

        event = repo.get(0)
        self.assertIs(type(event), Event)
        event.update('15/01/2015', '15:00', 'Untold festival')

        repo.update(event)

        updated_event = repo.get(0)

        self.assertEqual(updated_event.get_date(), '15/01/2015')
        self.assertEqual(updated_event.get_time(), '15:00')
        self.assertEqual(updated_event.get_description(), 'Untold festival')