# -*- coding: utf-8 -*-


import pytest

import sshrc.core.lexer as lexer
import sshrc.core.parser as parser
import sshrc.core.processor as process


CONTENT = """\
Compression yes

Host q
    Port 22

    -Host e
        Protocol 2

        Host h
            HostName hew

    Host q
        HostName qqq
""".strip()


def test_generate():
    tokens = lexer.lex(CONTENT.split("\n"))
    tree = parser.parse(tokens)
    new_config = list(process.generate(tree))

    assert new_config == [
        "Host qeh",
        "    HostName hew",
        "    Port 22",
        "    Protocol 2",
        "",
        "Host qq",
        "    HostName qqq",
        "    Port 22",
        "",
        "Host q",
        "    Port 22",
        "",
        "Host *",
        "    Compression yes",
        ""]

def test_process():
    content = process.process(CONTENT)

    assert process.process(CONTENT) == """\
Host qeh
    HostName hew
    Port 22
    Protocol 2

Host qq
    HostName qqq
    Port 22

Host q
    Port 22

Host *
    Compression yes
"""

@@ -23,23 +23,8 @@
 -%0A%0A%0A
-import pytest%0A%0A
 impo
@@ -776,16 +776,17 @@
    %22%22%5D%0A%0A
+%0A
 def test
@@ -801,48 +801,8 @@
 ():%0A
-    content = process.process(CONTENT)%0A%0A
     

Fix flake8