Skip to content

Commit

Permalink
Test fixtures: Retain ordering of followup packets.
Browse files Browse the repository at this point in the history
  • Loading branch information
timstaley committed Dec 6, 2015
1 parent 321b58c commit 5f8a514
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions voeventdb/server/tests/fixtures/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def add_reference(self, packet, ref_ivorn):
self.n_citations += 1
# self.cited.add(ref_ivorn)
self.cite_counts[ref_ivorn] = self.cite_counts[ref_ivorn] + 1
self.followup_packets.add(packet.attrib['ivorn'])
self.followup_packets.append(packet.attrib['ivorn'])
vp.add_citations(packet,
vp.Citation(
ref_ivorn,
Expand All @@ -98,7 +98,7 @@ def __init__(self, fixture_db_session):
# Count times ivorn referenced by other packets in db :
self.cite_counts = defaultdict(int)
# Packets containing at least one cite entry
self.followup_packets = set()
self.followup_packets = []
# Total number of citations (one packet may have multiple cite entries)
self.n_citations = 0

Expand Down
12 changes: 6 additions & 6 deletions voeventdb/server/tests/test_rest/test_restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from flask import url_for



@pytest.mark.usefixtures('fixture_db_session')
class TestWithEmptyDatabase:
@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -143,8 +142,8 @@ def test_reference_counts(self, simple_populated_db):
with self.c as c:
url = url_for(
apiv0.name + '.' + views.IvornReferenceCount.view_name,
**{PaginationKeys.order:OrderValues.id}
)
**{PaginationKeys.order: OrderValues.id}
)
rv = self.c.get(url)
assert rv.status_code == 200
rd = json.loads(rv.data)
Expand All @@ -153,7 +152,7 @@ def test_reference_counts(self, simple_populated_db):
assert sum(counts) == simple_populated_db.n_citations
for ivorn, refcount in ivorn_refcounts:
assert bool(refcount) == (
ivorn in simple_populated_db.followup_packets)
ivorn in simple_populated_db.followup_packets)

def test_cited_counts(self, simple_populated_db):
dbinf = simple_populated_db
Expand Down Expand Up @@ -208,7 +207,8 @@ def test_synopsis_view(self, simple_populated_db):

# Negative case, IVORN present but packet contains no references
all_ivorns = set(simple_populated_db.packet_dict.keys())
ivorns_wo_refs = list(all_ivorns - simple_populated_db.followup_packets)
ivorns_wo_refs = list(
all_ivorns - set(simple_populated_db.followup_packets))
ivorn = ivorns_wo_refs[0]
url = ep_url + urllib.quote_plus(ivorn)
rv = self.c.get(url)
Expand All @@ -219,7 +219,7 @@ def test_synopsis_view(self, simple_populated_db):

# Find packet which cites a SWIFT GRB, check URLs looked up correctly:
url = url_for(apiv0.name + '.' + views.IvornList.view_name,
**{filters.RefContains.querystring_key : 'BAT_GRB'}
**{filters.RefContains.querystring_key: 'BAT_GRB'}
)
rv = self.c.get(url)
match_ivorns = json.loads(rv.data)[ResultKeys.result]
Expand Down

0 comments on commit 5f8a514

Please sign in to comment.