Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-model
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Renaud Boyer
swh-model
Commits
cdf2b709
Commit
cdf2b709
authored
8 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
Refactor - Improve test git class definition
parent
97be2fd7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/model/tests/test_git.py
+18
-30
18 additions, 30 deletions
swh/model/tests/test_git.py
with
18 additions
and
30 deletions
swh/model/tests/test_git.py
+
18
−
30
View file @
cdf2b709
...
...
@@ -141,12 +141,8 @@ class GitHashArborescenceTree(unittest.TestCase):
"""
Root class to ease walk and git hash testing without side-effecty problems.
"""
@classmethod
def
setUpClass
(
cls
):
super
().
setUpClass
()
cls
.
tmp_root_path
=
tempfile
.
mkdtemp
().
encode
(
'
utf-8
'
)
def
setUp
(
self
):
self
.
tmp_root_path
=
tempfile
.
mkdtemp
().
encode
(
'
utf-8
'
)
start_path
=
os
.
path
.
dirname
(
__file__
).
encode
(
'
utf-8
'
)
sample_folder_archive
=
os
.
path
.
join
(
start_path
,
...
...
@@ -155,19 +151,16 @@ class GitHashArborescenceTree(unittest.TestCase):
b
'
dir-folders
'
,
b
'
sample-folder.tgz
'
)
cls
.
root_path
=
os
.
path
.
join
(
cls
.
tmp_root_path
,
b
'
sample-folder
'
)
self
.
root_path
=
os
.
path
.
join
(
self
.
tmp_root_path
,
b
'
sample-folder
'
)
# uncompress the sample folder
subprocess
.
check_output
(
[
'
tar
'
,
'
xvf
'
,
sample_folder_archive
,
'
-C
'
,
cls
.
tmp_root_path
])
[
'
tar
'
,
'
xvf
'
,
sample_folder_archive
,
'
-C
'
,
self
.
tmp_root_path
])
@classmethod
def
tearDown
(
cls
):
if
os
.
path
.
exists
(
cls
.
tmp_root_path
):
shutil
.
rmtree
(
cls
.
tmp_root_path
)
def
tearDown
(
self
):
if
os
.
path
.
exists
(
self
.
tmp_root_path
):
shutil
.
rmtree
(
self
.
tmp_root_path
)
class
WalkAndGitHash
(
GitHashArborescenceTree
):
@istest
def
walk_and_compute_sha1_from_directory
(
self
):
# make a temporary arborescence tree to hash without ignoring anything
...
...
@@ -224,12 +217,13 @@ class WalkAndGitHash(GitHashArborescenceTree):
self
.
assertEquals
(
actual_walk1
,
expected_checksums
)
class
GitHashUpdateWithNewFile
(
GitHashArborescenceTree
):
class
GitHashUpdate
(
GitHashArborescenceTree
):
@istest
def
update_checksums_from_add_new_file
(
self
):
# make a temporary arborescence tree to hash without ignoring anything
# update the disk in some way
# update the actual git checksums
where only the modification is need
ed
# update the disk in some way
(add a new file)
# update the actual git checksums
from the deeper tree modifi
ed
# when
objects
=
git
.
walk_and_compute_sha1_from_directory
(
...
...
@@ -252,12 +246,10 @@ class GitHashUpdateWithNewFile(GitHashArborescenceTree):
self
.
assertEquals
(
expected_dict
,
actual_dict
)
class
GitHashUpdateWithModifiedFile
(
GitHashArborescenceTree
):
@istest
def
update_checksums_from_modify_existing_file
(
self
):
# make a temporary arborescence tree to hash without ignoring anything
# update the disk in some way
# update the disk in some way
()
# update the actual git checksums where only the modification is needed
# when
...
...
@@ -282,13 +274,11 @@ class GitHashUpdateWithModifiedFile(GitHashArborescenceTree):
self
.
assertEquals
(
expected_dict
,
actual_dict
)
class
GitHashUpdateWithDeletion
(
GitHashArborescenceTree
):
@istest
def
update_checksums_
from_modify
_existing_file
(
self
):
def
update_checksums_
delete
_existing_file
(
self
):
# make a temporary arborescence tree to hash without ignoring anything
# update the disk in some way
# update the actual git checksums
where only the modification is need
ed
# update the disk in some way
(delete a file)
# update the actual git checksums
from the deeper tree modifi
ed
# when
objects
=
git
.
walk_and_compute_sha1_from_directory
(
...
...
@@ -310,13 +300,11 @@ class GitHashUpdateWithDeletion(GitHashArborescenceTree):
self
.
assertEquals
(
expected_dict
,
actual_dict
)
class
GitHashUpdateWithAllInOne
(
GitHashArborescenceTree
):
@istest
def
update_checksums_from_m
odify_existing_file
(
self
):
def
update_checksums_from_m
ultiple_fs_modification
(
self
):
# make a temporary arborescence tree to hash without ignoring anything
# update the disk in some way
# update the actual git checksums
where only the modification is need
ed
# update the disk in some way
(modify a file, add a new, delete one)
# update the actual git checksums
from the deeper tree modifi
ed
# when
objects
=
git
.
walk_and_compute_sha1_from_directory
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment