44import json
55
66
7+ OPEN_FILE = 'builtins.open'
8+
9+
710def test_get_by_id__return_activity_dto__when_find_activity_that_matches_its_id (
811 mocker ,
912):
1013 activities_json_dao = ActivitiesJsonDao ('non-important-path' )
11- open_file = 'builtins.open'
1214 activities = [
1315 {
1416 "name" : "test_name" ,
@@ -23,7 +25,7 @@ def test_get_by_id__return_activity_dto__when_find_activity_that_matches_its_id(
2325 read_data = json .dumps (activities )
2426 activity_dto = ActivityDto (** activities .pop ())
2527
26- mocker .patch (open_file , mocker .mock_open (read_data = read_data ))
28+ mocker .patch (OPEN_FILE , mocker .mock_open (read_data = read_data ))
2729
2830 result = activities_json_dao .get_by_id (activity_dto .id )
2931
@@ -34,11 +36,10 @@ def test__get_by_id__return_httpstatus_not_found__when_no_activity_matches_its_i
3436 mocker ,
3537):
3638 activities_json_dao = ActivitiesJsonDao ('non-important-path' )
37- open_file = 'builtins.open'
3839 activity = []
3940 read_data = json .dumps (activity )
4041
41- mocker .patch (open_file , mocker .mock_open (read_data = read_data ))
42+ mocker .patch (OPEN_FILE , mocker .mock_open (read_data = read_data ))
4243
4344 result = activities_json_dao .get_by_id ('non-important-id' )
4445
@@ -49,7 +50,6 @@ def test_get_all__return_list_of_activity_dto__when_find_one_or_more_activities(
4950 mocker ,
5051):
5152 activities_json_dao = ActivitiesJsonDao ('non-important-path' )
52- open_file = 'builtins.open'
5353 activity = {
5454 "name" : "test_name" ,
5555 "description" : "test_description" ,
@@ -66,7 +66,7 @@ def test_get_all__return_list_of_activity_dto__when_find_one_or_more_activities(
6666 activities = [activity ] * number_of_activities
6767 read_data = json .dumps (activities )
6868
69- mocker .patch (open_file , mocker .mock_open (read_data = read_data ))
69+ mocker .patch (OPEN_FILE , mocker .mock_open (read_data = read_data ))
7070
7171 result = activities_json_dao .get_all ()
7272
@@ -75,12 +75,11 @@ def test_get_all__return_list_of_activity_dto__when_find_one_or_more_activities(
7575
7676def test_get_all__return_empty_list__when_doesnt_found_any_activities (mocker ):
7777 activities_json_dao = ActivitiesJsonDao ('non-important-path' )
78- open_file = 'builtins.open'
7978 activities = []
8079
8180 read_data = json .dumps (activities )
8281
83- mocker .patch (open_file , mocker .mock_open (read_data = read_data ))
82+ mocker .patch (OPEN_FILE , mocker .mock_open (read_data = read_data ))
8483
8584 result = activities_json_dao .get_all ()
8685
0 commit comments