Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

"""This module holds the automated tests for DGILib Housekeeping.""" 

 

from pydgilib.dgilib import DGILib 

 

from ctypes import c_uint 

 

import pytest 

 

 

verbosity = (0, 99) 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_connect(verbose): 

"""test_connect. 

 

DGILibHousekeeping.connect 

""" 

dgilib = DGILib(verbose=verbose) 

dgilib.discover() 

device_sn = dgilib.get_device_serial() 

dgilib.dgi_hndl = dgilib.connect(device_sn) 

assert isinstance(dgilib.dgi_hndl, c_uint) 

# Test bigger than 0? Bigger than 4096 

dgilib.disconnect() 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_disconnect(verbose): 

"""test_disconnect. 

 

DGILibHousekeeping.disconnect 

""" 

dgilib = DGILib(verbose=verbose) 

dgilib.discover() 

device_sn = dgilib.get_device_serial() 

dgilib.dgi_hndl = dgilib.connect(device_sn) 

assert dgilib.disconnect() is None 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_connection_status(verbose): 

"""test_connection_status. 

 

DGILibHousekeeping.connection_status 

""" 

dgilib = DGILib(verbose=verbose) 

dgilib.discover() 

device_sn = dgilib.get_device_serial() 

assert dgilib.connection_status() == 2 

dgilib.dgi_hndl = dgilib.connect(device_sn) 

assert dgilib.connection_status() == 0 

dgilib.disconnect() 

assert dgilib.connection_status() == 2 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_get_major_version(verbose): 

"""test_get_major_version. 

 

DGILibHousekeeping.get_major_version 

""" 

assert isinstance(DGILib(verbose=verbose).get_major_version(), int) 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_get_minor_version(verbose): 

"""test_get_minor_version. 

 

DGILibHousekeeping.get_minor_version 

""" 

assert isinstance(DGILib(verbose=verbose).get_minor_version(), int) 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_get_build_number(verbose): 

"""test_get_build_number. 

 

DGILibHousekeeping.get_build_number 

""" 

assert isinstance(DGILib(verbose=verbose).get_build_number(), int) 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_get_fw_version(verbose): 

"""test_get_fw_version. 

 

DGILibHousekeeping.get_fw_version 

""" 

dgilib = DGILib(verbose=verbose) 

dgilib.discover() 

device_sn = dgilib.get_device_serial() 

dgilib.dgi_hndl = dgilib.connect(device_sn) 

fw_version = dgilib.get_fw_version() 

assert isinstance(fw_version, tuple) 

assert len(fw_version) == 2 

assert isinstance(fw_version[0], int) 

assert isinstance(fw_version[1], int) 

dgilib.disconnect() 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_start_polling(verbose): 

"""test_start_polling. 

 

DGILibHousekeeping.start_polling 

""" 

dgilib = DGILib(verbose=verbose) 

dgilib.discover() 

device_sn = dgilib.get_device_serial() 

dgilib.dgi_hndl = dgilib.connect(device_sn) 

assert dgilib.start_polling() is None 

# assert dgilib.start_polling() is None 

# dgilib.stop_polling() # All tests seems to pass without this as well 

dgilib.disconnect() 

# NOTE: Calling start_polling() twice in a row and not calling 

# disconnect afterwards resulted in mode 17 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_stop_polling(verbose): 

"""test_stop_polling. 

 

DGILibHousekeeping.stop_polling 

""" 

dgilib = DGILib(verbose=verbose) 

dgilib.discover() 

device_sn = dgilib.get_device_serial() 

dgilib.dgi_hndl = dgilib.connect(device_sn) 

assert dgilib.stop_polling() is None 

assert dgilib.stop_polling() is None 

dgilib.start_polling() 

assert dgilib.stop_polling() is None 

dgilib.disconnect() 

 

 

@pytest.mark.parametrize("verbose", verbosity) 

def test_target_reset(verbose): 

"""test_target_reset. 

 

DGILibHousekeeping.target_reset 

""" 

dgilib = DGILib(verbose=verbose) 

dgilib.discover() 

device_sn = dgilib.get_device_serial() 

dgilib.dgi_hndl = dgilib.connect(device_sn) 

assert dgilib.target_reset(False) is None 

assert dgilib.target_reset(False) is None 

assert dgilib.target_reset(True) is None 

assert dgilib.target_reset(True) is None 

assert dgilib.target_reset(False) is None 

dgilib.disconnect()