kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //Package mocks provides the mocks for openolt-adapter. |
| 18 | package mocks |
| 19 | |
| 20 | import ( |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 21 | "context" |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 22 | "github.com/opencord/voltha-lib-go/v3/pkg/db" |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 23 | tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile" |
| 24 | tp_pb "github.com/opencord/voltha-protos/v3/go/tech_profile" |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 25 | ) |
| 26 | |
| 27 | // MockTechProfile mock struct for OpenoltClient. |
| 28 | type MockTechProfile struct { |
| 29 | TpID uint32 |
| 30 | } |
| 31 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 32 | // SetKVClient to mock techprofile SetKVClient method |
sbarbari | a8910ba | 2019-11-05 10:12:23 -0500 | [diff] [blame] | 33 | func (m MockTechProfile) SetKVClient() *db.Backend { |
| 34 | return &db.Backend{Client: &MockKVClient{}} |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 35 | } |
| 36 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 37 | // GetTechProfileInstanceKVPath to mock techprofile GetTechProfileInstanceKVPath method |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 38 | func (m MockTechProfile) GetTechProfileInstanceKVPath(techProfiletblID uint32, uniPortName string) string { |
| 39 | return "" |
| 40 | |
| 41 | } |
| 42 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 43 | // GetTPInstanceFromKVStore to mock techprofile GetTPInstanceFromKVStore method |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 44 | func (m MockTechProfile) GetTPInstanceFromKVStore(ctx context.Context, techProfiletblID uint32, path string) (*tp.TechProfile, error) { |
Girish Kumar | 2ad402b | 2020-03-20 19:45:12 +0000 | [diff] [blame] | 45 | logger.Debug("Warning Warning Warning: GetTPInstanceFromKVStore") |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 46 | return nil, nil |
| 47 | |
| 48 | } |
| 49 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 50 | // CreateTechProfInstance to mock techprofile CreateTechProfInstance method |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 51 | func (m MockTechProfile) CreateTechProfInstance(ctx context.Context, techProfiletblID uint32, uniPortName string, intfID uint32) (*tp.TechProfile, error) { |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 52 | |
| 53 | return &tp.TechProfile{ |
| 54 | Name: "mock-tech-profile", |
| 55 | SubscriberIdentifier: "257", |
| 56 | ProfileType: "mock", |
| 57 | Version: 0, |
| 58 | NumGemPorts: 2, |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 59 | UpstreamGemPortAttributeList: nil, |
| 60 | DownstreamGemPortAttributeList: nil, |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 61 | }, nil |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 62 | |
| 63 | } |
| 64 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 65 | // DeleteTechProfileInstance to mock techprofile DeleteTechProfileInstance method |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 66 | func (m MockTechProfile) DeleteTechProfileInstance(ctx context.Context, techProfiletblID uint32, uniPortName string) error { |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 67 | return nil |
| 68 | } |
| 69 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 70 | // GetprotoBufParamValue to mock techprofile GetprotoBufParamValue method |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 71 | func (m MockTechProfile) GetprotoBufParamValue(paramType string, paramKey string) int32 { |
| 72 | return 0 |
| 73 | |
| 74 | } |
| 75 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 76 | // GetUsScheduler to mock techprofile GetUsScheduler method |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 77 | func (m MockTechProfile) GetUsScheduler(tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) { |
| 78 | return &tp_pb.SchedulerConfig{}, nil |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 79 | |
| 80 | } |
| 81 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 82 | // GetDsScheduler to mock techprofile GetDsScheduler method |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 83 | func (m MockTechProfile) GetDsScheduler(tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) { |
| 84 | return &tp_pb.SchedulerConfig{}, nil |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 85 | } |
| 86 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 87 | // GetTrafficScheduler to mock techprofile GetTrafficScheduler method |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 88 | func (m MockTechProfile) GetTrafficScheduler(tpInstance *tp.TechProfile, SchedCfg *tp_pb.SchedulerConfig, |
| 89 | ShapingCfg *tp_pb.TrafficShapingInfo) *tp_pb.TrafficScheduler { |
| 90 | return &tp_pb.TrafficScheduler{} |
| 91 | |
| 92 | } |
| 93 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 94 | // GetTrafficQueues to mock techprofile GetTrafficQueues method |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 95 | func (m MockTechProfile) GetTrafficQueues(tp *tp.TechProfile, Dir tp_pb.Direction) ([]*tp_pb.TrafficQueue, error) { |
| 96 | return []*tp_pb.TrafficQueue{{}}, nil |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 97 | } |
| 98 | |
Scott Baker | ee7c0a0 | 2020-01-07 11:12:26 -0800 | [diff] [blame] | 99 | // GetMulticastTrafficQueues to mock techprofile GetMulticastTrafficQueues method |
| 100 | func (m MockTechProfile) GetMulticastTrafficQueues(tp *tp.TechProfile) []*tp_pb.TrafficQueue { |
| 101 | return []*tp_pb.TrafficQueue{{}} |
| 102 | } |
| 103 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 104 | // GetGemportIDForPbit to mock techprofile GetGemportIDForPbit method |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 105 | func (m MockTechProfile) GetGemportIDForPbit(tp *tp.TechProfile, Dir tp_pb.Direction, pbit uint32) uint32 { |
| 106 | return 0 |
| 107 | } |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 108 | |
| 109 | // FindAllTpInstances to mock techprofile FindAllTpInstances method |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 110 | func (m MockTechProfile) FindAllTpInstances(ctx context.Context, techProfiletblID uint32, ponIntf uint32, onuID uint32) []tp.TechProfile { |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 111 | return []tp.TechProfile{} |
| 112 | } |