gibson-cli 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. api/BaseApi.py +45 -0
  2. api/Cli.py +248 -0
  3. bin/gibson.py +16 -0
  4. command/Api.py +31 -0
  5. command/Base.py +28 -0
  6. command/BaseCommand.py +26 -0
  7. command/Build.py +69 -0
  8. command/Code.py +198 -0
  9. command/Conf.py +74 -0
  10. command/Count.py +35 -0
  11. command/Dev.py +121 -0
  12. command/Forget.py +34 -0
  13. command/Import.py +109 -0
  14. command/List.py +61 -0
  15. command/Merge.py +35 -0
  16. command/Model.py +42 -0
  17. command/Models.py +31 -0
  18. command/Modify.py +43 -0
  19. command/Module.py +42 -0
  20. command/New.py +38 -0
  21. command/OpenApi.py +141 -0
  22. command/Question.py +105 -0
  23. command/Remove.py +80 -0
  24. command/Rename.py +71 -0
  25. command/Rewrite.py +107 -0
  26. command/Schema.py +42 -0
  27. command/Schemas.py +31 -0
  28. command/Show.py +37 -0
  29. command/Test.py +42 -0
  30. command/Tests.py +31 -0
  31. command/Tree.py +92 -0
  32. command/WarGames.py +35 -0
  33. command/auth/Auth.py +25 -0
  34. command/auth/Login.py +17 -0
  35. command/auth/Logout.py +7 -0
  36. command/tests/test_command_BaseCommand.py +10 -0
  37. command/tests/test_command_Conf.py +19 -0
  38. conf/Api.py +3 -0
  39. conf/Code.py +9 -0
  40. conf/Custom.py +4 -0
  41. conf/Datastore.py +4 -0
  42. conf/Dependencies.py +24 -0
  43. conf/Dev.py +15 -0
  44. conf/Frameworks.py +7 -0
  45. conf/Modeler.py +3 -0
  46. conf/Paths.py +10 -0
  47. conf/Platform.py +16 -0
  48. conf/Project.py +18 -0
  49. conf/Version.py +2 -0
  50. conf/dev/Api.py +5 -0
  51. conf/dev/Base.py +3 -0
  52. conf/dev/Model.py +3 -0
  53. conf/dev/Schema.py +3 -0
  54. conf/tests/test_conf_Dependencies.py +5 -0
  55. conf/tests/test_conf_Platform.py +7 -0
  56. core/CommandRouter.py +249 -0
  57. core/Configuration.py +418 -0
  58. core/Conversation.py +270 -0
  59. core/Env.py +12 -0
  60. core/Memory.py +148 -0
  61. core/TimeKeeper.py +12 -0
  62. core/utils.py +19 -0
  63. data/default-ref-table.tmpl +4 -0
  64. data/default-table.tmpl +6 -0
  65. db/TableExceptions.py +6 -0
  66. db/tests/test_db_TableExceptions.py +9 -0
  67. dev/Dev.py +92 -0
  68. display/Header.py +6 -0
  69. display/WorkspaceFooter.py +10 -0
  70. display/WorkspaceHeader.py +8 -0
  71. display/tests/test_display_Header.py +9 -0
  72. display/tests/test_display_WorkspaceFooter.py +9 -0
  73. display/tests/test_display_WorkspaceHeader.py +8 -0
  74. gibson_cli-0.1.0.dist-info/METADATA +306 -0
  75. gibson_cli-0.1.0.dist-info/RECORD +102 -0
  76. gibson_cli-0.1.0.dist-info/WHEEL +5 -0
  77. gibson_cli-0.1.0.dist-info/entry_points.txt +2 -0
  78. gibson_cli-0.1.0.dist-info/top_level.txt +12 -0
  79. lang/Python.py +57 -0
  80. lang/tests/test_lang_Python.py +70 -0
  81. services/auth/Server.py +75 -0
  82. services/code/context/schema/DataDictionary.py +12 -0
  83. services/code/context/schema/EntityKeys.py +49 -0
  84. services/code/context/schema/Manager.py +28 -0
  85. services/code/context/schema/tests/test_code_context_schema_DataDictionary.py +8 -0
  86. services/code/context/schema/tests/test_code_context_schema_EntityKeys.py +52 -0
  87. services/code/context/schema/tests/test_code_context_schema_Manager.py +34 -0
  88. services/code/customization/Authenticator.py +51 -0
  89. services/code/customization/BaseCustomization.py +12 -0
  90. services/code/customization/CustomizationManager.py +20 -0
  91. services/code/customization/tests/test_code_customization_Authenticator.py +53 -0
  92. services/code/customization/tests/test_code_customization_BaseCustomization.py +14 -0
  93. structure/Entity.py +115 -0
  94. structure/constraints/ReferenceConstraint.py +36 -0
  95. structure/keys/ForeignKey.py +41 -0
  96. structure/keys/Index.py +64 -0
  97. structure/keys/IndexAttribute.py +14 -0
  98. structure/keys/tests/test_ForeignKey.py +80 -0
  99. structure/keys/tests/test_Index.py +98 -0
  100. structure/keys/tests/test_IndexAttribute.py +17 -0
  101. structure/testing.py +194 -0
  102. structure/tests/test_Entity.py +107 -0
@@ -0,0 +1,107 @@
1
+ import pytest
2
+
3
+ from structure.constraints.ReferenceConstraint import ReferenceConstraint
4
+ from structure.Entity import Entity
5
+ from structure.keys.ForeignKey import ForeignKey
6
+ from structure.keys.Index import Index
7
+ from structure.testing import (
8
+ structure_testing_get_entity,
9
+ structure_testing_get_struct_data,
10
+ )
11
+
12
+
13
+ def test_add_foreign_key():
14
+ reference_constraint = ReferenceConstraint()
15
+ reference_constraint.attributes = ["a", "b"]
16
+ reference_constraint.references = "abc_def"
17
+
18
+ foreign_key = ForeignKey()
19
+ foreign_key.attributes = ["c", "d"]
20
+ foreign_key.reference = reference_constraint
21
+
22
+ entity = structure_testing_get_entity()
23
+ entity.add_foreign_key(foreign_key)
24
+
25
+ assert entity.keys["foreign"] == [
26
+ {
27
+ "attributes": ["c", "d"],
28
+ "name": None,
29
+ "reference": {
30
+ "attributes": ["a", "b"],
31
+ "match": None,
32
+ "on": {"delete": None, "update": None},
33
+ "references": "abc_def",
34
+ "sql": "references abc_def (a, b)",
35
+ },
36
+ "relationship": {"type": None},
37
+ "sql": "foreign key (c, d) references abc_def (a, b)",
38
+ "symbol": None,
39
+ }
40
+ ]
41
+
42
+
43
+ def test_add_attribute_after():
44
+ entity = structure_testing_get_entity()
45
+ entity.add_attribute("abc", "bigint", after="uuid")
46
+
47
+ assert entity.attributes[2]["sql"] == "abc bigint"
48
+
49
+
50
+ def test_add_attribute_before():
51
+ entity = structure_testing_get_entity()
52
+ entity.add_attribute("abc", "bigint", before="uuid")
53
+
54
+ assert entity.attributes[1]["sql"] == "abc bigint"
55
+
56
+
57
+ def test_add_attribute_append():
58
+ entity = structure_testing_get_entity()
59
+ entity.add_attribute("abc", "bigint")
60
+
61
+ assert entity.attributes[-1]["sql"] == "abc bigint"
62
+
63
+
64
+ def test_add_index():
65
+ index = Index()
66
+ index.add_attribute("abc")
67
+ index.add_attribute("def")
68
+
69
+ entity = structure_testing_get_entity()
70
+ entity.add_index(index)
71
+
72
+ assert entity.keys["index"] == [
73
+ {
74
+ "attributes": ["abc", "def"],
75
+ "name": None,
76
+ "sql": "index (abc, def)",
77
+ "using": None,
78
+ }
79
+ ]
80
+
81
+
82
+ def test_import_from_struct_incorrect_data_format():
83
+ with pytest.raises(RuntimeError) as e:
84
+ Entity().import_from_struct({"abc": "def"})
85
+
86
+ assert str(e.value) == "cannot import from struct, incorrect data format"
87
+
88
+
89
+ def test_import_from_struct():
90
+ entity = Entity().import_from_struct(structure_testing_get_struct_data())
91
+
92
+ assert entity.name == "abc_def"
93
+ assert len(entity.attributes) == 4
94
+ assert entity.attributes[0]["name"] == "id"
95
+ assert entity.attributes[1]["name"] == "uuid"
96
+ assert entity.attributes[2]["name"] == "date_created"
97
+ assert entity.attributes[3]["name"] == "date_updated"
98
+ assert entity.constraints == {"check": []}
99
+ assert entity.keys == {"foreign": [], "index": [], "primary": None, "unique": []}
100
+ assert entity.parameters == {
101
+ "auto": None,
102
+ "charset": None,
103
+ "collate": None,
104
+ "default": None,
105
+ "engine": None,
106
+ "sql": None,
107
+ }