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.
- {api → gibson/api}/Cli.py +6 -6
- {bin → gibson/bin}/gibson.py +2 -2
- {command → gibson/command}/Api.py +5 -6
- {command → gibson/command}/Base.py +4 -5
- {command → gibson/command}/BaseCommand.py +2 -2
- {command → gibson/command}/Build.py +2 -3
- {command → gibson/command}/Code.py +12 -11
- {command → gibson/command}/Conf.py +1 -1
- {command → gibson/command}/Dev.py +2 -3
- {command → gibson/command}/Import.py +4 -5
- {command → gibson/command}/List.py +2 -3
- {command → gibson/command}/Merge.py +2 -3
- {command → gibson/command}/Model.py +4 -5
- {command → gibson/command}/Models.py +4 -5
- {command → gibson/command}/Modify.py +2 -3
- {command → gibson/command}/Module.py +2 -3
- {command → gibson/command}/New.py +2 -3
- {command → gibson/command}/OpenApi.py +2 -3
- {command → gibson/command}/Question.py +2 -3
- {command → gibson/command}/Remove.py +3 -4
- {command → gibson/command}/Rename.py +3 -4
- {command → gibson/command}/Rewrite.py +3 -3
- {command → gibson/command}/Schema.py +4 -5
- {command → gibson/command}/Schemas.py +4 -5
- {command → gibson/command}/Test.py +4 -5
- {command → gibson/command}/Tests.py +4 -5
- {command → gibson/command}/Version.py +2 -2
- {command → gibson/command}/WarGames.py +2 -3
- {command → gibson/command}/auth/Auth.py +3 -3
- {command → gibson/command}/auth/Login.py +5 -6
- {command → gibson/command}/auth/Logout.py +1 -1
- {command → gibson/command}/tests/test_command_BaseCommand.py +2 -2
- {command → gibson/command}/tests/test_command_Conf.py +2 -2
- {conf → gibson/conf}/Dev.py +4 -4
- {conf → gibson/conf}/tests/test_conf_Dependencies.py +1 -1
- {conf → gibson/conf}/tests/test_conf_Platform.py +1 -1
- {core → gibson/core}/CommandRouter.py +34 -34
- gibson/core/Completions.py +35 -0
- {core → gibson/core}/Configuration.py +14 -11
- {core → gibson/core}/Conversation.py +8 -5
- {core → gibson/core}/Env.py +2 -2
- {core → gibson/core}/Memory.py +1 -1
- gibson/data/bash-completion.tmpl +96 -0
- {db → gibson/db}/tests/test_db_TableExceptions.py +1 -1
- {dev → gibson/dev}/Dev.py +2 -11
- {display → gibson/display}/tests/test_display_Header.py +1 -1
- {display → gibson/display}/tests/test_display_WorkspaceFooter.py +1 -1
- {display → gibson/display}/tests/test_display_WorkspaceHeader.py +1 -1
- {lang → gibson/lang}/Python.py +1 -1
- {lang → gibson/lang}/tests/test_lang_Python.py +1 -1
- {services → gibson/services}/auth/Server.py +11 -6
- {services → gibson/services}/code/context/schema/EntityKeys.py +3 -3
- {services → gibson/services}/code/context/schema/Manager.py +2 -2
- {services → gibson/services}/code/context/schema/tests/test_code_context_schema_DataDictionary.py +1 -1
- {services → gibson/services}/code/context/schema/tests/test_code_context_schema_EntityKeys.py +4 -4
- {services → gibson/services}/code/context/schema/tests/test_code_context_schema_Manager.py +2 -2
- {services → gibson/services}/code/customization/Authenticator.py +2 -2
- {services → gibson/services}/code/customization/BaseCustomization.py +1 -1
- {services → gibson/services}/code/customization/CustomizationManager.py +2 -2
- {services → gibson/services}/code/customization/tests/test_code_customization_Authenticator.py +2 -2
- {services → gibson/services}/code/customization/tests/test_code_customization_BaseCustomization.py +2 -2
- {structure → gibson/structure}/Entity.py +2 -2
- {structure → gibson/structure}/keys/ForeignKey.py +1 -1
- {structure → gibson/structure}/keys/Index.py +1 -1
- {structure → gibson/structure}/keys/tests/test_ForeignKey.py +2 -2
- {structure → gibson/structure}/keys/tests/test_Index.py +1 -1
- {structure → gibson/structure}/keys/tests/test_IndexAttribute.py +1 -1
- {structure → gibson/structure}/testing.py +1 -1
- {structure → gibson/structure}/tests/test_Entity.py +5 -5
- gibson/tests/test_Env.py +14 -0
- gibson/tests/test_Memory.py +89 -0
- gibson/tests/test_utils.py +20 -0
- {gibson_cli-0.1.2.dist-info → gibson_cli-0.1.3.dist-info}/METADATA +1 -1
- gibson_cli-0.1.3.dist-info/RECORD +108 -0
- {gibson_cli-0.1.2.dist-info → gibson_cli-0.1.3.dist-info}/WHEEL +1 -1
- gibson_cli-0.1.3.dist-info/entry_points.txt +2 -0
- gibson_cli-0.1.3.dist-info/top_level.txt +1 -0
- gibson_cli-0.1.2.dist-info/RECORD +0 -103
- gibson_cli-0.1.2.dist-info/entry_points.txt +0 -2
- gibson_cli-0.1.2.dist-info/top_level.txt +0 -12
- {api → gibson/api}/BaseApi.py +0 -0
- {command → gibson/command}/Count.py +0 -0
- {command → gibson/command}/Forget.py +0 -0
- {command → gibson/command}/Show.py +0 -0
- {command → gibson/command}/Tree.py +0 -0
- {conf → gibson/conf}/Api.py +0 -0
- {conf → gibson/conf}/Code.py +0 -0
- {conf → gibson/conf}/Custom.py +0 -0
- {conf → gibson/conf}/Datastore.py +0 -0
- {conf → gibson/conf}/Dependencies.py +0 -0
- {conf → gibson/conf}/Frameworks.py +0 -0
- {conf → gibson/conf}/Modeler.py +0 -0
- {conf → gibson/conf}/Paths.py +0 -0
- {conf → gibson/conf}/Platform.py +0 -0
- {conf → gibson/conf}/Project.py +0 -0
- {conf → gibson/conf}/Version.py +0 -0
- {conf → gibson/conf}/dev/Api.py +0 -0
- {conf → gibson/conf}/dev/Base.py +0 -0
- {conf → gibson/conf}/dev/Model.py +0 -0
- {conf → gibson/conf}/dev/Schema.py +0 -0
- {core → gibson/core}/TimeKeeper.py +0 -0
- {core → gibson/core}/utils.py +0 -0
- {data → gibson/data}/default-ref-table.tmpl +0 -0
- {data → gibson/data}/default-table.tmpl +0 -0
- {db → gibson/db}/TableExceptions.py +0 -0
- {display → gibson/display}/Header.py +0 -0
- {display → gibson/display}/WorkspaceFooter.py +0 -0
- {display → gibson/display}/WorkspaceHeader.py +0 -0
- {services → gibson/services}/code/context/schema/DataDictionary.py +0 -0
- {structure → gibson/structure}/constraints/ReferenceConstraint.py +0 -0
- {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.
|
10
|
-
from conf.
|
11
|
-
from conf.
|
12
|
-
from
|
13
|
-
from
|
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
|
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(
|
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
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
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
|
{core → gibson/core}/Env.py
RENAMED
{core → gibson/core}/Memory.py
RENAMED
@@ -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
|
{dev → gibson/dev}/Dev.py
RENAMED
@@ -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):
|
{lang → gibson/lang}/Python.py
RENAMED
@@ -27,7 +27,7 @@ class Python:
|
|
27
27
|
|
28
28
|
os_path = os.path.expandvars(os_path)
|
29
29
|
|
30
|
-
pythonpath = os.environ
|
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:
|
@@ -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
|
-
|
14
|
+
access_token = params.get("access_token", [""])[0]
|
15
|
+
refresh_token = params.get("refresh_token", [""])[0]
|
15
16
|
|
16
|
-
if
|
17
|
-
self.server.
|
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
|
-
|
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
|
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.
|
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:
|
{services → gibson/services}/code/context/schema/tests/test_code_context_schema_EntityKeys.py
RENAMED
@@ -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,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:
|
{services → gibson/services}/code/customization/tests/test_code_customization_Authenticator.py
RENAMED
@@ -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():
|
{services → gibson/services}/code/customization/tests/test_code_customization_BaseCustomization.py
RENAMED
@@ -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,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,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
|
)
|
gibson/tests/test_Env.py
ADDED
@@ -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
|