def test_encode_area(self): value = encode_cellarea(Radio.gsm, 310, 1, 0) self.assertEqual(len(value), 7) self.assertEqual(value, b'\x00\x016\x00\x01\x00\x00') value = encode_cellarea(Radio.wcdma, 310, 1, 12) self.assertEqual(len(value), 7) self.assertEqual(value, b'\x02\x016\x00\x01\x00\x0c')
def test_encode_area(self): value = encode_cellarea(Radio.gsm, 310, 1, 0) assert len(value) == 7 assert value == b'\x00\x016\x00\x01\x00\x00' value = encode_cellarea(Radio.wcdma, 310, 1, 12) assert len(value) == 7 assert value == b'\x02\x016\x00\x01\x00\x0c'
def test_region(self): areaid = encode_cellarea(Radio.gsm, GB_MCC, GB_MNC, 123) self.session.add(CellAreaOCID.create( areaid=areaid, lat=GB_LAT, lon=GB_LON, region=None, radio=Radio.gsm, mcc=GB_MCC, mnc=GB_MNC, lac=123)) self.session.flush() result = self.session.query(CellAreaOCID).first() self.assertEqual(result.region, 'GB')
def test_fields(self): areaid = encode_cellarea(Radio.wcdma, GB_MCC, GB_MNC, 123) self.session.add(CellAreaOCID.create( areaid=areaid, radio=Radio.wcdma, mcc=GB_MCC, mnc=GB_MNC, lac=123, lat=GB_LAT, lon=GB_LON, radius=10, region='GB', avg_cell_radius=11, num_cells=15)) self.session.flush() result = self.session.query(CellAreaOCID).first() self.assertEqual(encode_cellarea(*result.areaid), areaid) self.assertEqual(result.radio, Radio.wcdma) self.assertEqual(result.mcc, GB_MCC) self.assertEqual(result.mnc, GB_MNC) self.assertEqual(result.lac, 123) self.assertEqual(result.lat, GB_LAT) self.assertEqual(result.lon, GB_LON) self.assertEqual(result.radius, 10) self.assertEqual(result.region, 'GB') self.assertEqual(result.avg_cell_radius, 11) self.assertEqual(result.num_cells, 15)
def test_fields(self, session): areaid = encode_cellarea(Radio.wcdma, GB_MCC, GB_MNC, 123) session.add(CellAreaOCID.create( areaid=areaid, radio=Radio.wcdma, mcc=GB_MCC, mnc=GB_MNC, lac=123, lat=GB_LAT, lon=GB_LON, radius=10, region='GB', avg_cell_radius=11, num_cells=15)) session.flush() result = session.query(CellAreaOCID).first() assert encode_cellarea(*result.areaid) == areaid assert result.radio is Radio.wcdma assert result.mcc == GB_MCC assert result.mnc == GB_MNC assert result.lac == 123 assert result.lat == GB_LAT assert result.lon == GB_LON assert result.radius == 10 assert result.region == 'GB' assert result.avg_cell_radius == 11 assert result.num_cells == 15
def test_areaid_bytes(self): areaid = encode_cellarea(Radio.gsm, GB_MCC, GB_MNC, 1) self.session.add(CellArea( areaid=areaid, radio=Radio.wcdma, mcc=GB_MCC, mnc=GB_MNC, lac=1234)) self.session.flush() result = self.session.query(CellArea).first() self.assertEqual(result.areaid, (Radio.gsm, GB_MCC, GB_MNC, 1)) result = (self.session.query(CellArea) .filter(CellArea.areaid == areaid)).first() self.assertEqual(result.areaid, (Radio.gsm, GB_MCC, GB_MNC, 1))
def test_min(self): value = encode_cellarea(Radio.gsm, 0, 0, 0, codec='base64') self.assertEqual(value, b'AAAAAAAAAA==') value = encode_cellid(Radio.gsm, 0, 0, 0, 0, codec='base64') self.assertEqual(value, b'AAAAAAAAAAAAAAA=') value = decode_cellarea(b'AAAAAAAAAA==', codec='base64') self.assertEqual(value, (Radio.gsm, 0, 0, 0)) self.assertEqual(type(value[0]), Radio) value = decode_cellid(b'AAAAAAAAAAAAAAA=', codec='base64') self.assertEqual(value, (Radio.gsm, 0, 0, 0, 0)) self.assertEqual(type(value[0]), Radio)
def test_min(self): value = encode_cellarea(Radio.gsm, 0, 0, 0, codec="base64") assert value == b"AAAAAAAAAA==" value = encode_cellid(Radio.gsm, 0, 0, 0, 0, codec="base64") assert value == b"AAAAAAAAAAAAAAA=" value = decode_cellarea(b"AAAAAAAAAA==", codec="base64") assert value == (Radio.gsm, 0, 0, 0) assert type(value[0]) is Radio value = decode_cellid(b"AAAAAAAAAAAAAAA=", codec="base64") assert value == (Radio.gsm, 0, 0, 0, 0) assert type(value[0]) is Radio
def test_min(self): value = encode_cellarea(Radio.gsm, 0, 0, 0, codec='base64') assert value == b'AAAAAAAAAA==' value = encode_cellid(Radio.gsm, 0, 0, 0, 0, codec='base64') assert value == b'AAAAAAAAAAAAAAA=' value = decode_cellarea(b'AAAAAAAAAA==', codec='base64') assert value == (Radio.gsm, 0, 0, 0) assert type(value[0]) is Radio value = decode_cellid(b'AAAAAAAAAAAAAAA=', codec='base64') assert value == (Radio.gsm, 0, 0, 0, 0) assert type(value[0]) is Radio
def test_region(self): areaid = encode_cellarea(Radio.gsm, GB_MCC, GB_MNC, 123) self.session.add( CellAreaOCID.create(areaid=areaid, lat=GB_LAT, lon=GB_LON, region=None, radio=Radio.gsm, mcc=GB_MCC, mnc=GB_MNC, lac=123)) self.session.flush() result = self.session.query(CellAreaOCID).first() self.assertEqual(result.region, 'GB')
def test_areaid_bytes(self): areaid = encode_cellarea(Radio.gsm, GB_MCC, GB_MNC, 1) self.session.add( CellArea(areaid=areaid, radio=Radio.wcdma, mcc=GB_MCC, mnc=GB_MNC, lac=1234)) self.session.flush() result = self.session.query(CellArea).first() self.assertEqual(result.areaid, (Radio.gsm, GB_MCC, GB_MNC, 1)) result = (self.session.query(CellArea).filter( CellArea.areaid == areaid)).first() self.assertEqual(result.areaid, (Radio.gsm, GB_MCC, GB_MNC, 1))
def test_region(self, session): areaid = encode_cellarea(Radio.gsm, GB_MCC, GB_MNC, 123) session.add( CellArea.create( areaid=areaid, lat=GB_LAT, lon=GB_LON, region=None, radio=Radio.gsm, mcc=GB_MCC, mnc=GB_MNC, lac=123, )) session.flush() result = session.query(CellArea).first() assert result.region == "GB"
def test_max(self): bit16 = 2 ** 16 - 1 bit32 = 2 ** 32 - 1 value = encode_cellarea( Radio.wcdma, bit16, bit16, bit16, codec='base64') self.assertEqual(value, b'Av///////w==') value = encode_cellid( Radio.wcdma, bit16, bit16, bit16, bit32, codec='base64') self.assertEqual(value, b'Av////////////8=') value = decode_cellarea(b'Av///////w==', codec='base64') self.assertEqual(value, (Radio.wcdma, bit16, bit16, bit16)) self.assertEqual(type(value[0]), Radio) value = decode_cellid(b'Av////////////8=', codec='base64') self.assertEqual(value, (Radio.wcdma, bit16, bit16, bit16, bit32)) self.assertEqual(type(value[0]), Radio)
def test_max(self): bit16 = 2 ** 16 - 1 bit32 = 2 ** 32 - 1 value = encode_cellarea( Radio.wcdma, bit16, bit16, bit16, codec='base64') assert value == b'Av///////w==' value = encode_cellid( Radio.wcdma, bit16, bit16, bit16, bit32, codec='base64') assert value == b'Av////////////8=' value = decode_cellarea(b'Av///////w==', codec='base64') assert value == (Radio.wcdma, bit16, bit16, bit16) assert type(value[0]) is Radio value = decode_cellid(b'Av////////////8=', codec='base64') assert value == (Radio.wcdma, bit16, bit16, bit16, bit32) assert type(value[0]) is Radio
def areaid(self): return encode_cellarea( self.radioType, self.mobileCountryCode, self.mobileNetworkCode, self.locationAreaCode)
def areaid(self): return encode_cellarea(self.radio, self.mcc, self.mnc, self.lac)