Exemplo n.º 1
0
    def test_fields(self):
        now = util.utcnow()
        cellid = encode_cellid(Radio.gsm, GB_MCC, GB_MNC, 123, 2345)
        self.session.add(CellOCID.create(
            cellid=cellid, created=now, modified=now,
            radio=Radio.gsm, mcc=GB_MCC, mnc=GB_MNC, lac=123, cid=2345, psc=1,
            lat=GB_LAT, lon=GB_LON,
            max_lat=GB_LAT + 0.1, min_lat=GB_LAT - 0.1,
            max_lon=GB_LON + 0.1, min_lon=GB_LON - 0.1,
            radius=11, region='GB', samples=15, source=StationSource.gnss,
            block_first=now.date(), block_last=now.date(), block_count=1))
        self.session.flush()

        result = (self.session.query(CellOCID)
                              .filter(CellOCID.cellid == cellid)).first()
        self.assertEqual(result.areaid, cellid[:7])
        self.assertEqual(encode_cellid(*result.cellid), cellid)
        self.assertEqual(result.radio, Radio.gsm)
        self.assertEqual(result.mcc, GB_MCC)
        self.assertEqual(result.mnc, GB_MNC)
        self.assertEqual(result.lac, 123)
        self.assertEqual(result.cid, 2345)
        self.assertEqual(result.psc, 1)
        self.assertEqual(result.created, now)
        self.assertEqual(result.modified, now)
        self.assertEqual(result.lat, GB_LAT)
        self.assertEqual(result.lon, GB_LON)
        self.assertEqual(result.radius, 11)
        self.assertEqual(result.region, 'GB')
        self.assertEqual(result.samples, 15)
        self.assertEqual(result.source, StationSource.gnss)
        self.assertEqual(result.block_first, now.date())
        self.assertEqual(result.block_last, now.date())
        self.assertEqual(result.block_count, 1)
Exemplo n.º 2
0
    def test_region(self):
        cellid = encode_cellid(Radio.gsm, GB_MCC, GB_MNC, 123, 2345)
        self.session.add(CellOCID.create(
            cellid=cellid, lat=GB_LAT, lon=GB_LON, region=None,
            radio=Radio.gsm, mcc=GB_MCC, mnc=GB_MNC, lac=123, cid=2345))
        self.session.flush()

        result = self.session.query(CellOCID).first()
        self.assertEqual(result.region, 'GB')
Exemplo n.º 3
0
    def test_areaid(self):
        cellid = encode_cellid(Radio.gsm, GB_MCC, GB_MNC, 123, 2345)
        self.session.add(CellOCID.create(
            cellid=cellid,
            radio=Radio.gsm, mcc=GB_MCC, mnc=GB_MNC, lac=123, cid=2345))
        self.session.flush()

        result = self.session.query(CellOCID).first()
        self.assertEqual(result.areaid, cellid[:7])
Exemplo n.º 4
0
    def test_cellid_null(self):
        result = (self.session.query(CellOCID)
                              .filter(CellOCID.cellid.is_(None))).all()
        self.assertEqual(result, [])

        self.session.add(CellOCID(
            cellid=None,
            radio=Radio.gsm, mcc=GB_MCC, mnc=GB_MNC, lac=123, cid=2345))
        with self.assertRaises(Exception):
            self.session.flush()
Exemplo n.º 5
0
 def test_score(self):
     now = util.utcnow()
     cell = CellOCID.create(radio=Radio.gsm,
                            mcc=GB_MCC,
                            mnc=GB_MNC,
                            lac=2,
                            cid=3,
                            created=now,
                            modified=now,
                            radius=10,
                            samples=2)
     self.assertAlmostEqual(cell.score(now), 0.1, 2)
Exemplo n.º 6
0
 def test_score(self):
     now = util.utcnow()
     cell = CellOCID.create(
         radio=Radio.gsm, mcc=GB_MCC, mnc=GB_MNC, lac=2, cid=3,
         created=now, modified=now, radius=10, samples=2)
     self.assertAlmostEqual(cell.score(now), 0.1, 2)