summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/tests/views
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-12-09 16:52:47 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-12 20:44:53 +0000
commit8eed2641636791574d35a9d3a445ee55c7b2258d (patch)
treed1d5c2c4c66581bb2d2199f79938f8a4876de554 /bitbake/lib/toaster/tests/views
parentf2b0d43c2f010edc47c6a28f23aa862228ec0c27 (diff)
downloadpoky-8eed2641636791574d35a9d3a445ee55c7b2258d.tar.gz
poky-8eed2641636791574d35a9d3a445ee55c7b2258d.tar.bz2
poky-8eed2641636791574d35a9d3a445ee55c7b2258d.zip
bitbake: toaster: tests Update import layer test to use new Layer add api
(Bitbake rev: d4c79cd60c12d329c533add73e88b7184dca6ca3) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/tests/views')
-rw-r--r--bitbake/lib/toaster/tests/views/test_views.py45
1 files changed, 23 insertions, 22 deletions
diff --git a/bitbake/lib/toaster/tests/views/test_views.py b/bitbake/lib/toaster/tests/views/test_views.py
index c20b3fe0b6..1463077e91 100644
--- a/bitbake/lib/toaster/tests/views/test_views.py
+++ b/bitbake/lib/toaster/tests/views/test_views.py
@@ -142,35 +142,36 @@ class ViewTests(TestCase):
# from each of the urls
self.assertTrue(results)
- def test_xhr_import_layer(self):
- """Test xhr_importlayer API"""
+ def test_xhr_add_layer(self):
+ """Test xhr_add API"""
# Test for importing an already existing layer
- args = {'vcs_url': "git://git.example.com/test",
- 'name': "base-layer",
- 'git_ref': "c12b9596afd236116b25ce26dbe0d793de9dc7ce",
- 'project_id': self.project.id,
- 'local_source_dir': "",
- 'dir_path': "/path/in/repository"}
- response = self.client.post(reverse('xhr_importlayer'), args)
+ api_url = reverse('xhr_layer', args=(self.project.id,))
+
+ layer_data = {'vcs_url': "git://git.example.com/test",
+ 'name': "base-layer",
+ 'git_ref': "c12b9596afd236116b25ce26dbe0d793de9dc7ce",
+ 'project_id': self.project.id,
+ 'local_source_dir': "",
+ 'add_to_project': True,
+ 'dir_path': "/path/in/repository"}
+
+ layer_data_json = json.dumps(layer_data)
+
+ response = self.client.put(api_url, layer_data_json)
data = json.loads(response.content.decode('utf-8'))
self.assertEqual(response.status_code, 200)
self.assertEqual(data["error"], "ok")
- # Test to verify import of a layer successful
- args['name'] = "meta-oe"
- response = self.client.post(reverse('xhr_importlayer'), args)
- data = json.loads(response.content.decode('utf-8'))
- self.assertTrue(data["error"], "ok")
-
- # Test for html tag in the data
- args['<'] = "testing html tag"
- response = self.client.post(reverse('xhr_importlayer'), args)
- data = json.loads(response.content.decode('utf-8'))
- self.assertNotEqual(data["error"], "ok")
+ self.assertTrue(
+ layer_data['name'] in
+ self.project.get_all_compatible_layer_versions().values_list(
+ 'layer__name',
+ flat=True),
+ "Could not find imported layer in project's all layers list"
+ )
# Empty data passed
- args = {}
- response = self.client.post(reverse('xhr_importlayer'), args)
+ response = self.client.put(api_url, "{}")
data = json.loads(response.content.decode('utf-8'))
self.assertNotEqual(data["error"], "ok")