Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAT-138 convert test_aggr_regressions.py to pytest #1113

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LNX-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
interval: 15s
fakeservices.datajoint.io:
<<: *net
image: datajoint/nginx:v0.2.6
image: datajoint/nginx:v0.2.7
environment:
- ADD_db_TYPE=DATABASE
- ADD_db_ENDPOINT=db:3306
Expand Down
2 changes: 1 addition & 1 deletion local-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ services:
interval: 15s
fakeservices.datajoint.io:
<<: *net
image: datajoint/nginx:v0.2.6
image: datajoint/nginx:v0.2.7
environment:
- ADD_db_TYPE=DATABASE
- ADD_db_ENDPOINT=db:3306
Expand Down
50 changes: 50 additions & 0 deletions tests/schema_uuid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import uuid
import datajoint as dj
from . import PREFIX, CONN_INFO_ROOT

schema = dj.Schema(PREFIX + "_test1", connection=dj.conn(**CONN_INFO_ROOT))

top_level_namespace_id = uuid.UUID("00000000-0000-0000-0000-000000000000")


@schema
class Basic(dj.Manual):
definition = """
item : uuid
---
number : int
"""


@schema
class Topic(dj.Manual):
definition = """
# A topic for items
topic_id : uuid # internal identification of a topic, reflects topic name
---
topic : varchar(8000) # full topic name used to generate the topic id
"""

def add(self, topic):
"""add a new topic with a its UUID"""
self.insert1(
dict(topic_id=uuid.uuid5(top_level_namespace_id, topic), topic=topic)
)


@schema
class Item(dj.Computed):
definition = """
item_id : uuid # internal identification of
---
-> Topic
word : varchar(8000)
"""

key_source = Topic # test key source that is not instantiated

def make(self, key):
for word in ("Habenula", "Hippocampus", "Hypothalamus", "Hypophysis"):
self.insert1(
dict(key, word=word, item_id=uuid.uuid5(key["topic_id"], word))
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
"""

import itertools
from nose.tools import assert_equal
import datajoint as dj
from . import PREFIX, CONN_INFO
from . import PREFIX, CONN_INFO_ROOT
import uuid
from .schema_uuid import Topic, Item, top_level_namespace_id

schema = dj.Schema(PREFIX + "_aggr_regress", connection=dj.conn(**CONN_INFO))
schema = dj.Schema(PREFIX + "_aggr_regress", connection=dj.conn(**CONN_INFO_ROOT))

# --------------- ISSUE 386 -------------------
# Issue 386 resulted from the loss of aggregated attributes when the aggregation was used as the restrictor
Expand Down Expand Up @@ -100,19 +99,16 @@ class X(dj.Lookup):

def test_issue558_part1():
q = (A - B).proj(id2="3")
assert_equal(len(A - B), len(q))
assert len(A - B) == len(q)


def test_issue558_part2():
d = dict(id=3, id2=5)
assert_equal(len(X & d), len((X & d).proj(id2="3")))
assert len(X & d) == len((X & d).proj(id2="3"))


def test_left_join_len():
Topic().add("jeff")
Item.populate()
Topic().add("jeff2")
Topic().add("jeff3")
q = Topic.join(
Item - dict(topic_id=uuid.uuid5(top_level_namespace_id, "jeff")), left=True
)
Expand All @@ -122,8 +118,8 @@ def test_left_join_len():

def test_union_join():
# https://github.com/datajoint/datajoint-python/issues/930
A.insert(zip([100, 200, 300, 400, 500, 600]))
B.insert([(100, 11), (200, 22), (300, 33), (400, 44)])
A.insert(zip([100, 200, 300, 400, 500, 600]), skip_duplicates=True)
B.insert([(100, 11), (200, 22), (300, 33), (400, 44)], skip_duplicates=True)
q1 = B & "id < 300"
q2 = B & "id > 300"

Expand Down