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
Guillaume Hervier
slapos.package
Commits
79561a0d
Commit
79561a0d
authored
Jun 10, 2014
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.package.test: Include tests for Distribution
parent
0e2cc3e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
1 deletion
+109
-1
slapos/package/test/test_distribution.py
slapos/package/test/test_distribution.py
+109
-1
No files found.
slapos/package/test/test_distribution.py
View file @
79561a0d
...
@@ -35,6 +35,38 @@ import unittest
...
@@ -35,6 +35,38 @@ import unittest
def
_fake_call
(
self
,
*
args
,
**
kw
):
def
_fake_call
(
self
,
*
args
,
**
kw
):
self
.
last_call
=
args
self
.
last_call
=
args
def
_fake_debian_distribution
(
*
args
,
**
kw
):
return
(
'debian'
,
'7.4'
,
''
)
def
_fake_opensuse_distribution
(
*
args
,
**
kw
):
return
(
'OpenSuse '
,
'12.1'
,
''
)
class
DummyDistributionHandler
:
called
=
[]
def
purgeRepository
(
self
,
caller
):
self
.
called
.
append
(
"purgeRepository"
)
def
addRepository
(
self
,
caller
,
url
,
alias
):
self
.
called
.
append
(
"addRepository"
)
def
addKey
(
self
,
caller
,
url
,
alias
):
self
.
called
.
append
(
"addKey"
)
def
updateRepository
(
self
,
caller
):
self
.
called
.
append
(
"updateRepository"
)
def
isUpgradable
(
self
,
caller
,
name
):
self
.
called
.
append
(
"isUpgradeble"
)
def
installSoftwareList
(
self
,
caller
,
name_list
):
self
.
called
.
append
(
"installSoftwareList"
)
def
updateSoftware
(
self
,
caller
):
self
.
called
.
append
(
"updateSoftware"
)
def
updateSystem
(
self
,
caller
):
self
.
called
.
append
(
"updateSystem"
)
class
testPackageManager
(
unittest
.
TestCase
):
class
testPackageManager
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -60,6 +92,82 @@ class testPackageManager(unittest.TestCase):
...
@@ -60,6 +92,82 @@ class testPackageManager(unittest.TestCase):
return
"Red Hat"
return
"Red Hat"
package_manager
.
getDistributionName
=
RedHatCase
package_manager
.
getDistributionName
=
RedHatCase
self
.
assertRaises
(
UnsupportedOSException
,
package_manager
.
_getDistributionHandler
)
self
.
assertRaises
(
UnsupportedOSException
,
package_manager
.
_getDistributionHandler
)
def
testGetDistributionName
(
self
):
package_manager
=
PackageManager
()
package_manager
.
_getLinuxDistribution
=
_fake_opensuse_distribution
self
.
assertEquals
(
package_manager
.
getDistributionName
(),
"OpenSuse "
)
package_manager
.
_getLinuxDistribution
=
_fake_debian_distribution
self
.
assertEquals
(
package_manager
.
getDistributionName
(),
"debian"
)
def
testGetVersion
(
self
):
package_manager
=
PackageManager
()
package_manager
.
_getLinuxDistribution
=
_fake_opensuse_distribution
self
.
assertEquals
(
package_manager
.
getVersion
(),
"12.1"
)
package_manager
.
_getLinuxDistribution
=
_fake_debian_distribution
self
.
assertEquals
(
package_manager
.
getVersion
(),
"7.4"
)
def
testOSSignature
(
self
):
package_manager
=
PackageManager
()
package_manager
.
_getLinuxDistribution
=
_fake_opensuse_distribution
self
.
assertEquals
(
package_manager
.
getOSSignature
(),
"opensuse+++12.1+++"
)
package_manager
.
_getLinuxDistribution
=
_fake_debian_distribution
self
.
assertEquals
(
package_manager
.
getOSSignature
(),
"debian+++7.4+++"
)
def
_getPatchedPackageManagerForApiTest
(
self
):
package_manager
=
PackageManager
()
dummy_handler
=
DummyDistributionHandler
()
def
DummyCase
():
dummy_handler
.
called
=
[]
return
dummy_handler
package_manager
.
_getDistributionHandler
=
DummyCase
self
.
assertEquals
(
package_manager
.
_getDistributionHandler
(),
dummy_handler
)
self
.
assertEquals
(
dummy_handler
.
called
,
[])
return
package_manager
,
dummy_handler
def
testPurgeRepositoryAPI
(
self
):
package_manager
,
handler
=
self
.
_getPatchedPackageManagerForApiTest
()
package_manager
.
_purgeRepository
()
self
.
assertEquals
(
handler
.
called
,
[
"purgeRepository"
])
def
testAddRepositoryAPI
(
self
):
package_manager
,
handler
=
self
.
_getPatchedPackageManagerForApiTest
()
package_manager
.
_addRepository
(
"http://..."
,
"slapos"
)
self
.
assertEquals
(
handler
.
called
,
[
"addRepository"
])
def
testAddKeyAPI
(
self
):
package_manager
,
handler
=
self
.
_getPatchedPackageManagerForApiTest
()
package_manager
.
_addKey
(
"http://..."
,
"slapos"
)
self
.
assertEquals
(
handler
.
called
,
[
"addKey"
])
def
testUpdateRepositoryAPI
(
self
):
package_manager
,
handler
=
self
.
_getPatchedPackageManagerForApiTest
()
package_manager
.
_updateRepository
()
self
.
assertEquals
(
handler
.
called
,
[
"updateRepository"
])
def
testInstalledSoftwareListAPI
(
self
):
package_manager
,
handler
=
self
.
_getPatchedPackageManagerForApiTest
()
package_manager
.
_installSoftwareList
([
"slapos"
,
"re6st"
])
self
.
assertEquals
(
handler
.
called
,
[
"installSoftwareList"
])
def
testUpdateSoftwareAPI
(
self
):
package_manager
,
handler
=
self
.
_getPatchedPackageManagerForApiTest
()
package_manager
.
_updateSoftware
()
self
.
assertEquals
(
handler
.
called
,
[
"updateSoftware"
])
def
testUpdateSystemAPI
(
self
):
package_manager
,
handler
=
self
.
_getPatchedPackageManagerForApiTest
()
package_manager
.
_updateSystem
()
self
.
assertEquals
(
handler
.
called
,
[
"updateSystem"
])
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