gibson-cli 0.1.2__py3-none-any.whl → 0.1.3__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 (111) hide show
  1. {api → gibson/api}/Cli.py +6 -6
  2. {bin → gibson/bin}/gibson.py +2 -2
  3. {command → gibson/command}/Api.py +5 -6
  4. {command → gibson/command}/Base.py +4 -5
  5. {command → gibson/command}/BaseCommand.py +2 -2
  6. {command → gibson/command}/Build.py +2 -3
  7. {command → gibson/command}/Code.py +12 -11
  8. {command → gibson/command}/Conf.py +1 -1
  9. {command → gibson/command}/Dev.py +2 -3
  10. {command → gibson/command}/Import.py +4 -5
  11. {command → gibson/command}/List.py +2 -3
  12. {command → gibson/command}/Merge.py +2 -3
  13. {command → gibson/command}/Model.py +4 -5
  14. {command → gibson/command}/Models.py +4 -5
  15. {command → gibson/command}/Modify.py +2 -3
  16. {command → gibson/command}/Module.py +2 -3
  17. {command → gibson/command}/New.py +2 -3
  18. {command → gibson/command}/OpenApi.py +2 -3
  19. {command → gibson/command}/Question.py +2 -3
  20. {command → gibson/command}/Remove.py +3 -4
  21. {command → gibson/command}/Rename.py +3 -4
  22. {command → gibson/command}/Rewrite.py +3 -3
  23. {command → gibson/command}/Schema.py +4 -5
  24. {command → gibson/command}/Schemas.py +4 -5
  25. {command → gibson/command}/Test.py +4 -5
  26. {command → gibson/command}/Tests.py +4 -5
  27. {command → gibson/command}/Version.py +2 -2
  28. {command → gibson/command}/WarGames.py +2 -3
  29. {command → gibson/command}/auth/Auth.py +3 -3
  30. {command → gibson/command}/auth/Login.py +5 -6
  31. {command → gibson/command}/auth/Logout.py +1 -1
  32. {command → gibson/command}/tests/test_command_BaseCommand.py +2 -2
  33. {command → gibson/command}/tests/test_command_Conf.py +2 -2
  34. {conf → gibson/conf}/Dev.py +4 -4
  35. {conf → gibson/conf}/tests/test_conf_Dependencies.py +1 -1
  36. {conf → gibson/conf}/tests/test_conf_Platform.py +1 -1
  37. {core → gibson/core}/CommandRouter.py +34 -34
  38. gibson/core/Completions.py +35 -0
  39. {core → gibson/core}/Configuration.py +14 -11
  40. {core → gibson/core}/Conversation.py +8 -5
  41. {core → gibson/core}/Env.py +2 -2
  42. {core → gibson/core}/Memory.py +1 -1
  43. gibson/data/bash-completion.tmpl +96 -0
  44. {db → gibson/db}/tests/test_db_TableExceptions.py +1 -1
  45. {dev → gibson/dev}/Dev.py +2 -11
  46. {display → gibson/display}/tests/test_display_Header.py +1 -1
  47. {display → gibson/display}/tests/test_display_WorkspaceFooter.py +1 -1
  48. {display → gibson/display}/tests/test_display_WorkspaceHeader.py +1 -1
  49. {lang → gibson/lang}/Python.py +1 -1
  50. {lang → gibson/lang}/tests/test_lang_Python.py +1 -1
  51. {services → gibson/services}/auth/Server.py +11 -6
  52. {services → gibson/services}/code/context/schema/EntityKeys.py +3 -3
  53. {services → gibson/services}/code/context/schema/Manager.py +2 -2
  54. {services → gibson/services}/code/context/schema/tests/test_code_context_schema_DataDictionary.py +1 -1
  55. {services → gibson/services}/code/context/schema/tests/test_code_context_schema_EntityKeys.py +4 -4
  56. {services → gibson/services}/code/context/schema/tests/test_code_context_schema_Manager.py +2 -2
  57. {services → gibson/services}/code/customization/Authenticator.py +2 -2
  58. {services → gibson/services}/code/customization/BaseCustomization.py +1 -1
  59. {services → gibson/services}/code/customization/CustomizationManager.py +2 -2
  60. {services → gibson/services}/code/customization/tests/test_code_customization_Authenticator.py +2 -2
  61. {services → gibson/services}/code/customization/tests/test_code_customization_BaseCustomization.py +2 -2
  62. {structure → gibson/structure}/Entity.py +2 -2
  63. {structure → gibson/structure}/keys/ForeignKey.py +1 -1
  64. {structure → gibson/structure}/keys/Index.py +1 -1
  65. {structure → gibson/structure}/keys/tests/test_ForeignKey.py +2 -2
  66. {structure → gibson/structure}/keys/tests/test_Index.py +1 -1
  67. {structure → gibson/structure}/keys/tests/test_IndexAttribute.py +1 -1
  68. {structure → gibson/structure}/testing.py +1 -1
  69. {structure → gibson/structure}/tests/test_Entity.py +5 -5
  70. gibson/tests/test_Env.py +14 -0
  71. gibson/tests/test_Memory.py +89 -0
  72. gibson/tests/test_utils.py +20 -0
  73. {gibson_cli-0.1.2.dist-info → gibson_cli-0.1.3.dist-info}/METADATA +1 -1
  74. gibson_cli-0.1.3.dist-info/RECORD +108 -0
  75. {gibson_cli-0.1.2.dist-info → gibson_cli-0.1.3.dist-info}/WHEEL +1 -1
  76. gibson_cli-0.1.3.dist-info/entry_points.txt +2 -0
  77. gibson_cli-0.1.3.dist-info/top_level.txt +1 -0
  78. gibson_cli-0.1.2.dist-info/RECORD +0 -103
  79. gibson_cli-0.1.2.dist-info/entry_points.txt +0 -2
  80. gibson_cli-0.1.2.dist-info/top_level.txt +0 -12
  81. {api → gibson/api}/BaseApi.py +0 -0
  82. {command → gibson/command}/Count.py +0 -0
  83. {command → gibson/command}/Forget.py +0 -0
  84. {command → gibson/command}/Show.py +0 -0
  85. {command → gibson/command}/Tree.py +0 -0
  86. {conf → gibson/conf}/Api.py +0 -0
  87. {conf → gibson/conf}/Code.py +0 -0
  88. {conf → gibson/conf}/Custom.py +0 -0
  89. {conf → gibson/conf}/Datastore.py +0 -0
  90. {conf → gibson/conf}/Dependencies.py +0 -0
  91. {conf → gibson/conf}/Frameworks.py +0 -0
  92. {conf → gibson/conf}/Modeler.py +0 -0
  93. {conf → gibson/conf}/Paths.py +0 -0
  94. {conf → gibson/conf}/Platform.py +0 -0
  95. {conf → gibson/conf}/Project.py +0 -0
  96. {conf → gibson/conf}/Version.py +0 -0
  97. {conf → gibson/conf}/dev/Api.py +0 -0
  98. {conf → gibson/conf}/dev/Base.py +0 -0
  99. {conf → gibson/conf}/dev/Model.py +0 -0
  100. {conf → gibson/conf}/dev/Schema.py +0 -0
  101. {core → gibson/core}/TimeKeeper.py +0 -0
  102. {core → gibson/core}/utils.py +0 -0
  103. {data → gibson/data}/default-ref-table.tmpl +0 -0
  104. {data → gibson/data}/default-table.tmpl +0 -0
  105. {db → gibson/db}/TableExceptions.py +0 -0
  106. {display → gibson/display}/Header.py +0 -0
  107. {display → gibson/display}/WorkspaceFooter.py +0 -0
  108. {display → gibson/display}/WorkspaceHeader.py +0 -0
  109. {services → gibson/services}/code/context/schema/DataDictionary.py +0 -0
  110. {structure → gibson/structure}/constraints/ReferenceConstraint.py +0 -0
  111. {structure → gibson/structure}/keys/IndexAttribute.py +0 -0
@@ -5,15 +5,12 @@ import shutil
5
5
  import sys
6
6
  import time
7
7
 
8
- from conf.Dependencies import Dependencies
9
- from conf.dev.Api import Api
10
- from conf.dev.Base import Base
11
- from conf.dev.Model import Model
12
- from conf.dev.Schema import Schema
13
- from conf.Platform import Platform
14
- from conf.Project import Project
15
- from conf.Paths import ConfigPaths
16
- from .Conversation import Conversation
8
+ from gibson.conf.Dependencies import Dependencies
9
+ from gibson.conf.Platform import Platform
10
+ from gibson.conf.Project import Project
11
+ from gibson.conf.Paths import ConfigPaths
12
+ from gibson.core.Completions import Completions
13
+ from gibson.core.Conversation import Conversation
17
14
 
18
15
 
19
16
  class Configuration:
@@ -38,6 +35,8 @@ class Configuration:
38
35
 
39
36
  self.read_config()
40
37
 
38
+ Completions().write().install()
39
+
41
40
  def append_project_to_conf(self, project_name, project_description):
42
41
  self.project.api.key = "FIXME"
43
42
  self.project.name = project_name
@@ -351,14 +350,18 @@ class Configuration:
351
350
 
352
351
  return self
353
352
 
354
- def set_access_token(self, token):
353
+ def set_auth_tokens(self, access_token, refresh_token):
355
354
  try:
356
355
  os.mkdir(self.paths.auth)
357
356
  except FileExistsError:
358
357
  pass
359
358
 
360
359
  with open(f"{self.paths.auth}/{self.API_ENV}", "w") as f:
361
- f.write(json.dumps({"access_token": token}))
360
+ f.write(
361
+ json.dumps(
362
+ {"access_token": access_token, "refresh_token": refresh_token}
363
+ )
364
+ )
362
365
 
363
366
  def set_config_paths(self, ignore_env_vars=False):
364
367
  user_home = os.environ.get("HOME")
@@ -5,7 +5,7 @@ import time
5
5
 
6
6
  import pyfiglet
7
7
 
8
- from conf.Version import Version
8
+ from gibson.conf.Version import Version
9
9
 
10
10
 
11
11
  class Conversation:
@@ -234,10 +234,13 @@ class Conversation:
234
234
  if self.__delay is not None:
235
235
  delay = self.__delay
236
236
 
237
- for char in message:
238
- sys.stdout.write(char)
239
- sys.stdout.flush()
240
- time.sleep(delay)
237
+ try:
238
+ for char in message:
239
+ sys.stdout.write(char)
240
+ sys.stdout.flush()
241
+ time.sleep(delay)
242
+ except KeyboardInterrupt:
243
+ exit(1)
241
244
 
242
245
  def unmute(self):
243
246
  self.__mute = False
@@ -1,5 +1,5 @@
1
- from .Configuration import Configuration
2
- from lang.Python import Python
1
+ from gibson.core.Configuration import Configuration
2
+ from gibson.lang.Python import Python
3
3
 
4
4
 
5
5
  class Env:
@@ -1,7 +1,7 @@
1
1
  import json
2
2
  import os
3
3
 
4
- from .Configuration import Configuration
4
+ from gibson.core.Configuration import Configuration
5
5
 
6
6
 
7
7
  class Memory:
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # bash completion for Gibson CLI
4
+
5
+ if ! command -v gibson &>/dev/null; then
6
+ return
7
+ fi
8
+
9
+ __gibson_generate_completion() {
10
+ declare current_word
11
+ current_word="${COMP_WORDS[COMP_CWORD]}"
12
+ # shellcheck disable=SC2207
13
+ COMPREPLY=($(compgen -W "$1" -- "${current_word}"))
14
+ return 0
15
+ }
16
+
17
+ __gibson_commands_and_options() {
18
+ declare current_word
19
+ declare command
20
+
21
+ current_word="${COMP_WORDS[COMP_CWORD]}"
22
+ COMMANDS='
23
+ auth
24
+ build
25
+ code
26
+ conf
27
+ count
28
+ create
29
+ dev
30
+ forget
31
+ help
32
+ import
33
+ list
34
+ merge
35
+ model
36
+ modify
37
+ new
38
+ openapi
39
+ project
40
+ question
41
+ remove
42
+ rename
43
+ rewrite
44
+ schema
45
+ show
46
+ test
47
+ tree
48
+ q
49
+ '
50
+
51
+ case "${current_word}" in
52
+ -*) __gibson_options ;;
53
+ *) __gibson_generate_completion "${COMMANDS}" ;;
54
+ esac
55
+ }
56
+
57
+ __gibson_options() {
58
+ OPTIONS='--version -v'
59
+ __gibson_generate_completion "${OPTIONS}"
60
+ }
61
+
62
+ __gibson_completions() {
63
+ declare previous_word
64
+ previous_word="${COMP_WORDS[COMP_CWORD - 1]}"
65
+
66
+ case "${previous_word}" in
67
+ gibson) __gibson_commands_and_options ;;
68
+ auth) __gibson_generate_completion "login logout" ;;
69
+ # config) __gibson_generate_completion "set get" ;;
70
+ # create) __gibson_generate_completion "project module entity" ;;
71
+ # new) __gibson_generate_completion "project module entity" ;;
72
+ # project) __gibson_generate_completion "create delete list" ;;
73
+ # rename) __gibson_generate_completion "entity" ;;
74
+ # rewrite) __gibson_generate_completion "api base models schemas tests" ;;
75
+ esac
76
+
77
+ return 0
78
+ }
79
+
80
+ # complete is a bash builtin, but recent versions of ZSH come with a function
81
+ # called bashcompinit that will create a complete in ZSH. If the user is in
82
+ # ZSH, load and run bashcompinit before calling the complete function.
83
+ if [[ -n ${ZSH_VERSION-} ]]; then
84
+ # First calling compinit (only if not called yet!)
85
+ # and then bashcompinit as mentioned by zsh man page.
86
+ if ! command -v compinit >/dev/null; then
87
+ autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then
88
+ compinit -u
89
+ else
90
+ compinit
91
+ fi
92
+ fi
93
+ autoload -U +X bashcompinit && bashcompinit
94
+ fi
95
+
96
+ complete -o default -F __gibson_completions gibson
@@ -1,4 +1,4 @@
1
- from db.TableExceptions import TableExceptions
1
+ from gibson.db.TableExceptions import TableExceptions
2
2
 
3
3
 
4
4
  def test_universal():
@@ -1,7 +1,7 @@
1
1
  import os
2
2
 
3
- from core.Configuration import Configuration
4
- from core.utils import (
3
+ from gibson.core.Configuration import Configuration
4
+ from gibson.core.utils import (
5
5
  utils_entity_name_to_class_name,
6
6
  utils_extract_module_name,
7
7
  utils_is_ref_table,
@@ -18,15 +18,6 @@ class Dev:
18
18
  f"{self.configuration.project.dev.api.version}/{file_name}",
19
19
  code,
20
20
  )
21
-
22
- if file_name == "authenticators/DenyAll.py":
23
- self.link(
24
- os.path.expandvars(self.configuration.project.dev.api.path),
25
- self.configuration.project.dev.api.version
26
- + "/authenticators/DenyAll.py",
27
- self.configuration.project.dev.api.version + "/Authenticator.py",
28
- )
29
-
30
21
  return self
31
22
 
32
23
  def base_component(self, file_name, code):
@@ -1,4 +1,4 @@
1
- from display.Header import Header
1
+ from gibson.display.Header import Header
2
2
 
3
3
 
4
4
  def test_render():
@@ -1,4 +1,4 @@
1
- from display.WorkspaceFooter import WorkspaceFooter
1
+ from gibson.display.WorkspaceFooter import WorkspaceFooter
2
2
 
3
3
 
4
4
  def test_render():
@@ -1,4 +1,4 @@
1
- from display.WorkspaceHeader import WorkspaceHeader
1
+ from gibson.display.WorkspaceHeader import WorkspaceHeader
2
2
 
3
3
 
4
4
  def test_render():
@@ -27,7 +27,7 @@ class Python:
27
27
 
28
28
  os_path = os.path.expandvars(os_path)
29
29
 
30
- pythonpath = os.environ["PYTHONPATH"].split(":")
30
+ pythonpath = os.environ.get("PYTHONPATH", "").split(":")
31
31
  for entry in pythonpath:
32
32
  path = os_path.replace(entry, "")
33
33
  if path != os_path:
@@ -2,7 +2,7 @@ import os
2
2
 
3
3
  import pytest
4
4
 
5
- from lang.Python import Python
5
+ from gibson.lang.Python import Python
6
6
 
7
7
 
8
8
  def test_make_python_path_no_match():
@@ -11,10 +11,14 @@ class Handler(BaseHTTPRequestHandler):
11
11
  def do_GET(self):
12
12
  url = urlparse(self.path)
13
13
  params = parse_qs(url.query)
14
- token = params.get("token", [""])[0]
14
+ access_token = params.get("access_token", [""])[0]
15
+ refresh_token = params.get("refresh_token", [""])[0]
15
16
 
16
- if token:
17
- self.server.token = token
17
+ if access_token and access_token != "null":
18
+ self.server.access_token = access_token
19
+
20
+ if refresh_token and refresh_token != "null":
21
+ self.server.refresh_token = refresh_token
18
22
 
19
23
  self.send_response(302)
20
24
  self.send_header("Location", f"{self.server.app_domain}/chat")
@@ -29,7 +33,8 @@ class Handler(BaseHTTPRequestHandler):
29
33
  # Temporary HTTP server to handle the login process
30
34
  class Server(HTTPServer):
31
35
  port = None
32
- token = None
36
+ access_token = None
37
+ refresh_token = None
33
38
  thread = None
34
39
 
35
40
  def __init__(self, app_domain: str):
@@ -40,7 +45,7 @@ class Server(HTTPServer):
40
45
 
41
46
  self.app_domain = app_domain
42
47
 
43
- def get_token(self):
48
+ def get_tokens(self):
44
49
  self._start()
45
50
  self._open_browser()
46
51
 
@@ -50,7 +55,7 @@ class Server(HTTPServer):
50
55
  except KeyboardInterrupt:
51
56
  self._stop()
52
57
 
53
- return self.token
58
+ return self.access_token, self.refresh_token
54
59
 
55
60
  def _open_browser(self):
56
61
  webbrowser.open(f"{self.app_domain}/signup?cli={self.port}")
@@ -1,6 +1,6 @@
1
- from structure.constraints.ReferenceConstraint import ReferenceConstraint
2
- from structure.keys.ForeignKey import ForeignKey
3
- from structure.keys.Index import Index
1
+ from gibson.structure.constraints.ReferenceConstraint import ReferenceConstraint
2
+ from gibson.structure.keys.ForeignKey import ForeignKey
3
+ from gibson.structure.keys.Index import Index
4
4
 
5
5
 
6
6
  class EntityKeys:
@@ -1,5 +1,5 @@
1
- from services.code.context.schema.DataDictionary import DataDictionary
2
- from services.code.context.schema.EntityKeys import EntityKeys
1
+ from gibson.services.code.context.schema.DataDictionary import DataDictionary
2
+ from gibson.services.code.context.schema.EntityKeys import EntityKeys
3
3
 
4
4
 
5
5
  class Manager:
@@ -1,4 +1,4 @@
1
- from services.code.context.schema.DataDictionary import DataDictionary
1
+ from gibson.services.code.context.schema.DataDictionary import DataDictionary
2
2
 
3
3
 
4
4
  def test_configure():
@@ -1,7 +1,7 @@
1
- from services.code.context.schema.EntityKeys import EntityKeys
2
- from structure.constraints.ReferenceConstraint import ReferenceConstraint
3
- from structure.keys.ForeignKey import ForeignKey
4
- from structure.keys.Index import Index
1
+ from gibson.services.code.context.schema.EntityKeys import EntityKeys
2
+ from gibson.structure.constraints.ReferenceConstraint import ReferenceConstraint
3
+ from gibson.structure.keys.ForeignKey import ForeignKey
4
+ from gibson.structure.keys.Index import Index
5
5
 
6
6
 
7
7
  def test_best_sql_foreign_key_no_match():
@@ -1,5 +1,5 @@
1
- from services.code.context.schema.EntityKeys import EntityKeys
2
- from services.code.context.schema.Manager import Manager
1
+ from gibson.services.code.context.schema.EntityKeys import EntityKeys
2
+ from gibson.services.code.context.schema.Manager import Manager
3
3
 
4
4
 
5
5
  def test_get_entity_keys_no_such_entity_name():
@@ -1,7 +1,7 @@
1
1
  import os
2
2
 
3
- from core.Configuration import Configuration
4
- from services.code.customization.BaseCustomization import BaseCustomization
3
+ from gibson.core.Configuration import Configuration
4
+ from gibson.services.code.customization.BaseCustomization import BaseCustomization
5
5
 
6
6
 
7
7
  class Authenticator(BaseCustomization):
@@ -1,4 +1,4 @@
1
- from core.Configuration import Configuration
1
+ from gibson.core.Configuration import Configuration
2
2
 
3
3
 
4
4
  class BaseCustomization:
@@ -1,5 +1,5 @@
1
- from core.Configuration import Configuration
2
- from services.code.customization.Authenticator import Authenticator
1
+ from gibson.core.Configuration import Configuration
2
+ from gibson.services.code.customization.Authenticator import Authenticator
3
3
 
4
4
 
5
5
  class CustomizationManager:
@@ -1,8 +1,8 @@
1
1
  import os
2
2
  import shutil
3
3
 
4
- from core.Configuration import Configuration
5
- from services.code.customization.Authenticator import Authenticator
4
+ from gibson.core.Configuration import Configuration
5
+ from gibson.services.code.customization.Authenticator import Authenticator
6
6
 
7
7
 
8
8
  def test_link_target():
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
 
3
- from core.Configuration import Configuration
4
- from services.code.customization.BaseCustomization import BaseCustomization
3
+ from gibson.core.Configuration import Configuration
4
+ from gibson.services.code.customization.BaseCustomization import BaseCustomization
5
5
 
6
6
 
7
7
  def test_preserve_exception():
@@ -1,5 +1,5 @@
1
- from structure.keys.ForeignKey import ForeignKey
2
- from structure.keys.Index import Index
1
+ from gibson.structure.keys.ForeignKey import ForeignKey
2
+ from gibson.structure.keys.Index import Index
3
3
 
4
4
 
5
5
  class Entity:
@@ -1,4 +1,4 @@
1
- from structure.constraints.ReferenceConstraint import ReferenceConstraint
1
+ from gibson.structure.constraints.ReferenceConstraint import ReferenceConstraint
2
2
 
3
3
 
4
4
  class ForeignKey:
@@ -1,4 +1,4 @@
1
- from structure.keys.IndexAttribute import IndexAttribute
1
+ from gibson.structure.keys.IndexAttribute import IndexAttribute
2
2
 
3
3
 
4
4
  class Index:
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
 
3
- from structure.constraints.ReferenceConstraint import ReferenceConstraint
4
- from structure.keys.ForeignKey import ForeignKey
3
+ from gibson.structure.constraints.ReferenceConstraint import ReferenceConstraint
4
+ from gibson.structure.keys.ForeignKey import ForeignKey
5
5
 
6
6
 
7
7
  def test_sql_exceptions():
@@ -1,6 +1,6 @@
1
1
  import pytest
2
2
 
3
- from structure.keys.Index import Index
3
+ from gibson.structure.keys.Index import Index
4
4
 
5
5
 
6
6
  def test_sql_exceptions():
@@ -1,4 +1,4 @@
1
- from structure.keys.IndexAttribute import IndexAttribute
1
+ from gibson.structure.keys.IndexAttribute import IndexAttribute
2
2
 
3
3
 
4
4
  def test_sql():
@@ -1,4 +1,4 @@
1
- from structure.Entity import Entity
1
+ from gibson.structure.Entity import Entity
2
2
 
3
3
 
4
4
  def structure_testing_get_entity():
@@ -1,10 +1,10 @@
1
1
  import pytest
2
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 (
3
+ from gibson.structure.constraints.ReferenceConstraint import ReferenceConstraint
4
+ from gibson.structure.Entity import Entity
5
+ from gibson.structure.keys.ForeignKey import ForeignKey
6
+ from gibson.structure.keys.Index import Index
7
+ from gibson.structure.testing import (
8
8
  structure_testing_get_entity,
9
9
  structure_testing_get_struct_data,
10
10
  )
@@ -0,0 +1,14 @@
1
+ import pytest
2
+
3
+ from gibson.core.Configuration import Configuration
4
+ from gibson.core.Env import Env
5
+
6
+
7
+ def test_verify_language_exception():
8
+ configuration = Configuration()
9
+ configuration.project.code.language = "invalid"
10
+
11
+ with pytest.raises(RuntimeError) as e:
12
+ Env().verify(configuration)
13
+
14
+ assert str(e.value) == 'unrecognized language "invalid"'
@@ -0,0 +1,89 @@
1
+ from gibson.core.Configuration import Configuration
2
+ from gibson.core.Memory import Memory
3
+
4
+
5
+ def test_recall_merged_no_entities():
6
+ memory = Memory(Configuration())
7
+ memory.entities = None
8
+ memory.last = None
9
+
10
+ assert memory.recall_merged() == []
11
+
12
+
13
+ def test_recall_merged_entities_only():
14
+ memory = Memory(Configuration())
15
+ memory.entities = [{"definition": "abc", "name": "def"}]
16
+ memory.last = None
17
+
18
+ assert memory.recall_merged() == [{"definition": "abc", "name": "def"}]
19
+
20
+
21
+ def test_recall_merged_last_only():
22
+ memory = Memory(Configuration())
23
+ memory.entities = None
24
+ memory.last = {"entities": [{"definition": "abc", "name": "def"}]}
25
+
26
+ assert memory.recall_merged() == [{"definition": "abc", "name": "def"}]
27
+
28
+
29
+ def test_recall_merged_no_overlap():
30
+ memory = Memory(Configuration())
31
+ memory.entities = [{"definition": "abc", "name": "def"}]
32
+ memory.last = {"entities": [{"definition": "ghi", "name": "jkl"}]}
33
+
34
+ assert memory.recall_merged() == [
35
+ {"definition": "ghi", "name": "jkl"},
36
+ {"definition": "abc", "name": "def"},
37
+ ]
38
+
39
+
40
+ def test_recall_merged_overlap():
41
+ memory = Memory(Configuration())
42
+ memory.entities = [
43
+ {"definition": "abc", "name": "def"},
44
+ {"definition": "ghi", "name": "jkl"},
45
+ ]
46
+ memory.last = {
47
+ "entities": [
48
+ {"definition": "xyz", "name": "def"},
49
+ {"definition": "mno", "name": "pqr"},
50
+ ]
51
+ }
52
+
53
+ assert memory.recall_merged() == [
54
+ {"definition": "xyz", "name": "def"},
55
+ {"definition": "mno", "name": "pqr"},
56
+ {"definition": "ghi", "name": "jkl"},
57
+ ]
58
+
59
+
60
+ def test_recall_entity_none():
61
+ memory = Memory(Configuration())
62
+ memory.entities = None
63
+ memory.last = None
64
+
65
+ assert memory.recall_entity("abc") is None
66
+
67
+
68
+ def test_recall_entity_entities():
69
+ memory = Memory(Configuration())
70
+ memory.entities = [{"definition": "abc", "name": "def"}]
71
+ memory.last = None
72
+
73
+ assert memory.recall_entity("def") == {"definition": "abc", "name": "def"}
74
+
75
+
76
+ def test_recall_entity_last():
77
+ memory = Memory(Configuration())
78
+ memory.entities = None
79
+ memory.last = {"entities": [{"definition": "abc", "name": "def"}]}
80
+
81
+ assert memory.recall_entity("def") == {"definition": "abc", "name": "def"}
82
+
83
+
84
+ def test_recall_entity_prefer_last():
85
+ memory = Memory(Configuration())
86
+ memory.entities = [{"definition": "abc", "name": "def"}]
87
+ memory.last = {"entities": [{"definition": "xyz", "name": "def"}]}
88
+
89
+ assert memory.recall_entity("def") == {"definition": "xyz", "name": "def"}
@@ -0,0 +1,20 @@
1
+ from gibson.core.utils import (
2
+ utils_entity_name_to_class_name,
3
+ utils_extract_module_name,
4
+ utils_is_ref_table,
5
+ )
6
+
7
+
8
+ def test_entity_name_to_class_name():
9
+ assert utils_entity_name_to_class_name("abc_def_ghi") == "AbcDefGhi"
10
+
11
+
12
+ def test_extract_module_name():
13
+ assert utils_extract_module_name("abc_def_ghi") == "abc"
14
+
15
+
16
+ def test_is_ref_table():
17
+ assert utils_is_ref_table("abc") is False
18
+ assert utils_is_ref_table("abc_def") is False
19
+ assert utils_is_ref_table("abc_ref") is True
20
+ assert utils_is_ref_table("abc_ref_def") is True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gibson-cli
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Gibson Command Line Interface
5
5
  Author-email: GibsonAI <noc@gibsonai.com>
6
6
  Project-URL: Homepage, https://gibsonai.com/