Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Gambier
slapos.package
Commits
7803db0a
Commit
7803db0a
authored
Jun 10, 2014
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.package.test: Include Initial tests for getDistributionHandler
Fix minor typo changes on distribution.py
parent
a0a3e41d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
8 deletions
+76
-8
slapos/package/distribution.py
slapos/package/distribution.py
+11
-8
slapos/package/test/test_distribution.py
slapos/package/test/test_distribution.py
+65
-0
No files found.
slapos/package/distribution.py
View file @
7803db0a
...
...
@@ -38,6 +38,9 @@ _distributor_id_file_re = re.compile("(?:DISTRIB_ID\s*=)\s*(.*)", re.I)
_release_file_re
=
re
.
compile
(
"(?:DISTRIB_RELEASE
\
s*=)
\
s*(.*)"
,
re
.
I
)
_codename_file_re
=
re
.
compile
(
"(?:DISTRIB_CODENAME
\
s*=)
\
s*(.*)"
,
re
.
I
)
class
UnsupportedOSException
(
Exception
):
pass
def
patched_linux_distribution
(
distname
=
''
,
version
=
''
,
id
=
''
,
supported_dists
=
platform
.
_supported_dists
,
full_distribution_name
=
1
):
...
...
@@ -80,7 +83,7 @@ class PackageManager:
""" This is implemented in BasePromise """
raise
NotImplemented
def
_getDistrib
i
tionHandler
(
self
):
def
_getDistrib
u
tionHandler
(
self
):
distribution_name
=
self
.
getDistributionName
()
if
distribution_name
.
lower
().
strip
()
==
'opensuse'
:
return
Zypper
()
...
...
@@ -88,15 +91,15 @@ class PackageManager:
elif
distribution_name
.
lower
().
strip
()
in
[
'debian'
,
'ubuntu'
]:
return
AptGet
()
raise
NotImplemented
(
"Distribution (%s) is not Supported!"
%
distribution_name
)
raise
UnsupportedOSException
(
"Distribution (%s) is not Supported!"
%
distribution_name
)
def
_purgeRepository
(
self
):
""" Remove all repositories """
return
self
.
_getDistrib
i
tionHandler
().
purgeRepository
(
self
.
_call
)
return
self
.
_getDistrib
u
tionHandler
().
purgeRepository
(
self
.
_call
)
def
_addRepository
(
self
,
url
,
alias
):
""" Add a repository """
return
self
.
_getDistrib
i
tionHandler
().
addRepository
(
self
.
_call
,
url
,
alias
)
return
self
.
_getDistrib
u
tionHandler
().
addRepository
(
self
.
_call
,
url
,
alias
)
def
_addKey
(
self
,
url
,
alias
):
""" Add a gpg or a key """
...
...
@@ -104,19 +107,19 @@ class PackageManager:
def
_updateRepository
(
self
):
""" Add a repository """
return
self
.
_getDistrib
i
tionHandler
().
updateRepository
(
self
.
_call
)
return
self
.
_getDistrib
u
tionHandler
().
updateRepository
(
self
.
_call
)
def
_installSoftwareList
(
self
,
name_list
):
""" Upgrade softwares """
return
self
.
_getDistrib
i
tionHandler
().
installSoftwareList
(
self
.
_call
,
name_list
)
return
self
.
_getDistrib
u
tionHandler
().
installSoftwareList
(
self
.
_call
,
name_list
)
def
_updateSoftware
(
self
):
""" Upgrade softwares """
return
self
.
_getDistrib
i
tionHandler
().
updateSoftware
(
self
.
_call
)
return
self
.
_getDistrib
u
tionHandler
().
updateSoftware
(
self
.
_call
)
def
_updateSystem
(
self
):
""" Dist-Upgrade of system """
return
self
.
_getDistrib
i
tionHandler
().
updateSystem
(
self
.
_call
)
return
self
.
_getDistrib
u
tionHandler
().
updateSystem
(
self
.
_call
)
def
update
(
self
,
repository_list
=
[],
package_list
=
[],
key_list
=
[]):
""" Perform upgrade """
...
...
slapos/package/test/test_distribution.py
0 → 100644
View file @
7803db0a
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2012-2014 Vifib SARL and Contributors.
# All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
slapos.package.distribution
import
PackageManager
,
AptGet
,
Zypper
,
\
UnsupportedOSException
import
os
import
unittest
def
_fake_call
(
self
,
*
args
,
**
kw
):
self
.
last_call
=
args
class
testPackageManager
(
unittest
.
TestCase
):
def
setUp
(
self
):
PackageManager
.
_call
=
_fake_call
def
testGetDistributionHandler
(
self
):
package_manager
=
PackageManager
()
def
OpenSuseCase
():
return
"OpenSuse"
package_manager
.
getDistributionName
=
OpenSuseCase
self
.
assertTrue
(
isinstance
(
package_manager
.
_getDistributionHandler
(),
Zypper
))
def
DebianCase
():
return
"Debian"
package_manager
.
getDistributionName
=
DebianCase
self
.
assertTrue
(
isinstance
(
package_manager
.
_getDistributionHandler
(),
AptGet
))
def
RedHatCase
():
return
"Red Hat"
package_manager
.
getDistributionName
=
RedHatCase
self
.
assertRaises
(
UnsupportedOSException
,
package_manager
.
_getDistributionHandler
)
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