import sys
import subprocess

import pytest


from multisieve_coreference.resolve_coreference import process_coreference


def test_main_example(example_naf_file, temp_file, example_naf_output):
    with open(example_naf_file) as fd, open(temp_file, 'w') as out:
        subprocess.check_call(
            [sys.executable, '-m', 'multisieve_coreference'],
            stdin=fd,
            stdout=out
        )
    from KafNafParserPy import KafNafParser
    with open(temp_file) as out, open(example_naf_output) as correct:
        assert KafNafParser(out).coreference_layer is not None
        out.seek(0)
        assert out.read() == correct.read()


def test_example(example_naf_object, caplog):
    # caplog.set_level('DEBUG')
    caplog.set_level('WARNING', 'multisieve_coreference.constituency_tree')
    out = process_coreference(example_naf_object)
    assert out.coreference_layer is not None


@pytest.mark.slow
def test_main_sonar1(sonar_naf_object1, caplog):
    # caplog.set_level('DEBUG')
    caplog.set_level('WARNING', 'multisieve_coreference.constituency_tree')
    out = process_coreference(sonar_naf_object1)
    assert out.coreference_layer is not None


@pytest.mark.slow
def test_main_sonar2(sonar_naf_object2, caplog):
    # caplog.set_level('DEBUG')
    caplog.set_level('WARNING', 'multisieve_coreference.constituency_tree')
    out = process_coreference(sonar_naf_object2)
    assert out.coreference_layer is not None

@@ -655,32 +655,45 @@
 def test_example
+_without_fill
 (example_naf_obj
@@ -701,34 +701,32 @@
 ct, caplog):%0A   
- #
  caplog.set_leve
@@ -726,33 +726,258 @@
 et_level('DEBUG'
-)
+, 'multisieve_coreference.dump')%0A    out = process_coreference(example_naf_object, fill_gaps=False)%0A    assert out.coreference_layer is not None%0A%0A%0A@pytest.mark.slow%0Adef test_main_sonar1_without_fill(sonar_naf_object1, caplog):
 %0A    caplog.set_
@@ -975,38 +975,36 @@
 plog.set_level('
-WARNIN
+DEBU
 G', 'multisieve_
@@ -1015,33 +1015,20 @@
 ference.
-constituency_tree
+dump
 ')%0A    o
@@ -1044,39 +1044,37 @@
 ess_coreference(
-example
+sonar
 _naf_object)%0A   
@@ -1068,16 +1068,34 @@
 f_object
+1, fill_gaps=False
 )%0A    as
@@ -1172,17 +1172,30 @@
 in_sonar
-1
+2_without_fill
 (sonar_n
@@ -1195,33 +1195,33 @@
 sonar_naf_object
-1
+2
 , caplog):%0A    #
@@ -1210,34 +1210,32 @@
 t2, caplog):%0A   
- #
  caplog.set_leve
@@ -1235,33 +1235,233 @@
 et_level('DEBUG'
-)
+, 'multisieve_coreference.dump')%0A    out = process_coreference(sonar_naf_object2, fill_gaps=False)%0A    assert out.coreference_layer is not None%0A%0A%0Adef test_example_with_fill(example_naf_object, caplog):
 %0A    caplog.set_
@@ -1459,38 +1459,36 @@
 plog.set_level('
-WARNIN
+DEBU
 G', 'multisieve_
@@ -1499,33 +1499,20 @@
 ference.
-constituency_tree
+dump
 ')%0A    o
@@ -1528,37 +1528,39 @@
 ess_coreference(
-sonar
+example
 _naf_object1)%0A  
@@ -1554,17 +1554,32 @@
 f_object
-1
+, fill_gaps=True
 )%0A    as
@@ -1656,17 +1656,27 @@
 in_sonar
-2
+1_with_fill
 (sonar_n
@@ -1676,33 +1676,33 @@
 sonar_naf_object
-2
+1
 , caplog):%0A    #
@@ -1703,10 +1703,8 @@
 %0A   
- #
  cap
@@ -1724,17 +1724,237 @@
 ('DEBUG'
-)
+, 'multisieve_coreference.dump')%0A    out = process_coreference(sonar_naf_object1, fill_gaps=True)%0A    assert out.coreference_layer is not None%0A%0A%0A@pytest.mark.slow%0Adef test_main_sonar2_with_fill(sonar_naf_object2, caplog):
 %0A    cap
@@ -1972,14 +1972,12 @@
 el('
-WARNIN
+DEBU
 G', 
@@ -2004,25 +2004,12 @@
 nce.
-constituency_tree
+dump
 ')%0A 
@@ -2054,16 +2054,32 @@
 _object2
+, fill_gaps=True
 )%0A    as

Add tests with and without `fill_gaps`