Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
8fe7ff08
Commit
8fe7ff08
authored
Aug 08, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share one mixin.
parent
9ed94c78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
36 deletions
+36
-36
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+36
-36
No files found.
slapos/tests/slapformat.py
View file @
8fe7ff08
...
@@ -2,16 +2,6 @@ import logging
...
@@ -2,16 +2,6 @@ import logging
import
slapos.format
import
slapos.format
import
unittest
import
unittest
class
TestComputer
(
unittest
.
TestCase
):
def
test_getAddress_empty_computer
(
self
):
computer
=
slapos
.
format
.
Computer
(
'computer'
)
self
.
assertEqual
(
computer
.
getAddress
(),
{
'netmask'
:
None
,
'addr'
:
None
})
def
test_construct_empty
(
self
):
computer
=
slapos
.
format
.
Computer
(
'computer'
)
computer
.
construct
()
class
FakeConfig
:
class
FakeConfig
:
pass
pass
...
@@ -23,7 +13,20 @@ class TestLoggerHandler(logging.Handler):
...
@@ -23,7 +13,20 @@ class TestLoggerHandler(logging.Handler):
def
emit
(
self
,
record
):
def
emit
(
self
,
record
):
self
.
bucket
.
append
(
record
.
msg
)
self
.
bucket
.
append
(
record
.
msg
)
class
TestPartition
(
unittest
.
TestCase
):
call_and_read_list
=
[]
def
fakeCallAndRead
(
argument_list
,
raise_on_error
=
True
):
global
call_and_read_list
call_and_read_list
.
append
(
argument_list
)
def
raising_KeyError
(
name
):
raise
KeyError
def
returning_True
(
name
):
return
True
class
FakeClass
:
pass
class
SlapformatMixin
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
config
=
FakeConfig
()
config
=
FakeConfig
()
config
.
dry_run
=
True
config
.
dry_run
=
True
...
@@ -36,6 +39,27 @@ class TestPartition(unittest.TestCase):
...
@@ -36,6 +39,27 @@ class TestPartition(unittest.TestCase):
self
.
partition
=
slapos
.
format
.
Partition
(
'partition'
,
'/part_path'
,
self
.
partition
=
slapos
.
format
.
Partition
(
'partition'
,
'/part_path'
,
slapos
.
format
.
User
(
'root'
),
[],
None
)
slapos
.
format
.
User
(
'root'
),
[],
None
)
self
.
partition
.
_os
=
slapos
.
format
.
OS
(
config
)
self
.
partition
.
_os
=
slapos
.
format
.
OS
(
config
)
global
call_and_read_list
call_and_read_list
=
[]
self
.
real_callAndRead
=
slapos
.
format
.
callAndRead
slapos
.
format
.
callAndRead
=
fakeCallAndRead
def
tearDown
(
self
):
global
call_and_read_list
call_and_read_list
=
[]
slapos
.
format
.
callAndRead
=
self
.
real_callAndRead
class
TestComputer
(
SlapformatMixin
):
def
test_getAddress_empty_computer
(
self
):
computer
=
slapos
.
format
.
Computer
(
'computer'
)
self
.
assertEqual
(
computer
.
getAddress
(),
{
'netmask'
:
None
,
'addr'
:
None
})
def
test_construct_empty
(
self
):
computer
=
slapos
.
format
.
Computer
(
'computer'
)
computer
.
construct
()
class
TestPartition
(
SlapformatMixin
):
def
test_createPath
(
self
):
def
test_createPath
(
self
):
self
.
partition
.
createPath
()
self
.
partition
.
createPath
()
...
@@ -58,31 +82,7 @@ class TestPartition(unittest.TestCase):
...
@@ -58,31 +82,7 @@ class TestPartition(unittest.TestCase):
self
.
test_result
.
bucket
self
.
test_result
.
bucket
)
)
call_and_read_list
=
[]
class
TestUser
(
SlapformatMixin
):
def
fakeCallAndRead
(
argument_list
,
raise_on_error
=
True
):
global
call_and_read_list
call_and_read_list
.
append
(
argument_list
)
def
raising_KeyError
(
name
):
raise
KeyError
def
returning_True
(
name
):
return
True
class
FakeClass
:
pass
class
TestUser
(
unittest
.
TestCase
):
def
setUp
(
self
):
global
call_and_read_list
call_and_read_list
=
[]
self
.
real_callAndRead
=
slapos
.
format
.
callAndRead
slapos
.
format
.
callAndRead
=
fakeCallAndRead
def
tearDown
(
self
):
global
call_and_read_list
call_and_read_list
=
[]
slapos
.
format
.
callAndRead
=
self
.
real_callAndRead
def
test_create
(
self
):
def
test_create
(
self
):
global
call_and_read_list
global
call_and_read_list
user
=
slapos
.
format
.
User
(
'testuser'
)
user
=
slapos
.
format
.
User
(
'testuser'
)
...
...
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