import pytest


@pytest.fixture
def file_no_replicate(testapp, experiment, award, lab):
    item = {
        'dataset': experiment['@id'],
        'lab': lab['@id'],
        'award': award['@id'],
        'file_format': 'bam',
        'assembly': 'hg19',
        'md5sum': 'e002cd204df36d93dd070ef0712b8eed',
        'output_type': 'alignments',
        'status': 'in progress',  # avoid s3 upload codepath
    }
    return testapp.post_json('/file', item).json['@graph'][0]


@pytest.fixture
def file_with_replicate(testapp, experiment, award, lab, replicate):
    item = {
        'dataset': experiment['@id'],
        'replicate': replicate['@id'],
        'lab': lab['@id'],
        'award': award['@id'],
        'file_format': 'bam',
        'assembly': 'hg19',
        'md5sum': 'e003cd204df36d93dd070ef0712b8eed',
        'output_type': 'alignments',
        'status': 'in progress',  # avoid s3 upload codepath
    }
    return testapp.post_json('/file', item).json['@graph'][0]


@pytest.fixture
def file_with_derived(testapp, experiment, award, lab, file_with_replicate):
    item = {
        'dataset': experiment['@id'],
        'lab': lab['@id'],
        'award': award['@id'],
        'file_format': 'bam',
        'assembly': 'hg19',
        'md5sum': 'e004cd204df36d93dd070ef0712b8eed',
        'output_type': 'alignments',
        'status': 'in progress',  # avoid s3 upload codepath
        'derived_from': [file_with_replicate['@id']],
    }
    return testapp.post_json('/file', item).json['@graph'][0]


def test_file_post(file_no_replicate):
    assert file_no_replicate['biological_replicates'] == []


def test_file_with_replicate_post(file_with_replicate):
    assert file_with_replicate['biological_replicates'] == [1]


def test_file_with_derived_from_post(testapp, file_with_derived):
    assert file_with_derived['biological_replicates'] == [1]

@@ -1523,353 +1523,1423 @@
 %5D%0A%0A%0A
-def test_file_post(file_no_replicate):%0A    assert file_no_replicate%5B'biological_replicates'%5D == %5B%5D%0A%0A%0Adef test_file_with_replicate_post(file_with_replicate):%0A    assert file_with_replicate%5B'biological_replicates'%5D == %5B1%5D%0A%0A%0Adef test_file_with_derived_from_post(testapp, file_with_derived):%0A    assert file_with_derived%5B'biological_replicates'%5D == %5B1%5D
+@pytest.fixture%0Adef file_no_assembly(testapp, experiment, award, lab, replicate):%0A    item = %7B%0A        'dataset': experiment%5B'@id'%5D,%0A        'replicate': replicate%5B'@id'%5D,%0A        'lab': lab%5B'@id'%5D,%0A        'award': award%5B'@id'%5D,%0A        'file_format': 'bam',%0A        'md5sum': '82847a2a5beb8095282c68c00f48e347',%0A        'output_type': 'alignments',%0A        'status': 'in progress'%0A    %7D%0A    return item%0A%0A%0Adef test_file_post(file_no_replicate):%0A    assert file_no_replicate%5B'biological_replicates'%5D == %5B%5D%0A%0A%0Adef test_file_with_replicate_post(file_with_replicate):%0A    assert file_with_replicate%5B'biological_replicates'%5D == %5B1%5D%0A%0A%0Adef test_file_with_derived_from_post(testapp, file_with_derived):%0A    assert file_with_derived%5B'biological_replicates'%5D == %5B1%5D%0A%0A%0Adef test_file_no_assembly(testapp, file_no_assembly, file_with_replicate):%0A    res = testapp.post_json('/file', file_no_assembly, expect_errors=True)%0A    assert res.status_code == 422%0A    res = testapp.patch_json(file_with_replicate%5B'@id'%5D,%0A                             %7B'file_format': 'fastq', 'output_type': 'reads'%7D,%0A                             expect_errors=True)%0A    assert res.status_code == 422%0A    file_no_assembly%5B'file_format'%5D = 'bigBed'%0A    file_no_assembly%5B'file_format_type'%5D = 'narrowPeak'%0A    file_no_assembly%5B'output_type'%5D = 'peaks'%0A    res = testapp.post_json('/file', file_no_assembly, expect_errors=True)%0A    assert res.status_code == 422
 %0A

Add file assembly dependency check to tests