import pytest
pytestmark = [pytest.mark.working, pytest.mark.schema]


@pytest.fixture
def publication_PMID(testapp, lab, award):
    item = {
        'uuid': '8312fc0c-b241-4cb2-9b01-143891055000',
        'award': award['@id'],
        'lab': lab['@id'],
        'ID': "PMID:26673895",
    }
    return testapp.post_json('/publication', item).json['@graph'][0]


@pytest.fixture
def publication_doi_pubmed(testapp, lab, award):
    item = {
        'uuid': '8312fc0c-b241-4cb2-9b01-143891055001',
        'award': award['@id'],
        'lab': lab['@id'],
        'ID': "doi:10.1093/nar/gkv1046",
    }
    return testapp.post_json('/publication', item).json['@graph'][0]


@pytest.fixture
def publication_doi_biorxiv(testapp, lab, award):
    item = {
        'uuid': '8312fc0c-b241-4cb2-9b01-143891055002',
        'award': award['@id'],
        'lab': lab['@id'],
        'ID': "doi:10.1101/000091"
    }
    return testapp.post_json('/publication', item).json['@graph'][0]


# data from test/datafixtures
def test_update_publication_PMID(testapp, publication_PMID):
    assert publication_PMID['title'][:50] == 'A deep proteomics perspective on CRM1-mediated nuc'
    assert publication_PMID['abstract'][:50] == 'CRM1 is a highly conserved, RanGTPase-driven expor'
    assert publication_PMID['authors'] == 'Kirli K, Karaca S, Dehne HJ, Samwer M, Pan KT, Lenz C, Urlaub H, Gorlich D'
    assert publication_PMID['url'] == 'https://www.ncbi.nlm.nih.gov/pubmed/26673895'


def test_update_publication_doi_pubmed(testapp, publication_doi_pubmed):
    assert publication_doi_pubmed['title'][:50] == 'FlyBase: establishing a Gene Group resource for Dr'
    assert publication_doi_pubmed['abstract'][:50] == 'Many publications describe sets of genes or gene p'
    assert publication_doi_pubmed['authors'][:50] == 'Attrill H, Falls K, Goodman JL, Millburn GH, Anton'
    assert publication_doi_pubmed['url'] == 'https://www.ncbi.nlm.nih.gov/pubmed/26467478'


def test_update_publication_doi_biorxiv(testapp, publication_doi_biorxiv):
    assert publication_doi_biorxiv['title'][:50] == 'Designing Robustness to Temperature in a Feedforwa'
    assert publication_doi_biorxiv['abstract'][:50] == 'Incoherent feedforward loops represent important b'
    assert publication_doi_biorxiv['authors'] == 'Shaunak Sen, Jongmin Kim, Richard M. Murray'
    assert publication_doi_biorxiv['url'] == 'http://biorxiv.org/content/early/2013/11/07/000091'

@@ -1305,20 +1305,25 @@
 rs'%5D
+%5B:4%5D
  == 
+%5B
 'Kirli K
 , Ka
@@ -1322,18 +1322,20 @@
 li K
+'
 , 
+'
 Karaca S
 , De
@@ -1334,18 +1334,20 @@
 ca S
+'
 , 
+'
 Dehne HJ
 , Sa
@@ -1346,18 +1346,20 @@
 e HJ
+'
 , 
+'
 Samwer M
 , Pa
@@ -1358,46 +1358,10 @@
 er M
-, Pan KT, Lenz C, Urlaub H, Gorlich D
 '
+%5D
 %0A   
@@ -1442,16 +1442,66 @@
 673895'%0A
+    assert publication_PMID%5B'journal'%5D == 'eLife'%0A
 %0A%0Adef te
@@ -1824,23 +1824,23 @@
 hors'%5D%5B:
-50
+4
 %5D == 
+%5B
 'Attrill
@@ -1845,19 +1845,23 @@
 ll H
+'
 , 
+'
 Falls K
+'
 , 
+'
 Good
@@ -1866,18 +1866,20 @@
 odman JL
+'
 , 
+'
 Millburn
@@ -1885,16 +1885,10 @@
 n GH
-, Anton
 '
+%5D
 %0A   
@@ -1975,16 +1975,89 @@
 467478'%0A
+    assert publication_doi_pubmed%5B'journal'%5D == 'Nucleic acids research'%0A
 %0A%0Adef te
@@ -2387,16 +2387,17 @@
 rs'%5D == 
+%5B
 'Shaunak
@@ -2400,18 +2400,20 @@
 unak Sen
+'
 , 
+'
 Jongmin 
@@ -2415,18 +2415,20 @@
 gmin Kim
+'
 , 
+'
 Richard 
@@ -2437,16 +2437,17 @@
  Murray'
+%5D
 %0A    ass
@@ -2537,8 +2537,67 @@
 000091'%0A
+    assert publication_doi_biorxiv%5B'journal'%5D == 'bioRxiv'%0A

Add tests