File tree 3 files changed +102
-0
lines changed
3 files changed +102
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Project specific
2
+ example.db
3
+ .vscode /*
4
+
1
5
# Byte-compiled / optimized / DLL files
2
6
__pycache__ /
3
7
* .py [cod ]
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Pytesting/test/test_worker.py
4
+
5
+ Generative test cases for the data processing Worker object
6
+
7
+ @author: Rupert.Thomas
8
+ Created 22/11/2019
9
+
10
+ Run tests (from the root folder using):
11
+ pytest
12
+
13
+ """
14
+
15
+ from hypothesis .strategies import text
16
+ from hypothesis import given
17
+
18
+ from truth .truth import AssertThat
19
+
20
+ # Module under test
21
+ from src .worker import Worker
22
+
23
+
24
+ @given (text ())
25
+ def test_worker_parseLine_generative (input ):
26
+
27
+ worker = Worker ()
28
+
29
+ AssertThat (worker .parseLine (input )).IsNone ()
30
+
31
+
32
+ # from hypothesis.strategies import date
33
+
34
+ # @given(date())
35
+ # def test_worker_parseDate1_generative(input):
36
+
37
+ # worker = Worker()
38
+
39
+ # AssertThat(worker.parseLine(input)).IsString()
40
+
41
+
42
+
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Pytesting/test/test_main.py
4
+
5
+ Test cases for the main application
6
+
7
+ @author: Rupert.Thomas
8
+ Created 17/11/2019
9
+
10
+ Run tests (from the root folder using):
11
+ pytest
12
+
13
+ """
14
+
15
+ from truth .truth import AssertThat
16
+
17
+ # Module under test
18
+ from src .main import Application
19
+
20
+
21
+ def test_init (mocker ):
22
+ """
23
+ Test application initialisation
24
+
25
+ Expected result: DAO and Worker classes instantiated
26
+ """
27
+
28
+ # given: setup test framework
29
+ mock_dao = mocker .patch ('src.main.DAO' )
30
+ mock_worker = mocker .patch ('src.main.Worker' )
31
+
32
+ # when:
33
+ app = Application ()
34
+
35
+ # then:
36
+ AssertThat (mock_dao ).WasCalled ().Once ()
37
+ AssertThat (mock_worker ).WasCalled ().Once ()
38
+
39
+
40
+ def test_loadData (mocker ):
41
+ """
42
+ Test parseLine with good data (all fields present)
43
+
44
+ Expected result: dict returne with data
45
+ """
46
+
47
+ # given: setup test framework
48
+ mock_dao = mocker .patch ('src.main.DAO' )
49
+ mock_worker = mocker .patch ('src.main.Worker' )
50
+ mock_worker .readData .return_value = None
51
+ app = Application ()
52
+
53
+ # when:
54
+
55
+ # then:
56
+ AssertThat (mock_worker .readData ).WasCalled ().Once ()
You can’t perform that action at this time.
0 commit comments