Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sams-classes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
coding-at-fu
sams-classes
Commits
8a921b82
There was a problem fetching the pipeline summary.
Commit
8a921b82
authored
7 years ago
by
slobinger
Browse files
Options
Downloads
Plain Diff
Merge branch '29-alias-for-apps' into 'master'
Resolve "Apps sollen mit Alias an Hub angemeldet werden können" Closes
#29
See merge request
!21
parents
f8b9a90d
91716c85
Branches
Branches containing commit
No related tags found
1 merge request
!21
Resolve "Apps sollen mit Alias an Hub angemeldet werden können"
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sams_classes/sams_hub.py
+10
-8
10 additions, 8 deletions
sams_classes/sams_hub.py
test/test_sams_hub.py
+21
-16
21 additions, 16 deletions
test/test_sams_hub.py
with
31 additions
and
24 deletions
sams_classes/sams_hub.py
+
10
−
8
View file @
8a921b82
...
@@ -33,12 +33,13 @@ class SAMSHub:
...
@@ -33,12 +33,13 @@ class SAMSHub:
def
addApp
(
self
,
app
:
SAMSApp
=
None
,
alias
=
None
):
def
addApp
(
self
,
app
:
SAMSApp
=
None
,
alias
=
None
):
if
not
isinstance
(
app
,
SAMSApp
):
if
not
isinstance
(
app
,
SAMSApp
):
raise
TypeError
(
'
Argument app has to be a SAMSApp.
'
)
raise
TypeError
(
'
Argument app has to be a SAMSApp.
'
)
self
.
_apps
[
app
.
name
]
=
app
appDict
=
{
'
app
'
:
app
,
'
urlPrefix
'
:
(
alias
or
app
.
name
)}
self
.
_appList
.
append
(
app
)
self
.
_apps
[
app
.
name
]
=
appDict
self
.
_appList
.
append
(
appDict
)
if
app
.
name
==
self
.
_config
.
get
(
'
main_app
'
):
if
app
.
name
==
self
.
_config
.
get
(
'
main_app
'
):
self
.
_flaskApp
.
register_blueprint
(
app
.
blueprint
)
self
.
_flaskApp
.
register_blueprint
(
app
.
blueprint
)
self
.
_flaskApp
.
register_blueprint
(
self
.
_flaskApp
.
register_blueprint
(
app
.
blueprint
,
url_prefix
=
'
/
'
+
(
alias
or
app
.
name
)
)
app
.
blueprint
,
url_prefix
=
'
/
'
+
appDict
[
'
urlPrefix
'
]
)
@property
@property
def
appKeys
(
self
):
def
appKeys
(
self
):
...
@@ -50,7 +51,7 @@ class SAMSHub:
...
@@ -50,7 +51,7 @@ class SAMSHub:
def
app
(
self
,
name
):
def
app
(
self
,
name
):
try
:
try
:
return
self
.
_apps
[
name
]
return
self
.
_apps
[
name
]
[
'
app
'
]
except
:
except
:
raise
AppNotExist
raise
AppNotExist
...
@@ -76,11 +77,12 @@ class SAMSHub:
...
@@ -76,11 +77,12 @@ class SAMSHub:
def
menu
(
self
,
langCode
):
def
menu
(
self
,
langCode
):
menu
=
[]
menu
=
[]
for
app
in
self
.
_appList
:
for
app
Dict
in
self
.
_appList
:
if
self
.
_config
.
get
(
'
main_app
'
)
==
app
.
name
:
if
self
.
_config
.
get
(
'
main_app
'
)
==
app
Dict
[
'
app
'
]
.
name
:
menu
.
extend
(
app
.
menu
(
langCode
=
langCode
))
menu
.
extend
(
app
Dict
[
'
app
'
]
.
menu
(
langCode
=
langCode
))
else
:
else
:
menu
.
extend
(
app
.
menu
(
langCode
=
langCode
,
urlPrefix
=
app
.
name
))
menu
.
extend
(
appDict
[
'
app
'
].
menu
(
langCode
=
langCode
,
urlPrefix
=
appDict
[
'
urlPrefix
'
]))
return
menu
return
menu
@staticmethod
@staticmethod
...
...
This diff is collapsed.
Click to expand it.
test/test_sams_hub.py
+
21
−
16
View file @
8a921b82
...
@@ -18,12 +18,12 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase):
...
@@ -18,12 +18,12 @@ class CaseSAMSHubWithThreadedAPI(unittest.TestCase):
apiApp
.
config
[
'
TESTING
'
]
=
True
apiApp
.
config
[
'
TESTING
'
]
=
True
thApi
=
FlaskInThread
(
apiApp
,
host
=
"
localhost
"
,
port
=
4711
)
thApi
=
FlaskInThread
(
apiApp
,
host
=
"
localhost
"
,
port
=
4711
)
thApi
.
start
()
thApi
.
start
()
time
.
sleep
(
0.0
1
)
time
.
sleep
(
1
)
def
tearDown
(
self
):
def
tearDown
(
self
):
response
=
requests
.
get
(
'
http://localhost:4711/shutdown
'
)
response
=
requests
.
get
(
'
http://localhost:4711/shutdown
'
)
print
(
response
.
content
.
decode
(
'
utf-8
'
))
print
(
response
.
content
.
decode
(
'
utf-8
'
))
time
.
sleep
(
0.0
1
)
time
.
sleep
(
1
)
def
test_hub_provides_apps_with_proxies
(
self
):
def
test_hub_provides_apps_with_proxies
(
self
):
manifest
=
{
manifest
=
{
...
@@ -223,14 +223,7 @@ class CaseMinimalSAMSHub(unittest.TestCase):
...
@@ -223,14 +223,7 @@ class CaseMinimalSAMSHub(unittest.TestCase):
]
]
urls
=
[
'
1/1
'
,
'
2/1
'
,
'
1/2
'
]
urls
=
[
'
1/1
'
,
'
2/1
'
,
'
1/2
'
]
name_vars
=
[
'
1_1
'
,
'
2_1
'
,
'
1_2
'
]
name_vars
=
[
'
1_1
'
,
'
2_1
'
,
'
1_2
'
]
expected
=
''
.
join
((
testSamsApp
=
SAMSApp
(
"
<ul>
\n\n
<li><a href=
'
/
"
,
name
,
'
/
'
,
urls
[
0
],
"'
>
"
,
expected_names
[
0
],
"
</a>
\n\n
<ul>
\n\n
<li><a href=
'
/
"
,
name
,
'
/
'
,
urls
[
1
],
"'
>
"
,
expected_names
[
1
],
"
</a>
\n\n
</li>
\n\n
</ul>
\n\n
</li>
\n\n
<li><a href=
'
/
"
,
name
,
'
/
'
,
urls
[
2
],
"'
>
"
,
expected_names
[
2
],
'
</a>
\n\n
</li>
\n\n
</ul>
'
))
self
.
hub
.
addApp
(
SAMSApp
(
name
=
name
,
manifest
=
{
name
=
name
,
manifest
=
{
'
default_language
'
:
'
de
'
,
'
default_language
'
:
'
de
'
,
'
views
'
:
[{
'
url
'
:
'
test-menu
'
,
'
function
'
:
'
views.menu_test
'
}],
'
views
'
:
[{
'
url
'
:
'
test-menu
'
,
'
function
'
:
'
views.menu_test
'
}],
...
@@ -242,13 +235,25 @@ class CaseMinimalSAMSHub(unittest.TestCase):
...
@@ -242,13 +235,25 @@ class CaseMinimalSAMSHub(unittest.TestCase):
]
]
}
}
,
langDict
=
{
'
de
'
:
dict
(
zip
(
name_vars
,
expected_names
))}
,
langDict
=
{
'
de
'
:
dict
(
zip
(
name_vars
,
expected_names
))}
)
)
)
self
.
hub
.
flaskApp
.
config
[
'
DEBUG
'
]
=
True
for
addAppParams
in
(
with
self
.
hub
.
flaskApp
.
test_client
(
self
)
as
client
:
{
'
app
'
:
testSamsApp
},
{
'
app
'
:
testSamsApp
,
'
alias
'
:
'
testAlias
'
}):
response
=
client
.
get
(
'
/test/test-menu
'
)
hub
=
SAMSHub
(
name
=
'
test
'
,
config
=
{
'
default_language
'
:
'
de
'
})
self
.
assertIs
(
response
.
status_code
,
200
)
effectiveName
=
addAppParams
.
get
(
'
alias
'
,
name
)
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
expected
)
expected
=
''
.
join
((
"
<ul>
\n\n
<li><a href=
'
/
"
,
effectiveName
,
'
/
'
,
urls
[
0
],
"'
>
"
,
expected_names
[
0
],
"
</a>
\n\n
<ul>
\n\n
<li><a href=
'
/
"
,
effectiveName
,
'
/
'
,
urls
[
1
],
"'
>
"
,
expected_names
[
1
],
"
</a>
\n\n
</li>
\n\n
</ul>
\n\n
</li>
\n\n
<li><a href=
'
/
"
,
effectiveName
,
'
/
'
,
urls
[
2
],
"'
>
"
,
expected_names
[
2
],
'
</a>
\n\n
</li>
\n\n
</ul>
'
))
hub
.
addApp
(
**
addAppParams
)
hub
.
flaskApp
.
config
[
'
DEBUG
'
]
=
True
with
hub
.
flaskApp
.
test_client
(
self
)
as
client
:
response
=
client
.
get
(
'
/
'
+
effectiveName
+
'
/test-menu
'
)
with
self
.
subTest
(
addAppParams
):
self
.
assertIs
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
data
.
decode
(
'
utf-8
'
),
expected
)
def
test_hub_default_language_used
(
self
):
def
test_hub_default_language_used
(
self
):
"""
The hub default_language is prefered instead of app default_language
"""
"""
The hub default_language is prefered instead of app default_language
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment