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" |
| 23 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 24 | tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile" |
| 25 | tp_pb "github.com/opencord/voltha-protos/v3/go/tech_profile" |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 26 | ) |
| 27 | |
| 28 | // MockTechProfile mock struct for OpenoltClient. |
| 29 | type MockTechProfile struct { |
| 30 | TpID uint32 |
| 31 | } |
| 32 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 33 | // SetKVClient to mock techprofile SetKVClient method |
sbarbari | a8910ba | 2019-11-05 10:12:23 -0500 | [diff] [blame] | 34 | func (m MockTechProfile) SetKVClient() *db.Backend { |
| 35 | return &db.Backend{Client: &MockKVClient{}} |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 36 | } |
| 37 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 38 | // GetTechProfileInstanceKVPath to mock techprofile GetTechProfileInstanceKVPath method |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 39 | func (m MockTechProfile) GetTechProfileInstanceKVPath(techProfiletblID uint32, uniPortName string) string { |
| 40 | return "" |
| 41 | |
| 42 | } |
| 43 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 44 | // GetTPInstanceFromKVStore to mock techprofile GetTPInstanceFromKVStore method |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 45 | func (m MockTechProfile) GetTPInstanceFromKVStore(ctx context.Context, techProfiletblID uint32, path string) (*tp.TechProfile, error) { |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 46 | log.Debug("Warning Warning Warning: GetTPInstanceFromKVStore") |
| 47 | return nil, nil |
| 48 | |
| 49 | } |
| 50 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 51 | // CreateTechProfInstance to mock techprofile CreateTechProfInstance method |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 52 | 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] | 53 | |
| 54 | return &tp.TechProfile{ |
| 55 | Name: "mock-tech-profile", |
| 56 | SubscriberIdentifier: "257", |
| 57 | ProfileType: "mock", |
| 58 | Version: 0, |
| 59 | NumGemPorts: 2, |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 60 | UpstreamGemPortAttributeList: nil, |
| 61 | DownstreamGemPortAttributeList: nil, |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 62 | }, nil |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 63 | |
| 64 | } |
| 65 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 66 | // DeleteTechProfileInstance to mock techprofile DeleteTechProfileInstance method |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 67 | func (m MockTechProfile) DeleteTechProfileInstance(ctx context.Context, techProfiletblID uint32, uniPortName string) error { |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 68 | return nil |
| 69 | } |
| 70 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 71 | // GetprotoBufParamValue to mock techprofile GetprotoBufParamValue method |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 72 | func (m MockTechProfile) GetprotoBufParamValue(paramType string, paramKey string) int32 { |
| 73 | return 0 |
| 74 | |
| 75 | } |
| 76 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 77 | // GetUsScheduler to mock techprofile GetUsScheduler method |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 78 | func (m MockTechProfile) GetUsScheduler(tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) { |
| 79 | return &tp_pb.SchedulerConfig{}, nil |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 80 | |
| 81 | } |
| 82 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 83 | // GetDsScheduler to mock techprofile GetDsScheduler method |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 84 | func (m MockTechProfile) GetDsScheduler(tpInstance *tp.TechProfile) (*tp_pb.SchedulerConfig, error) { |
| 85 | return &tp_pb.SchedulerConfig{}, nil |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 86 | } |
| 87 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 88 | // GetTrafficScheduler to mock techprofile GetTrafficScheduler method |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 89 | func (m MockTechProfile) GetTrafficScheduler(tpInstance *tp.TechProfile, SchedCfg *tp_pb.SchedulerConfig, |
| 90 | ShapingCfg *tp_pb.TrafficShapingInfo) *tp_pb.TrafficScheduler { |
| 91 | return &tp_pb.TrafficScheduler{} |
| 92 | |
| 93 | } |
| 94 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 95 | // GetTrafficQueues to mock techprofile GetTrafficQueues method |
Girish Kumar | 8f73fe0 | 2019-12-09 13:19:37 +0000 | [diff] [blame] | 96 | func (m MockTechProfile) GetTrafficQueues(tp *tp.TechProfile, Dir tp_pb.Direction) ([]*tp_pb.TrafficQueue, error) { |
| 97 | return []*tp_pb.TrafficQueue{{}}, nil |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 98 | } |
| 99 | |
Scott Baker | ee7c0a0 | 2020-01-07 11:12:26 -0800 | [diff] [blame] | 100 | // GetMulticastTrafficQueues to mock techprofile GetMulticastTrafficQueues method |
| 101 | func (m MockTechProfile) GetMulticastTrafficQueues(tp *tp.TechProfile) []*tp_pb.TrafficQueue { |
| 102 | return []*tp_pb.TrafficQueue{{}} |
| 103 | } |
| 104 | |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 105 | // GetGemportIDForPbit to mock techprofile GetGemportIDForPbit method |
kdarapu | b26b450 | 2019-10-05 03:02:33 +0530 | [diff] [blame] | 106 | func (m MockTechProfile) GetGemportIDForPbit(tp *tp.TechProfile, Dir tp_pb.Direction, pbit uint32) uint32 { |
| 107 | return 0 |
| 108 | } |
Girish Gowdra | 5493426 | 2019-11-13 14:19:55 +0530 | [diff] [blame] | 109 | |
| 110 | // FindAllTpInstances to mock techprofile FindAllTpInstances method |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 111 | 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] | 112 | return []tp.TechProfile{} |
| 113 | } |