Skip to content

Commit c36d09b

Browse files
committed
Progress towards tests for adding a target - success case
1 parent 542d83b commit c36d09b

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

src/vws/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
"""
22
A library for Vuforia Web Services.
33
"""
4+
5+
from .vws import VWS
6+
7+
__all__ = [
8+
'VWS',
9+
]

tests/fixtures/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Common fixtures.
3+
"""

tests/fixtures/images.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
Fixtures for images.
3+
"""
4+
5+
import io
6+
7+
import pytest
8+
9+
10+
@pytest.fixture()
11+
def high_quality_image() -> io.BytesIO:
12+
"""
13+
Return an image file which is expected to have a 'success' status when
14+
added to a target and a high tracking rating.
15+
16+
At the time of writing, this image gains a tracking rating of 5.
17+
"""
18+
path = 'tests/data/high_quality_image.jpg'
19+
with open(path, 'rb') as high_quality_image_file:
20+
return io.BytesIO(high_quality_image_file.read())

tests/test_add_target.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Tests for helper function for adding a target to a Vuforia database.
3+
"""
4+
5+
import io
6+
7+
from vws import VWS
8+
from vws.exceptions import (
9+
BadImage,
10+
Fail,
11+
ImageTooLarge,
12+
MetadataTooLarge,
13+
ProjectInactive,
14+
TargetNameExist,
15+
)
16+
17+
18+
class TestSuccess:
19+
"""
20+
Tests for successfully adding a target.
21+
"""
22+
23+
def test_add_target(
24+
self,
25+
client: VWS,
26+
high_quality_image: io.BytesIO,
27+
) -> None:
28+
"""
29+
No exception is raised when adding one target.
30+
"""
31+
client.add_target(name='x', width=1, image=high_quality_image)
32+
33+
def test_add_two_targets(
34+
self,
35+
client: VWS,
36+
high_quality_image: io.BytesIO,
37+
) -> None:
38+
"""
39+
No exception is raised when adding two targets with different names.
40+
"""
41+
client.add_target(name='x', width=1, image=high_quality_image)
42+
client.add_target(name='a', width=1, image=high_quality_image)

0 commit comments

Comments
 (0)