From 457689addcc0c7521dd7e5e314f9cba3e64a1d0f Mon Sep 17 00:00:00 2001 From: karina Date: Thu, 27 Jun 2024 12:11:06 +0300 Subject: [PATCH] #634 tests added --- tests/manifests/mermaid/test_mermaid.py | 243 ++++++++++++++---------- 1 file changed, 139 insertions(+), 104 deletions(-) diff --git a/tests/manifests/mermaid/test_mermaid.py b/tests/manifests/mermaid/test_mermaid.py index d9a1d2919..2ff9f10ef 100644 --- a/tests/manifests/mermaid/test_mermaid.py +++ b/tests/manifests/mermaid/test_mermaid.py @@ -6,12 +6,12 @@ def test_copy_mmd(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | | | - | | | Country | | | salis | | - | | | | name | string | | pavadinimas | | open + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | | | + | | | Country | | | salis | | + | | | | name | string | | pavadinimas | | open | | | | id | integer required| | id | | open ''')) @@ -35,16 +35,51 @@ class Country { } """ +def test_copy_mmd_access(context: Context, rc, cli: SpintaCliRunner, tmp_path): + create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | | | + | | | Country | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | id | integer required| | id | | private + | | | | continent | string | | pavadinimas | | protected + | | | | population | integer | | id | | public + ''')) + + cli.invoke(rc, [ + 'copy', + '--no-source', + '--access', 'open', + '-o', tmp_path / 'result.mmd', + tmp_path / 'manifest.csv', + ]) + + with open(tmp_path / 'result.mmd', "r") as file: + contents = file.read() + assert contents == """--- +datasets/gov/example +--- +classDiagram +class Country { ++ name : string [0..1] +- id : integer [1..1] +~ continent : string [0..1] +# population : integer [0..1] +} +""" + def test_copy_mmd_array(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | | | - | | | Country | | | salis | | - | | | | name[] | string | | pavadinimas | | open - | | | | id | integer required| | id | | open + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | | | + | | | Country | | | salis | | + | | | | name[] | string | | pavadinimas | | open + | | | | id | integer required| | id | | open ''')) cli.invoke(rc, [ @@ -70,17 +105,17 @@ class Country { def test_copy_mmd_enum(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | | | - | | | Country | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | id | integer required| | id | | open - | | | | continent| string | | | | open - | | | | | enum | | | "Africa"| - | | | | | | | | "Asia" | - | | | | | | | | "Europe"| + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | | | + | | | Country | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | id | integer required | | id | | open + | | | | continent | string | | | | open + | | | | | enum | | | "Africa" | + | | | | | | | | "Asia" | + | | | | | | | | "Europe" | ''')) cli.invoke(rc, [ @@ -113,17 +148,17 @@ class Country { def test_copy_mmd_ref(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | | | - | | | Country | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | id | integer required| | id | | open - | | | City | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | country | ref | Country | | | open - | | | | id | integer required| | id | | open + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | | | + | | | Country | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | id | integer required | | id | | open + | | | City | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | country | ref | Country | | | open + | | | | id | integer required | | id | | open ''')) cli.invoke(rc, [ @@ -154,17 +189,17 @@ class City { def test_copy_mmd_ref_required(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | | | - | | | Country | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | id | integer required | | id | | open - | | | City | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | country | ref required | Country | | | open - | | | | id | integer required | | id | | open + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | | | + | | | Country | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | id | integer required | | id | | open + | | | City | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | country | ref required | Country | | | open + | | | | id | integer required | | id | | open ''')) cli.invoke(rc, [ @@ -195,18 +230,18 @@ class City { def test_copy_mmd_backref(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | | | - | | | Country | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | id | integer required| | id | | open - | | | | cities[] | backref | City | | | open - | | | City | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | country | ref | Country | | | open - | | | | id | integer required| | id | | open + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | | | + | | | Country | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | id | integer required | | id | | open + | | | | cities[] | backref | City | | | open + | | | City | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | country | ref | Country | | | open + | | | | id | integer required | | id | | open ''')) cli.invoke(rc, [ @@ -238,18 +273,18 @@ class City { def test_copy_mmd_backref_not_array(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | | | - | | | Country | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | id | integer required| | id | | open - | | | | capital | backref | City | | | open - | | | City | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | country | ref | Country | | | open - | | | | id | integer required| | id | | open + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | | | + | | | Country | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | id | integer required | | id | | open + | | | | capital | backref | City | | | open + | | | City | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | country | ref | Country | | | open + | | | | id | integer required | | id | | open ''')) cli.invoke(rc, [ @@ -281,18 +316,18 @@ class City { def test_copy_mmd_backref_required(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | | | - | | | Country | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | id | integer required | | id | | open - | | | | cities[] | backref required | City | | | open - | | | City | | | salis | | - | | | | name | string | | pavadinimas | | open - | | | | country | ref | Country | | | open - | | | | id | integer required| | id | | open + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | | | + | | | Country | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | id | integer required | | id | | open + | | | | cities[] | backref required | City | | | open + | | | City | | | salis | | + | | | | name | string | | pavadinimas | | open + | | | | country | ref | Country | | | open + | | | | id | integer required | | id | | open ''')) cli.invoke(rc, [ @@ -324,17 +359,17 @@ class City { def test_copy_mmd_base(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | Settlement | | | | | - | | | | name | string | | | | open - | | | | id | integer required| | | | open - | | Settlement | | | | | | | - | | | City | | | miestas | | - | | | | name | | | pavadinimas | | open - | | | | id | | | id | | open - | | | | council | string | | taryba | | open + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | Settlement | | | | | + | | | | name | string | | | | open + | | | | id | integer required | | | | open + | | Settlement | | | | | + | | | City | | | miestas | | + | | | | name | | | pavadinimas | | open + | | | | id | | | id | | open + | | | | council | string | | taryba | | open ''')) cli.invoke(rc, [ @@ -364,17 +399,17 @@ class City { def test_copy_mmd_base_ref(context: Context, rc, cli: SpintaCliRunner, tmp_path): create_tabular_manifest(context, tmp_path / 'manifest.csv', striptable(''' - d | r | b | m | property | type | ref | source | prepare | access - datasets/gov/example | | | | | - | data | sql | | | | - | | | Settlement | | id | | | - | | | | name | string | | | | open - | | | | id | integer required| | | | open - | | Settlement | | | | id | | | - | | | City | | | miestas | | - | | | | name | | | pavadinimas | | open - | | | | id | | | id | | open - | | | | council | string | | taryba | | open + d | r | b | m | property | type | ref | source | prepare | access + datasets/gov/example | | | | | + | data | sql | | | | + | | | Settlement | | id | | | + | | | | name | string | | | | open + | | | | id | integer required | | | | open + | | Settlement | | id | | | + | | | City | | | miestas | | + | | | | name | | | pavadinimas | | open + | | | | id | | | id | | open + | | | | council | string | | taryba | | open ''')) cli.invoke(rc, [