コード例 #1
0
    def test_single_landing(self):
        db.session.add(self.landing_koenigsdorf_dd0815)
        db.session.commit()

        update_logbook()
        entries = self.get_logbook_entries()
        self.assertEqual(len(entries), 1)
        self.assertEqual(entries[0].takeoff_airport_id, None)
        self.assertEqual(entries[0].landing_airport_id, self.koenigsdorf.id)
コード例 #2
0
    def test_different_takeoffs(self):
        db.session.add(self.takeoff_koenigsdorf_dd0815)
        db.session.add(self.takeoff_ohlstadt_dd4711)
        db.session.commit()

        update_logbook()
        entries = self.get_logbook_entries()
        self.assertEqual(len(entries), 2)
        self.assertEqual(entries[0].takeoff_airport_id, self.koenigsdorf.id)
        self.assertEqual(entries[1].takeoff_airport_id, self.ohlstadt.id)
コード例 #3
0
    def test_takeoff_and_landing_on_different_days(self):
        db.session.add(self.takeoff_koenigsdorf_dd0815)
        db.session.add(self.landing_koenigsdorf_dd0815_later)
        db.session.commit()

        update_logbook()
        entries = self.get_logbook_entries()
        self.assertEqual(len(entries), 2)
        self.assertEqual(entries[0].takeoff_airport_id, self.koenigsdorf.id)
        self.assertEqual(entries[0].reftime,
                         self.takeoff_koenigsdorf_dd0815.timestamp)
        self.assertEqual(entries[1].landing_airport_id, self.koenigsdorf.id)
        self.assertEqual(entries[1].reftime,
                         self.landing_koenigsdorf_dd0815_later.timestamp)
コード例 #4
0
ファイル: logbook.py プロジェクト: Meisterschueler/ogn-python
def compute_logbook(start, end):
    """Compute logbook."""

    days = get_database_days(start, end)

    pbar = tqdm(days)
    for single_date in pbar:
        pbar.set_description(single_date.strftime("%Y-%m-%d"))
        result = update_logbook(date=single_date)
コード例 #5
0
    def test_update_wrong_order(self):
        db.session.add(self.landing_koenigsdorf_dd0815)
        db.session.commit()

        update_logbook()
        entries = self.get_logbook_entries()
        self.assertEqual(len(entries), 1)
        self.assertEqual(entries[0].takeoff_airport_id, None)
        self.assertEqual(entries[0].landing_airport_id, self.koenigsdorf.id)
        self.assertEqual(entries[0].reference_timestamp,
                         self.landing_koenigsdorf_dd0815.timestamp)

        db.session.add(self.takeoff_koenigsdorf_dd0815)
        db.session.commit()

        update_logbook()
        entries = self.get_logbook_entries()
        self.assertEqual(len(entries), 1)
        self.assertEqual(entries[0].takeoff_airport_id, self.koenigsdorf.id)
        self.assertEqual(entries[0].landing_airport_id, self.koenigsdorf.id)
        self.assertEqual(entries[0].reference_timestamp,
                         self.takeoff_koenigsdorf_dd0815.timestamp)