from ..helpers import assert_equal, patch
import datetime
from tagalog import source_host

def test_no_source_host_defaults():
    data = [{'@message': 'one'},
            {'@message': 'two'},
            {'@message': 'three'}]
    out = source_host(data)

    assert_equal(next(out), {'@message': 'one', '@source_host': 'default'})
    assert_equal(next(out), {'@message': 'two', '@source_host': 'default'})
    assert_equal(next(out), {'@message': 'three', '@source_host': 'default'})

@@ -84,16 +84,17 @@
 e_host%0A%0A
+%0A
 def test
@@ -251,16 +251,134 @@
 (data)%0A%0A
+    # FIXME: Replace 'default' with mocked method that looks up the FQDN of%0A    # the machine which it is running on.%0A
     asse
@@ -513,32 +513,32 @@
 t': 'default'%7D)%0A
-
     assert_equal
@@ -579,28 +579,1640 @@
 '@source_host': 'default'%7D)%0A
+%0A%0Adef test_source_host_provided():%0A    data = %5B%7B'@source_host': 'orangutan.zoo.tld', '@message': 'one'%7D,%0A            %7B'@source_host': 'orangutan.zoo.tld', '@message': 'two'%7D,%0A            %7B'@source_host': 'orangutan.zoo.tld', '@message': 'three'%7D%5D%0A    out = source_host(data, source_host='chimpanzee.zoo.tld')%0A%0A    assert_equal(next(out), %7B'@source_host': 'orangutan.zoo.tld', '@message': 'one'%7D)%0A    assert_equal(next(out), %7B'@source_host': 'orangutan.zoo.tld', '@message': 'two'%7D)%0A    assert_equal(next(out), %7B'@source_host': 'orangutan.zoo.tld', '@message': 'three'%7D)%0A%0A%0Adef test_source_host_provided_custom_key():%0A    data = %5B%7B'@message': 'one'%7D,%0A            %7B'@message': 'two'%7D,%0A            %7B'@message': 'three'%7D%5D%0A    out = source_host(data, source_host='orangutan.zoo.tld', key='host')%0A%0A    assert_equal(next(out), %7B'host': 'orangutan.zoo.tld', '@message': 'one'%7D)%0A    assert_equal(next(out), %7B'host': 'orangutan.zoo.tld', '@message': 'two'%7D)%0A    assert_equal(next(out), %7B'host': 'orangutan.zoo.tld', '@message': 'three'%7D)%0A%0A%0Adef test_source_host_dont_overwrite_existing():%0A    data = %5B%7B'@source_host': 'orangutan.zoo.tld', '@message': 'one'%7D,%0A            %7B'@source_host': 'orangutan.zoo.tld', '@message': 'two'%7D,%0A            %7B'@source_host': 'orangutan.zoo.tld', '@message': 'three'%7D%5D%0A    out = source_host(data, source_host='chimpanzee.zoo.tld')%0A%0A    assert_equal(next(out), %7B'@source_host': 'orangutan.zoo.tld', '@message': 'one'%7D)%0A    assert_equal(next(out), %7B'@source_host': 'orangutan.zoo.tld', '@message': 'two'%7D)%0A    assert_equal(next(out), %7B'@source_host': 'orangutan.zoo.tld', '@message': 'three'%7D)%0A

Add desired unit tests for source_host