-
Notifications
You must be signed in to change notification settings - Fork 0
/
mockedLibs.py
69 lines (47 loc) · 1.31 KB
/
mockedLibs.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
61
62
63
64
65
66
67
68
69
from unittest.mock import AsyncMock, MagicMock, Mock
import logsetup
import logging, time
logger = logging.getLogger('mockedLibs')
GPIO = Mock()
gp = Mock()
def file_get(self, *args):
logger.debug("Sleeping in mocked file_get")
time.sleep(1.5)
return Mock()
def capture(self, *args):
time.sleep(5)
m = Mock()
m.name = "abcd.dmg"
m.folder = "img"
return m
def output(self, *args):
logger.debug("Setting GPIO output to: %s" %repr(args))
time.sleep(0.05)
GPIO.output = output
mockCam = Mock()
mockCam.file_get = file_get
mockCam.capture = capture
gp.Camera = lambda : mockCam
configMock = Mock()
class ShutterSpeedMock:
def __init__(self):
self.ss = '1/50'
def get_value(self):
return self.ss
def set_value(self, val):
self.ss = val
shutterSpeedMockins = ShutterSpeedMock()
configMock.get_child_by_name = lambda x: shutterSpeedMockins if x == 'shutterspeed' else Mock()
mockCam.get_config = lambda : configMock
#gp.Camera.file_get = file_get
#cam = gp.Camera()
#print(cam)
#print(cam.file_get("a", 1, "2"))
#gphotoMock.Camera = MagicMock()
#gphotoMock.GPhoto2Error = Exception()
#import sys, asyncio, logging
#sys.modules['RPi'] = RPIMock
#sys.modules['gphoto2'] = gphotoMock
#logger.warning("Test file")
#import main
#asyncio.run(main.main())