예제 #1
0
 def test_int(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     self.assertEqual(1, client.get_value('testIntKey', 0))
     client.stop()
예제 #2
0
 def test_invalidation(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     self.assertEqual(True, client.get_value('testBoolKey', False))
     client.stop()
예제 #3
0
 def test_double(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     self.assertEqual(1.1, client.get_value('testDoubleKey', 0.0))
     client.stop()
예제 #4
0
 def test_unknown(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     self.assertEqual('default',
                      client.get_value('testUnknownKey', 'default'))
     client.stop()
예제 #5
0
 def test_get_key_and_value_not_found(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     result = client.get_key_and_value('nonexisting')
     self.assertIsNone(result)
     client.stop()
예제 #6
0
 def test_string(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     self.assertEqual('testValue',
                      client.get_value('testStringKey', 'default'))
     client.stop()
예제 #7
0
 def test_get_variation_id(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     self.assertEqual('fakeId1', client.get_variation_id('key1', None))
     self.assertEqual('fakeId2', client.get_variation_id('key2', None))
     client.stop()
예제 #8
0
 def test_get_variation_id_not_found(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     self.assertEqual(
         'default_variation_id',
         client.get_variation_id('nonexisting', 'default_variation_id'))
     client.stop()
예제 #9
0
 def test_get_all_variation_ids(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     result = client.get_all_variation_ids()
     self.assertEqual(2, len(result))
     self.assertTrue('fakeId1' in result)
     self.assertTrue('fakeId2' in result)
     client.stop()
예제 #10
0
 def test_get_all_keys(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     # Two list should have exactly the same elements, order doesn't matter.
     self.assertEqual(
         {
             'testBoolKey', 'testStringKey', 'testIntKey', 'testDoubleKey',
             'key1', 'key2'
         }, set(client.get_all_keys()))
     client.stop()
예제 #11
0
 def test_get_all_values(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     all_values = client.get_all_values()
     # Two dictionary should have exactly the same elements, order doesn't matter.
     self.assertEqual(6, len(all_values))
     self.assertEqual(True, all_values['testBoolKey'])
     self.assertEqual('testValue', all_values['testStringKey'])
     self.assertEqual(1, all_values['testIntKey'])
     self.assertEqual(1.1, all_values['testDoubleKey'])
     self.assertTrue(all_values['key1'])
     self.assertFalse(all_values['key2'])
     client.stop()
예제 #12
0
 def test_get_key_and_value(self):
     client = ConfigCatClient('test',
                              0,
                              0,
                              None,
                              0,
                              config_cache_class=ConfigCacheMock)
     result = client.get_key_and_value('fakeId1')
     self.assertEqual('key1', result.key)
     self.assertTrue(result.value)
     result = client.get_key_and_value('fakeId2')
     self.assertEqual('key2', result.key)
     self.assertFalse(result.value)
     client.stop()
예제 #13
0
 def test_without_sdk_key(self):
     try:
         ConfigCatClient(None)
         self.fail('Expected ConfigCatClientException')
     except ConfigCatClientException:
         pass
예제 #14
0
 def test_get_key_and_value_empty_config(self):
     client = ConfigCatClient('test', 0, 0, None, 0)
     result = client.get_key_and_value('nonexisting')
     self.assertIsNone(result)
     client.stop()
예제 #15
0
 def test_get_variation_id_empty_config(self):
     client = ConfigCatClient('test', 0, 0, None, 0)
     self.assertEqual(
         'default_variation_id',
         client.get_variation_id('nonexisting', 'default_variation_id'))
     client.stop()