def test_search_full_flag_filters_descriptions(self): # By default, should only be searching the name of the country data = self.api.get_countries(search="america") for v in data.values(): self.assertIn("america", v["name"].lower()) default_len = len(data) # When full, should be searching the values too data = self.api.get_countries(search="america", search_full=True) for v in data.values(): self.assertIn("america", str(v).lower()) full_len = len(data) self.assertGreater(full_len, default_len)
def test_can_pass_own_cache_object(self): import urllib2 def test_fetch(url): return urllib2.urlopen(url).read() data = self.api.get_topics() self.assertTrue(data.values()[1].has_key('sourceNote'))
def test_can_pass_own_cache_object(self): def test_fetch(url): return urllib.request.urlopen(url).read() data = self.api.get_topics() self.assertIn('sourceNote', list(data.values())[1])
def test_container_run_command(self, ms): data = OrderedDict( (('command', ['/fake/command']), ('interactive', False), ('wait-for-websocket', False), ('environment', { 'FAKE_ENV': 'fake' }))) self.assertEqual( ms.return_value, self.lxd.container_run_command('trusty-1', *data.values())) self.assertEqual(1, ms.call_count) self.assertEqual(ms.call_args[0][:2], ('POST', '/1.0/containers/trusty-1/exec')) self.assertEqual(json.loads(ms.call_args[0][2]), dict(data))
def test_container_run_command(self, ms): data = OrderedDict(( ('command', ['/fake/command']), ('interactive', False), ('wait-for-websocket', False), ('environment', {'FAKE_ENV': 'fake'}) )) self.assertEqual( ms.return_value, self.lxd.container_run_command('trusty-1', *data.values())) self.assertEqual(1, ms.call_count) self.assertEqual( ms.call_args[0][:2], ('POST', '/1.0/containers/trusty-1/exec')) self.assertEqual( json.loads(ms.call_args[0][2]), dict(data) )
def test_returns_regions(self): data = self.api.get_regions(search="Latin") self.assertTrue(all(['latin' in v['name'].lower() for v in data.values()]))
def test_returns_sources(self): data = self.api.get_sources() source = data.values()[1] self.assertTrue(source.has_key('name'))
def test_returns_topics(self): data = self.api.get_topics() topic = data.values()[1] self.assertTrue(topic.has_key('value')) self.assertTrue(topic.has_key('sourceNote'))
def test_returns_regions(self): data = self.api.get_regions(search="Latin") self.assertTrue( all(['latin' in v['name'].lower() for v in data.values()]))
def test_container_run_command(self, ms): data = OrderedDict( ( ("command", ["/fake/command"]), ("interactive", False), ("wait-for-websocket", False), ("environment", {"FAKE_ENV": "fake"}), ) ) self.assertEqual(ms.return_value, self.lxd.container_run_command("trusty-1", *data.values())) self.assertEqual(1, ms.call_count) self.assertEqual(ms.call_args[0][:2], ("POST", "/1.0/containers/trusty-1/exec")) self.assertEqual(json.loads(ms.call_args[0][2]), dict(data))
def test_returns_sources(self): data = self.api.get_sources() source = list(data.values())[1] self.assertIn('name', source)
def test_returns_topics(self): data = self.api.get_topics() topic = list(data.values())[1] self.assertIn('value', topic) self.assertIn('sourceNote', topic)