Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CSCI30_Project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Temujin
CSCI30_Project
Commits
eb82afea
Commit
eb82afea
authored
Dec 11, 2019
by
Temujin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
additional tests, required docs
parent
5970f441
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
22 deletions
+77
-22
Certificate of Authorship Group 20131029_fillable.pdf
Certificate of Authorship Group 20131029_fillable.pdf
+0
-0
Contributions_.pdf
Contributions_.pdf
+0
-0
family_tree.cpython-36.pyc
__pycache__/family_tree.cpython-36.pyc
+0
-0
family_tree.py
family_tree.py
+6
-20
ft_test.py
tests/ft_test.py
+45
-2
test_save.ft
tests/test_save.ft
+26
-0
No files found.
Certificate of Authorship Group 20131029_fillable.pdf
0 → 100644
View file @
eb82afea
File added
Contributions_.pdf
0 → 100644
View file @
eb82afea
File added
__pycache__/family_tree.cpython-36.pyc
View file @
eb82afea
No preview for this file type
family_tree.py
View file @
eb82afea
...
...
@@ -15,11 +15,10 @@ class FamilyTree:
"""
Tree setup procedure:
1 get all the nodes and edges, check if they're valid.
2 Make sure there's only one root.
3 Find and set the root
5 run set_generations() method
6 done
1 get all the nodes and edges
2 Find and set the root
3 run set_generations() method
4 done
"""
ordinal
=
[
"first"
,
"second"
,
"third"
,
"fourth"
,
"fifth"
,
...
...
@@ -361,6 +360,7 @@ def savefile(filename, tree):
if
x
is
not
tree
.
root
:
parent
=
x
.
get_parent
()
saveF
.
write
(
"child "
+
parent
.
get_name
()
+
" "
+
x
.
get_name
()
+
"
\n
"
)
saveF
.
close
()
def
command_line
():
...
...
@@ -450,19 +450,5 @@ def command_line():
print
(
"Error: no such command"
)
def
main
():
# test for opening and saving files
ntree
=
openfile
(
"chandelier"
)
ntree
.
find_root
()
ntree
.
set_generations
()
print
(
"The root of the tree is {}."
.
format
(
ntree
.
root
))
for
key
,
node
in
ntree
.
family_tree
.
items
():
print
(
"{}: {}"
.
format
(
node
,
node
.
get_generation
()))
savefile
(
"test"
,
ntree
)
command_line
()
if
__name__
==
"__main__"
:
main
()
command_line
()
tests/ft_test.py
View file @
eb82afea
"""Unittest for family_tree."""
import
sys
import
os
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
...
...
@@ -8,6 +7,36 @@ import family_tree as f
import
unittest
savefile_content
=
"""
family test_save
count 6
name A
age 69
sex True
name B
age 69
sex True
name C
age 69
sex False
name D
age 69
sex True
name E
age 666
sex False
name F
age 420
sex False
links 5
child A B
child A C
child B D
child B E
child D F
"""
.
strip
()
class
TestFamilyTree
(
unittest
.
TestCase
):
"""For testing family tree."""
...
...
@@ -94,7 +123,7 @@ class TestFamilyTree(unittest.TestCase):
self
.
assertEqual
(
self
.
ftree
.
relationship
(
A
,
D
),
"grandson"
)
self
.
assertEqual
(
self
.
ftree
.
relationship
(
D
,
A
),
"grandfather"
)
# great grandparent/child
# great grand
parent/child
self
.
assertEqual
(
self
.
ftree
.
relationship
(
F
,
A
),
"greatgrandfather"
)
self
.
assertEqual
(
self
.
ftree
.
relationship
(
A
,
F
),
"greatgranddaughter"
)
...
...
@@ -111,6 +140,20 @@ class TestFamilyTree(unittest.TestCase):
self
.
assertEqual
(
self
.
ftree
.
relationship
(
C
,
F
),
"grandniece"
)
self
.
assertEqual
(
self
.
ftree
.
relationship
(
F
,
C
),
"grandaunt"
)
def
test_save
(
self
):
f
.
savefile
(
"test_save"
,
self
.
ftree
)
savefile
=
open
(
"test_save.ft"
,
"r"
)
content
=
""
.
join
(
savefile
.
readlines
())
.
strip
()
self
.
assertEqual
(
content
,
savefile_content
)
savefile
.
close
()
def
test_load
(
self
):
tree
=
f
.
openfile
(
"../chandelier"
)
self
.
assertFalse
(
len
(
tree
.
family_tree
)
==
0
)
for
k
,
v
in
tree
.
family_tree
.
items
():
self
.
assertFalse
(
k
is
None
)
self
.
assertFalse
(
v
is
None
)
if
__name__
==
"__main__"
:
unittest
.
main
()
tests/test_save.ft
0 → 100644
View file @
eb82afea
family test_save
count 6
name A
age 69
sex True
name B
age 69
sex True
name C
age 69
sex False
name D
age 69
sex True
name E
age 666
sex False
name F
age 420
sex False
links 5
child A B
child A C
child B D
child B E
child D F
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