-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
60 lines (46 loc) · 1.62 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import photo
import slide
import pytest
def test_same_tags():
p1= photo.Photo(id=0, tags=["cat", "house", "garden"])
p2= photo.Photo(id=0, tags=["cat", "house", "garden"])
s1 = slide.Slide(p1)
s2 = slide.Slide(p2)
assert(s1.score(s2) == 0)
assert(s2.score(s1) == 0)
def test_different_tags():
p1= photo.Photo(id=0, tags=["cat", "house", "garden"])
p2= photo.Photo(id=0, tags=["sun", "beach", "sky"])
s1 = slide.Slide(p1)
s2 = slide.Slide(p2)
assert(s1.score(s2) == 0)
assert(s2.score(s1) == 0)
def test_fewer_tags():
p1= photo.Photo(id=0, tags=["cat", "house", "garden"])
p2= photo.Photo(id=0, tags=["cat", "house"])
s1 = slide.Slide(p1)
s2 = slide.Slide(p2)
# Expect zero as b has no tags other than those in a
assert(s1.score(s2) == 0)
assert(s2.score(s1) == 0)
def test_equal_different_tags():
p1= photo.Photo(id=0, tags=["cat", "house", "garden"])
p2= photo.Photo(id=0, tags=["cat", "house", "sky"])
s1 = slide.Slide(p1)
s2 = slide.Slide(p2)
assert(s1.score(s2) == 1)
assert(s2.score(s1) == 1)
def test_equal_more_tags():
p1= photo.Photo(id=0, tags=["cat", "house", "garden", "bear"])
p2= photo.Photo(id=0, tags=["cat", "house", "sky", "dog"])
s1 = slide.Slide(p1)
s2 = slide.Slide(p2)
assert(s1.score(s2) == 2)
assert(s2.score(s1) == 2)
def test_equal_more_tags_2():
p1= photo.Photo(id=0, tags=["cat", "house", "garden", "bear"])
p2= photo.Photo(id=0, tags=["cat", "house", "sky", "dog", "cow"])
s1 = slide.Slide(p1)
s2 = slide.Slide(p2)
assert(s1.score(s2) == 2)
assert(s2.score(s1) == 2)