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

1import sys 

2import os 

3 

4sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../../../") 

5from sdc_etl_libs.api_helpers.apis.Ultipro.UltiproTimeManagement import UltiproTimeManagement 

6 

7 

8def test_no_data(mocker): 

9 mocker.patch('sdc_etl_libs.api_helpers.API.API.get_credentials', 

10 return_value={"tm_username": "foo", "tm_password": "bar"}) 

11 

12 class ReqMock: 

13 status_code = 200 

14 content = """{ 

15 "@odata.context": "http://knw12.ulticlock.com/UtmOdataServices/api$metadata#OrgLevel1", 

16 "@odata.count": 0, 

17 "value": [] 

18 }""" 

19 

20 mocker.patch('requests.get', return_value=ReqMock) 

21 

22 ultipro = UltiproTimeManagement() 

23 

24 df = ultipro.get_data_from_endpoint('org-level-1', 'OrgLevel1', None, limit_=100) 

25 assert (df == None) 

26 

27 

28def test_yes_data(mocker): 

29 mocker.patch('sdc_etl_libs.api_helpers.API.API.get_credentials', 

30 return_value={"tm_username": "foo", "tm_password": "bar"}) 

31 

32 class ReqMock: 

33 status_code = 200 

34 content = """{ 

35 "@odata.context": "http://knw12.ulticlock.com/UtmOdataServices/api/$metadata#OrgLevel1", 

36 "@odata.count": 3, 

37 "value": [ 

38 { 

39 "Id": 3, 

40 "Name": "11000", 

41 "Description": "Admin" 

42 }, 

43 { 

44 "Id": 4, 

45 "Name": "11006", 

46 "Description": "CorpDev" 

47 }, 

48 { 

49 "Id": 5, 

50 "Name": "11001", 

51 "Description": "Finance" 

52 } 

53 ]}""" 

54 

55 mocker.patch('requests.get', return_value=ReqMock) 

56 

57 ultipro = UltiproTimeManagement() 

58 

59 df = ultipro.get_data_from_endpoint('org-level-1', 'OrgLevel1', None, limit_=100) 

60 assert df.df.shape == (3, 4)