Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
ef7d6bba
Commit
ef7d6bba
authored
May 14, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed getting back the wrong repository
parent
37402bdf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
4 deletions
+55
-4
semaphore_helper.py
...hon-client-generated/semaphore_client/semaphore_helper.py
+10
-4
test_get_repository.py
...phore-python-client-generated/test/test_get_repository.py
+45
-0
No files found.
semaphore-python-client-generated/semaphore_client/semaphore_helper.py
View file @
ef7d6bba
...
...
@@ -69,9 +69,8 @@ class SemaphoreHelper:
def
create_repository
(
self
,
name
,
project_id
,
key_id
,
git_url
):
repository_request
=
RepositoryRequest
(
name
=
name
,
project_id
=
project_id
,
git_url
=
git_url
,
ssh_key_id
=
key_id
)
self
.
project_api
.
project_project_id_repositories_post
(
repository_request
,
project_id
)
repositories
=
self
.
project_api
.
project_project_id_repositories_get
(
project_id
,
name
,
'asc'
)
return
repositories
[
0
]
.
id
repository
=
self
.
find_repository
(
project_id
,
name
,
git_url
)
return
repository
.
id
def
create_template
(
self
,
project_id
,
key_id
,
inventory_id
,
repository_id
,
playbook_name
):
template_request
=
TemplateRequest
(
ssh_key_id
=
key_id
,
project_id
=
project_id
,
inventory_id
=
inventory_id
,
...
...
@@ -123,3 +122,10 @@ class SemaphoreHelper:
for
template
in
templates
:
if
template
.
playbook
==
playbook_name
:
return
template
def
find_repository
(
self
,
project_id
,
name
,
git_url
):
repositories
=
self
.
project_api
.
project_project_id_repositories_get
(
project_id
,
name
,
'asc'
)
for
repo
in
repositories
:
if
repo
.
git_url
==
git_url
:
return
repo
return
None
\ No newline at end of file
semaphore-python-client-generated/test/test_get_repository.py
0 → 100644
View file @
ef7d6bba
from
__future__
import
absolute_import
import
unittest
import
semaphore_client
from
semaphore_client
import
APIToken
,
RepositoryRequest
from
semaphore_client.models.login
import
Login
# noqa: E501
from
semaphore_client.rest
import
ApiException
from
semaphore_client.semaphore_helper
import
SemaphoreHelper
class
TestGetRepository
(
unittest
.
TestCase
):
"""Login unit test stubs"""
def
setUp
(
self
):
self
.
semaphore_base_url
=
'http://localhost:3000/api'
if
SemaphoreHelper
.
service_is_up
(
self
.
semaphore_base_url
):
self
.
username
=
'admin'
self
.
password
=
'password'
def
tearDown
(
self
):
pass
def
testGetRepository
(
self
):
"""Test Login"""
if
SemaphoreHelper
.
service_is_up
(
self
.
semaphore_base_url
):
helper
=
SemaphoreHelper
(
self
.
semaphore_base_url
,
self
.
username
,
self
.
password
)
project_name
=
'test'
key
=
'-----BEGIN RSA PRIVATE KEY-----MIIEowIBAAKCAQEAg0blRNV6cm3RTiivpzE8HR4JzKZRVIBZ7bxeNoMz0'
\
'-----END RSA PRIVATE KEY-----'
project_id
=
helper
.
create_project
(
project_name
)
git_url_1
=
'https://github.com/QCDIS/playbooks.git'
key_id
=
helper
.
create_ssh_key
(
project_name
,
project_id
,
key
)
repository_id_1
=
helper
.
create_repository
(
project_name
,
project_id
,
key_id
,
git_url_1
)
git_url_2
=
'https://github.com/QCDIS/mysome_glusterfs.git'
repository_id_2
=
helper
.
create_repository
(
project_name
,
project_id
,
key_id
,
git_url_2
)
self
.
assertNotEqual
(
repository_id_1
,
repository_id_2
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment