kopia lustrzana https://github.com/glidernet/ogn-python
Test all model classes
rodzic
acc4b858a8
commit
6aa99bd18f
|
@ -1,4 +1,5 @@
|
||||||
from sqlalchemy import Column, Integer, String, Boolean, SmallInteger
|
from sqlalchemy import Column, Integer, String, Boolean, SmallInteger, ForeignKey
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
|
|
||||||
|
@ -18,15 +19,18 @@ class DeviceInfo(Base):
|
||||||
|
|
||||||
address_origin = Column(SmallInteger)
|
address_origin = Column(SmallInteger)
|
||||||
|
|
||||||
|
# Relations
|
||||||
|
device_id = Column(Integer, ForeignKey('device.id', ondelete='SET NULL'), index=True)
|
||||||
|
device = relationship('Device', foreign_keys=[device_id])
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<DeviceInfo: %s,%s,%s,%s,%s,%s,%s,%s,%s,%s>" % (
|
return "<DeviceInfo: %s,%s,%s,%s,%s,%s,%s,%s,%s>" % (
|
||||||
self.address_type,
|
self.address_type,
|
||||||
self.address,
|
self.address,
|
||||||
self.name,
|
|
||||||
self.airport,
|
|
||||||
self.aircraft,
|
self.aircraft,
|
||||||
self.registration,
|
self.registration,
|
||||||
self.competition,
|
self.competition,
|
||||||
self.frequency,
|
|
||||||
self.tracked,
|
self.tracked,
|
||||||
self.identified)
|
self.identified,
|
||||||
|
self.aircraft_type,
|
||||||
|
self.address_origin)
|
||||||
|
|
|
@ -4,7 +4,7 @@ class DeviceInfoOrigin:
|
||||||
flarmnet = 2
|
flarmnet = 2
|
||||||
user_defined = 3
|
user_defined = 3
|
||||||
|
|
||||||
def __init__(self, origin):
|
def __init__(self, origin=0):
|
||||||
if origin in [0, 1, 2, 3]:
|
if origin in [0, 1, 2, 3]:
|
||||||
self.origin = origin
|
self.origin = origin
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class Location:
|
class Location:
|
||||||
"""Represents a location in WGS84"""
|
"""Represents a location in WGS84"""
|
||||||
|
|
||||||
def __init__(self, lon, lat):
|
def __init__(self, lon=0, lat=0):
|
||||||
self.longitude = lon
|
self.longitude = lon
|
||||||
self.latitude = lat
|
self.latitude = lat
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
import inspect
|
||||||
|
|
||||||
from ogn.model import AircraftBeacon, Airport, ReceiverBeacon
|
import ogn.model
|
||||||
|
|
||||||
|
|
||||||
class TestStringMethods(unittest.TestCase):
|
class TestStringMethods(unittest.TestCase):
|
||||||
def test_string(self):
|
def test_string(self):
|
||||||
print(AircraftBeacon())
|
|
||||||
print(Airport())
|
|
||||||
print(ReceiverBeacon())
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
for name, obj in inspect.getmembers(ogn.model):
|
||||||
|
print("Testing: {}".format(name))
|
||||||
|
if inspect.isclass(obj):
|
||||||
|
print(obj())
|
||||||
|
except AttributeError as e:
|
||||||
|
raise AssertionError(e)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Ładowanie…
Reference in New Issue