def test_column_fn_with_agg(self): ips = Table.from_tag(IPS) res = select(ips.exchange_id, h_max(ip_ntoa(ips.ip)), where=ips, order_by=(ips.exchange_id, )) results = list(res) res.purge() exchanges = [ex for ex, _ in results] ipss = [ip for _, ip in results] self.assertListEqual(['Adx', 'Appnexus', 'OpenX', 'Rubycon'], exchanges) self.assertListEqual(['192.168.1.1'] * 4, ipss) res = select(ips.exchange_id, h_min(ip_ntoa(ips.ip)), where=ips, order_by=(ips.exchange_id, )) results = list(res) res.purge() exchanges = [ex for ex, _ in results] ipss = [ip for _, ip in results] self.assertListEqual(['Adx', 'Appnexus', 'OpenX', 'Rubycon'], exchanges) self.assertListEqual(['127.0.0.1'] * 4, ipss)
def test_column_fn_with_distinct(self): ips = Table.from_tag(IPS) res = select(ip_ntoa(ips.ip), where=ips.exchange_id == "Adx", order_by=(ip_ntoa(ips.ip),), distinct=True) results = list(res) res.purge() ipss = [ip[0] for ip in results] self.assertListEqual(['127.0.0.1', '192.1.1.1', '192.1.1.2', '192.168.1.1'], ipss)
def test_column_fn_with_distinct(self): ips = Table.from_tag(IPS) res = select(ip_ntoa(ips.ip), where=ips.exchange_id == "Adx", order_by=(ip_ntoa(ips.ip), ), distinct=True) results = list(res) res.purge() ipss = [ip[0] for ip in results] self.assertListEqual( ['127.0.0.1', '192.1.1.1', '192.1.1.2', '192.168.1.1'], ipss)
def test_column_fn(self): ips = Table.from_tag(IPS) res = select(ips.exchange_id, ip_ntoa(ips.ip), where=ips.exchange_id == "Adx") results = list(res) self.assertEqual(len(results), 29) res.purge()
def test_column_fn_with_agg(self): ips = Table.from_tag(IPS) res = select(ips.exchange_id, h_max(ip_ntoa(ips.ip)), where=ips, order_by=(ips.exchange_id,)) results = list(res) res.purge() exchanges = [ex for ex, _ in results] ipss = [ip for _, ip in results] self.assertListEqual(['Adx', 'Appnexus', 'OpenX', 'Rubycon'], exchanges) self.assertListEqual(['192.168.1.1'] * 4, ipss) res = select(ips.exchange_id, h_min(ip_ntoa(ips.ip)), where=ips, order_by=(ips.exchange_id,)) results = list(res) res.purge() exchanges = [ex for ex, _ in results] ipss = [ip for _, ip in results] self.assertListEqual(['Adx', 'Appnexus', 'OpenX', 'Rubycon'], exchanges) self.assertListEqual(['127.0.0.1'] * 4, ipss)
def test_get_key_names_with_column_fn(self): wheres = [(self.emp.salary > 25000), self.dept] project = [self.emp.name, ip_ntoa(self.emp.salary), self.dept.building] pipe = SelectPipe('server', wheres=wheres, project=project) self.assertTupleEqual((None, None, None), tuple(second_items(pipe._get_key_names(project, ())[1]))) join = [self.dept.id, self.emp.department_id] pipe = SelectPipe('server', wheres=wheres, project=project, join=join) self.assertTupleEqual((None, None, None, None), tuple(second_items(pipe._get_key_names(project, join)[1])))
def test_get_key_names_with_column_fn(self): wheres = [(self.emp.salary > 25000), self.dept] project = [self.emp.name, ip_ntoa(self.emp.salary), self.dept.building] pipe = SelectPipe('server', wheres=wheres, project=project) self.assertTupleEqual( (None, None, None), tuple(second_items(pipe._get_key_names(project, ())[1]))) join = [self.dept.id, self.emp.department_id] pipe = SelectPipe('server', wheres=wheres, project=project, join=join) self.assertTupleEqual( (None, None, None, None), tuple(second_items(pipe._get_key_names(project, join)[1])))