コード例 #1
0
    def test_all_JSON_functionality(self):
        json = JSON_Interface()
        string = json.from_JSON('test_input.txt')
        json.create_events_from_JSON_string(string, self.db)

        convert = JSON_Interface()

        converted = convert.all_events_from_DB_to_JSON(self.db)
        f = open("test_output.txt", 'w')
        f.write(converted)
        f.close()
コード例 #2
0
	def test_all_JSON_functionality(self):
		json = JSON_Interface()
		string = json.from_JSON('test_input.txt')
		json.create_events_from_JSON_string(string, self.db)

		convert = JSON_Interface()

		converted = convert.all_events_from_DB_to_JSON(self.db)
		f = open("test_output.txt", 'w')
		f.write(converted)
		f.close()
コード例 #3
0
    def test_add_entry_from_JSON(self):
        json = JSON_Interface()
        string = json.from_JSON('test_input.txt')
        json.create_events_from_JSON_string(string, self.db)

        events_on_day = self.db.get_all_events_for_zone(1)

        self.assertEqual(events_on_day[0].start_time, 1.0)
        self.assertEqual(events_on_day[0].stop_time, 2.0)
        self.assertEqual(events_on_day[0].day, 'Monday')
        self.assertEqual(events_on_day[0].owner, 1)
        self.assertEqual(events_on_day[1].start_time, 1.5)
        self.assertEqual(events_on_day[1].stop_time, 2.5)
        self.assertEqual(events_on_day[1].day, 'Monday')
        self.assertEqual(events_on_day[1].owner, 1)
        self.assertEqual(events_on_day[2].start_time, 2.0)
        self.assertEqual(events_on_day[2].stop_time, 3.0)
        self.assertEqual(events_on_day[2].day, 'Monday')
        self.assertEqual(events_on_day[2].owner, 1)
        self.assertEqual(events_on_day[3].start_time, 3.0)
        self.assertEqual(events_on_day[3].stop_time, 4.0)
        self.assertEqual(events_on_day[3].day, 'Monday')
        self.assertEqual(events_on_day[3].owner, 1)

        events_on_day = self.db.get_all_events_for_zone(2)

        self.assertEqual(events_on_day[0].start_time, 1.0)
        self.assertEqual(events_on_day[0].stop_time, 2.0)
        self.assertEqual(events_on_day[0].day, 'Monday')
        self.assertEqual(events_on_day[0].owner, 2)
        self.assertEqual(events_on_day[1].start_time, 1.5)
        self.assertEqual(events_on_day[1].stop_time, 2.5)
        self.assertEqual(events_on_day[1].day, 'Monday')
        self.assertEqual(events_on_day[1].owner, 2)
        self.assertEqual(events_on_day[2].start_time, 2.0)
        self.assertEqual(events_on_day[2].stop_time, 3.0)
        self.assertEqual(events_on_day[2].day, 'Monday')
        self.assertEqual(events_on_day[2].owner, 2)
        self.assertEqual(events_on_day[3].start_time, 3.0)
        self.assertEqual(events_on_day[3].stop_time, 4.0)
        self.assertEqual(events_on_day[3].day, 'Monday')
        self.assertEqual(events_on_day[3].owner, 2)

        events_on_day = self.db.get_all_events_for_zone(3)

        self.assertEqual(events_on_day[0].start_time, 1.0)
        self.assertEqual(events_on_day[0].stop_time, 2.0)
        self.assertEqual(events_on_day[0].day, 'Monday')
        self.assertEqual(events_on_day[0].owner, 3)
        self.assertEqual(events_on_day[1].start_time, 1.5)
        self.assertEqual(events_on_day[1].stop_time, 2.5)
        self.assertEqual(events_on_day[1].day, 'Monday')
        self.assertEqual(events_on_day[1].owner, 3)
        self.assertEqual(events_on_day[2].start_time, 2.0)
        self.assertEqual(events_on_day[2].stop_time, 3.0)
        self.assertEqual(events_on_day[2].day, 'Monday')
        self.assertEqual(events_on_day[2].owner, 3)
        self.assertEqual(events_on_day[3].start_time, 3.0)
        self.assertEqual(events_on_day[3].stop_time, 4.0)
        self.assertEqual(events_on_day[3].day, 'Monday')
        self.assertEqual(events_on_day[3].owner, 3)
コード例 #4
0
	def test_add_entry_from_JSON(self):
		json = JSON_Interface()
		string = json.from_JSON('test_input.txt')
		json.create_events_from_JSON_string(string, self.db)

		events_on_day = self.db.get_all_events_for_zone(1)

		self.assertEqual(events_on_day[0].start_time, 1.0)
		self.assertEqual(events_on_day[0].stop_time, 2.0)
		self.assertEqual(events_on_day[0].day, 'Monday')
		self.assertEqual(events_on_day[0].owner, 1)
		self.assertEqual(events_on_day[1].start_time, 1.5)
		self.assertEqual(events_on_day[1].stop_time, 2.5)
		self.assertEqual(events_on_day[1].day, 'Monday')
		self.assertEqual(events_on_day[1].owner, 1)
		self.assertEqual(events_on_day[2].start_time, 2.0)
		self.assertEqual(events_on_day[2].stop_time, 3.0)
		self.assertEqual(events_on_day[2].day, 'Monday')
		self.assertEqual(events_on_day[2].owner, 1)
		self.assertEqual(events_on_day[3].start_time, 3.0)
		self.assertEqual(events_on_day[3].stop_time, 4.0)
		self.assertEqual(events_on_day[3].day, 'Monday')
		self.assertEqual(events_on_day[3].owner, 1)

		events_on_day = self.db.get_all_events_for_zone(2)

		self.assertEqual(events_on_day[0].start_time, 1.0)
		self.assertEqual(events_on_day[0].stop_time, 2.0)
		self.assertEqual(events_on_day[0].day, 'Monday')
		self.assertEqual(events_on_day[0].owner, 2)
		self.assertEqual(events_on_day[1].start_time, 1.5)
		self.assertEqual(events_on_day[1].stop_time, 2.5)
		self.assertEqual(events_on_day[1].day, 'Monday')
		self.assertEqual(events_on_day[1].owner, 2)
		self.assertEqual(events_on_day[2].start_time, 2.0)
		self.assertEqual(events_on_day[2].stop_time, 3.0)
		self.assertEqual(events_on_day[2].day, 'Monday')
		self.assertEqual(events_on_day[2].owner, 2)
		self.assertEqual(events_on_day[3].start_time, 3.0)
		self.assertEqual(events_on_day[3].stop_time, 4.0)
		self.assertEqual(events_on_day[3].day, 'Monday')
		self.assertEqual(events_on_day[3].owner, 2)

		events_on_day = self.db.get_all_events_for_zone(3)

		self.assertEqual(events_on_day[0].start_time, 1.0)
		self.assertEqual(events_on_day[0].stop_time, 2.0)
		self.assertEqual(events_on_day[0].day, 'Monday')
		self.assertEqual(events_on_day[0].owner, 3)
		self.assertEqual(events_on_day[1].start_time, 1.5)
		self.assertEqual(events_on_day[1].stop_time, 2.5)
		self.assertEqual(events_on_day[1].day, 'Monday')
		self.assertEqual(events_on_day[1].owner, 3)
		self.assertEqual(events_on_day[2].start_time, 2.0)
		self.assertEqual(events_on_day[2].stop_time, 3.0)
		self.assertEqual(events_on_day[2].day, 'Monday')
		self.assertEqual(events_on_day[2].owner, 3)
		self.assertEqual(events_on_day[3].start_time, 3.0)
		self.assertEqual(events_on_day[3].stop_time, 4.0)
		self.assertEqual(events_on_day[3].day, 'Monday')
		self.assertEqual(events_on_day[3].owner, 3)