10000 feat: add odp config by andrewleap-optimizely · Pull Request #401 · optimizely/python-sdk · GitHub
[go: up one dir, main page]

Skip to content

feat: add odp config #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
andrewleap-optimizely committed Aug 19, 2022
commit 38e76643d1f1f17bdaa24fa2333b006d7a819310
52 changes: 52 additions & 0 deletions tests/test_odp_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2022, Optimizely
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations
from tests import base
from optimizely.odp.odp_config import OdpConfig


class OdpConfigTest(base.BaseTest):
api_host = 'test-host'
api_key = 'test-key'
segments_to_check = ['test-segment']

def test_init_config(self):
config = OdpConfig(self.api_key, self.api_host, self.segments_to_check)

self.assertEqual(config.get_api_key(), self.api_key)
self.assertEqual(config.get_api_host(), self.api_host)
self.assertEqual(config.get_segments_to_check(), self.segments_to_check)

def test_update_config(self):
config = OdpConfig()
updated = config.update(self.api_key, self.api_host, self.segments_to_check)

self.assertStrictTrue(updated)
self.assertEqual(config.get_api_key(), self.api_key)
self.assertEqual(config.get_api_host(), self.api_host)
self.assertEqual(config.get_segments_to_check(), self.segments_to_check)

updated = config.update(self.api_key, self.api_host, self.segments_to_check)
self.assertStrictFalse(updated)

def test_config_setters(self):
config = OdpConfig()

config.set_api_host(self.api_host)
config.set_api_key(self.api_key)
config.set_segments_to_check(self.segments_to_check)

self.assertEqual(config.get_api_key(), self.api_key)
self.assertEqual(config.get_api_host(), self.api_host)
self.assertEqual(config.get_segments_to_check(), self.segments_to_check)
0