Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
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
Stefane Fermigier
neo
Commits
c66c97bc
Commit
c66c97bc
authored
Jan 17, 2017
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qa: fix ImporterTests.test
It was failing when some .py files were not compiled.
parent
f9ff4249
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
neo/tests/threaded/testImporter.py
neo/tests/threaded/testImporter.py
+23
-12
No files found.
neo/tests/threaded/testImporter.py
View file @
c66c97bc
...
...
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
collections
import
deque
from
cPickle
import
Pickler
,
Unpickler
from
cStringIO
import
StringIO
from
itertools
import
islice
,
izip_longest
...
...
@@ -129,19 +128,28 @@ class ImporterTests(NEOThreadedTest):
self
.
assertDictEqual
(
state
,
load
())
def
test
(
self
):
# XXX: Using NEO source files as test data was a bad idea because
# the test breaks easily in case of massive changes in the code,
# or if there are many untracked files.
importer
=
[]
fs_dir
=
os
.
path
.
join
(
getTempDirectory
(),
self
.
id
())
shutil
.
rmtree
(
fs_dir
,
1
)
# for --loop
os
.
mkdir
(
fs_dir
)
src_root
,
=
neo
.
__path__
fs_list
=
"root"
,
"client"
,
"master"
,
"tests"
def
not_pyc
(
name
):
return
not
name
.
endswith
(
".pyc"
)
# We use 'hash' to skip roughly half of files.
# They'll be added after the migration has started.
def
root_filter
(
name
):
if
not
name
.
endswith
(
".pyc"
):
if
not
_pyc
(
name
):
i
=
name
.
find
(
os
.
sep
)
return
i
<
0
or
name
[:
i
]
not
in
fs_list
return
(
i
<
0
or
name
[:
i
]
not
in
fs_list
)
and
(
'.'
not
in
name
or
hash
(
name
)
&
1
)
def
sub_filter
(
name
):
return
lambda
n
:
n
[
-
4
:]
!=
'.pyc'
and
\
n
.
split
(
os
.
sep
,
1
)[
0
]
in
(
name
,
"scripts"
)
return
lambda
n
:
not_pyc
(
n
)
and
(
hash
(
n
)
&
1
if
'.'
in
n
else
os
.
sep
in
n
or
n
in
(
name
,
"scripts"
))
conn_list
=
[]
iter_list
=
[]
# Setup several FileStorage databases.
...
...
@@ -193,7 +201,7 @@ class ImporterTests(NEOThreadedTest):
cluster
.
start
()
t
,
c
=
cluster
.
getTransaction
()
r
=
c
.
root
()[
"neo"
]
# Test retrieving of an object from ZODB when next serial in NEO.
# Test retrieving of an object from ZODB when next serial i
s i
n NEO.
r
.
_p_changed
=
1
t
.
commit
()
t
.
begin
()
...
...
@@ -204,20 +212,23 @@ class ImporterTests(NEOThreadedTest):
self
.
assertRaisesRegexp
(
NotImplementedError
,
" getObjectHistory$"
,
c
.
db
().
history
,
r
.
_p_oid
)
i
=
r
.
walk
()
next
(
islice
(
i
,
9
,
None
))
next
(
islice
(
i
,
4
,
None
))
logging
.
info
(
"start migration"
)
dm
.
doOperation
(
cluster
.
storage
)
deque
(
i
,
maxlen
=
0
)
last_import
=
None
for
i
,
r
in
enumerate
(
r
.
treeFromFs
(
src_root
,
10
)):
# Adjust if needed. Must remain > 0.
assert
14
==
sum
(
1
for
i
in
i
)
last_import
=
-
1
for
i
,
r
in
enumerate
(
r
.
treeFromFs
(
src_root
,
6
,
not_pyc
)):
t
.
commit
()
if
cluster
.
storage
.
dm
.
_import
:
last_import
=
i
self
.
tic
()
self
.
assertTrue
(
last_import
and
not
cluster
.
storage
.
dm
.
_import
)
# Same as above. We want last_import smaller enough compared to i
assert
i
/
3
<
last_import
<
i
-
3
,
(
last_import
,
i
)
self
.
assertFalse
(
cluster
.
storage
.
dm
.
_import
)
i
=
len
(
src_root
)
+
1
self
.
assertEqual
(
sorted
(
r
.
walk
()),
sorted
(
(
x
[
i
:]
or
'.'
,
sorted
(
y
),
sorted
(
z
))
(
x
[
i
:]
or
'.'
,
sorted
(
y
),
sorted
(
filter
(
not_pyc
,
z
)
))
for
x
,
y
,
z
in
os
.
walk
(
src_root
)))
t
.
commit
()
...
...
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