def test_init(self): wifi = WifiShard0(mac='111101123456') self.session.add(wifi) self.session.flush() wifis = (self.session.query(WifiShard0) .filter(WifiShard0.mac == '111101123456')).all() self.assertEqual(wifis[0].mac, '111101123456')
def test_init(self, session): wifi = WifiShard0(mac="111101123456") session.add(wifi) session.flush() wifis = (session.query(WifiShard0).filter( WifiShard0.mac == "111101123456")).all() assert wifis[0].mac == "111101123456"
def test_executemany_backport(self): # Fixed in PyMySQL 0.6.7 self.session.add(WifiShard0(mac='000000123456')) self.session.add(WifiShard0(mac='000000abcdef')) self.session.commit()
def test_init_fail(self): wifi = WifiShard0(mac='abc') self.session.add(wifi) with self.assertRaises(SQLAlchemyError): self.session.flush()
def test_init_empty(self): wifi = WifiShard0() self.session.add(wifi) with self.assertRaises(SQLAlchemyError): self.session.flush()
def test_mac_hex(self): self.session.add(WifiShard0(mac='111101123456')) self.session.flush() stmt = 'select hex(`mac`) from wifi_shard_0' row = self.session.execute(stmt).fetchone() self.assertEqual(row, ('111101123456', ))
def test_init_fail(self, session): session.add(WifiShard0(mac='abc')) with pytest.raises(SQLAlchemyError): session.flush()
def test_init_empty(self, session): with warnings.catch_warnings(): warnings.simplefilter('ignore', SAWarning) session.add(WifiShard0()) with pytest.raises(SQLAlchemyError): session.flush()
def test_mac_hex(self, session): session.add(WifiShard0(mac="111101123456")) session.flush() stmt = "select hex(`mac`) from wifi_shard_0" row = session.execute(stmt).fetchone() assert row == ("111101123456", )