예제 #1
0
    def test_get_pgtjson(self):

        c = RestClient('localhost', lgweb_port, 10)
        c._GET(
            '/gen_pgt?lg_name=logical_graphs/chiles_simple.json&num_par=5&algo=metis&min_goal=0&ptype=0&max_load_imb=100')

        # doesn't exist
        self.assertRaises(RestClientException, c._get_json, '/pgt_jsonbody?pgt_name=unknown.json')
        # good!
        c._get_json('/pgt_jsonbody?pgt_name=logical_graphs/chiles_simple1_pgt.json')
예제 #2
0
    def test_get_lgjson(self):

        c = RestClient('localhost', lgweb_port, 10)

        # a specific one
        lg = c._get_json('/jsonbody?lg_name=logical_graphs/chiles_simple.json')
        self.assertIsNotNone(lg)

        # by default the first one found by the lg_web should be returned
        lg = c._get_json('/jsonbody')
        self.assertIsNotNone(lg)

        # doesn't exist
        self.assertRaises(RestClientException, c._get_json, '/jsonbody?lg_name=doesnt_exist.json')
예제 #3
0
파일: test_lgweb.py 프로젝트: ICRAR/daliuge
    def test_post_lgjson(self):

        c = RestClient("localhost", lgweb_port, timeout=10)

        # new graphs cannot currently be added
        form_data = {
            "lg_name": "new.graph",
            "lg_content": '{"id": 1, "name": "example"}',
            "rmode": "1",
        }
        self.assertRaises(RestClientException, c._post_form, "/jsonbody", form_data)

        # Replace the contents of an existing one
        # (but replace it back with original after the test)
        original_fname = os.path.join(lg_dir, "logical_graphs", "chiles_simple.graph")
        copy_fname = tempfile.mktemp()
        shutil.copy(original_fname, copy_fname)

        try:
            form_data["lg_name"] = "logical_graphs/chiles_simple.graph"
            c._post_form("/jsonbody", form_data)
            new = c._get_json("/jsonbody?lg_name=logical_graphs/chiles_simple.graph")
            self.assertIsNotNone(new)
            self.assertIn("id", new)
            self.assertIn("name", new)
            self.assertEqual(1, new["id"])
            self.assertEqual("example", new["name"])
            self.assertEqual("1", new["reprodata"]["rmode"])
        finally:
            shutil.move(copy_fname, original_fname)
예제 #4
0
파일: test_lgweb.py 프로젝트: xyuan/daliuge
    def test_post_lgjson(self):

        c = RestClient('localhost', lgweb_port, 10)

        # new graphs cannot currently be added
        form_data = {
            'lg_name': 'new.json',
            'lg_content': '{"id": 1, "name": "example"}'
        }
        self.assertRaises(RestClientException, c._post_form, '/jsonbody',
                          form_data)

        # Replace the contents of an existing one
        # (but replace it back with original after the test)
        original_fname = os.path.join(lg_dir, 'logical_graphs',
                                      'chiles_simple.json')
        copy_fname = tempfile.mktemp()
        shutil.copy(original_fname, copy_fname)

        try:
            form_data['lg_name'] = 'logical_graphs/chiles_simple.json'
            c._post_form('/jsonbody', form_data)
            new = c._get_json(
                '/jsonbody?lg_name=logical_graphs/chiles_simple.json')
            self.assertIsNotNone(new)
            self.assertIn('id', new)
            self.assertIn('name', new)
            self.assertEqual(1, new['id'])
            self.assertEqual('example', new['name'])
        finally:
            shutil.move(copy_fname, original_fname)