def test_blocked(self): today = util.utcnow().date() two_weeks = today - timedelta(days=14) self.assertFalse(CellShardGsm().blocked()) self.assertTrue(CellShardGsm(block_count=100).blocked()) self.assertTrue(CellShardGsm(block_last=today).blocked()) self.assertFalse(CellShardGsm(block_last=two_weeks).blocked()) self.assertTrue(CellShardGsm(block_last=two_weeks).blocked(two_weeks))
def test_cellid_null(self, session): result = (session.query(CellShardGsm).filter( CellShardGsm.cellid.is_(None))).all() assert result == [] with warnings.catch_warnings(): warnings.simplefilter('ignore', SAWarning) session.add( CellShardGsm(cellid=None, radio=Radio.gsm, mcc=GB_MCC, mnc=GB_MNC, lac=123, cid=2345)) with pytest.raises(Exception): session.flush()
def test_blocked(self): today = util.utcnow() two_weeks = today - timedelta(days=14) assert not station_blocked(CellShardGsm()) assert station_blocked(CellShardGsm(created=two_weeks, block_count=1)) assert station_blocked( CellShardGsm(created=today - timedelta(30), block_count=1)) assert not station_blocked( CellShardGsm(created=today - timedelta(45), block_count=1)) assert station_blocked( CellShardGsm(created=today - timedelta(45), block_count=2)) assert not station_blocked( CellShardGsm(created=today - timedelta(105), block_count=3)) assert station_blocked( CellShardGsm(created=two_weeks, block_last=today.date())) assert not station_blocked( CellShardGsm(created=two_weeks, block_last=two_weeks.date())) assert station_blocked( CellShardGsm(created=two_weeks, block_last=two_weeks.date()), two_weeks.date())
def test_init_fail(self): self.session.add(CellShardGsm(cellid='abc')) with self.assertRaises(SQLAlchemyError): self.session.flush()
def test_init_empty(self): self.session.add(CellShardGsm()) with self.assertRaises(SQLAlchemyError): self.session.flush()
def test_init_fail(self, session): session.add(CellShardGsm(cellid="abc")) with pytest.raises(SQLAlchemyError): session.flush()
def test_init_empty(self, session): with warnings.catch_warnings(): warnings.simplefilter("ignore", SAWarning) session.add(CellShardGsm()) with pytest.raises(SQLAlchemyError): session.flush()