示例#1
0
 def test_case13(self):
     """创建dataset, storage非法"""
     dataset_name = time.strftime("%Y%m%d%H%M%S",
                                  time.localtime()) + 'dataset'
     schema_info = schema()
     data = {
         "name": self.dataset_name,
         "schema": schema_info,
         "storage": "HDF",
         "expiredPeriod": 0,
         "storageConfigurations": self.storageConfigurations,
         "sliceTime": "",
         "sliceType": "H",
         "owner": owner,
         "resource": dataset_resource
     }
     res = requests.post(url=self.create_dataset_url,
                         headers=get_headers(),
                         data=json.dumps(data))
     # print(res.status_code, 'test_case09', res.text)
     try:
         err = json.loads(res.text)
         err = json.loads(err["err"])
         err_code = int(err["list"][0]["code"])
         self.assertEqual(err_code, 903, '创建dataset, storage非法时err_code不正确')
     except Exception as e:
         print('测试用例--创建dataset, storage非法--执行失败')
示例#2
0
 def test_case08(self):
     """创建dataset, resource参数错误, resource 为dataset的resource"""
     dataset_name = time.strftime("%Y%m%d%H%M%S",
                                  time.localtime()) + 'dataset'
     schema_info = schema()
     data = {
         "name": self.dataset_name,
         "schema": schema_info,
         "storage": "HDFS",
         "expiredPeriod": 0,
         "storageConfigurations": self.storageConfigurations,
         "sliceTime": "",
         "sliceType": "H",
         "owner": owner,
         "resource": schema_resource
     }
     res = requests.post(url=self.create_dataset_url,
                         headers=get_headers(),
                         data=json.dumps(data))
     # print(res.status_code, 'test_case08', res.text)
     err = json.loads(res.text)
     err_message = err["err"]
     err_message = err_message.strip()
     self.assertEqual(err_message, 'dataset resource id is wrong',
                      '创建dataset, resource参数错误时err message不正确')
示例#3
0
 def test_case04(self):
     """--创建HDFS dataset, name参数值为空--"""
     schema_info = schema()
     data = {
         "name": "",
         "schema": schema_info,
         "storage": "HDFS",
         "expiredPeriod": 0,
         "storageConfigurations": self.storageConfigurations,
         "sliceTime": "",
         "sliceType": "H",
         "owner": "2059750c-a300-4b64-84a6-e8b086dbfd42",
         "resource": {
             "id": "39386f75-9b28-43a6-a6bf-bd5e0e85d437"
         }
     }
     res = requests.post(url=self.create_dataset_url,
                         headers=get_headers(),
                         data=json.dumps(data))
     # print(res.status_code, res.text)
     # 取得res.text中的code, 用来做断言
     err = json.loads(res.text)
     err = json.loads(err["err"])
     err_code = int(err["list"][0]["code"])
     self.assertEqual(err_code, 902, '创建HDFS dataset, name参数值为空时err_code错误')
示例#4
0
 def test_case07(self):
     """创建dataset, 缺失resource参数"""
     schema_info = schema()
     data = {
         "name": self.dataset_name,
         "schema": schema_info,
         "storage": "HDFS",
         "expiredPeriod": 0,
         "storageConfigurations": self.storageConfigurations,
         "sliceTime": "",
         "sliceType": "H",
         "owner": "2059750c-a300-4b64-84a6-e8b086dbfd42"
     }
     res = requests.post(url=self.create_dataset_url,
                         headers=get_headers(),
                         data=json.dumps(data))
     err = json.loads(res.text)
     err = json.loads(err["err"])
     err_code = int(err["list"][0]["code"])
     self.assertEqual(err_code, 900, '创建dataset, 缺失resource参数时err_code不正确')
 def test_case02(self):
     """--正常创建HDFSdataset--"""
     dataset_name = time.strftime("%Y%m%d%H%M%S",
                                  time.localtime()) + 'HDFSdataset'
     schema_info = schema()  # data_from_db中schema()查询schema
     data = {
         "name": dataset_name,
         "schema": schema_info,
         "storage": "HDFS",
         "expiredPeriod": 0,
         "storageConfigurations": self.storageConfigurations,
         "owner": "2059750c-a300-4b64-84a6-e8b086dbfd42",
         "resource": {
             "id": "39386f75-9b28-43a6-a6bf-bd5e0e85d437"
         }
     }
     res = requests.post(url=self.create_dataset_url,
                         headers=get_headers(),
                         data=json.dumps(data))
     # 断言成功时响应状态码为201
     print("开始创建hdfs")
     print(res.status_code, res.text)
     self.assertEqual(res.status_code, 201, 'HDFS dataset创建失败')
     text = json.loads(res.text)
     text = text["id"]
     try:
         query = 'select id from merce_dataset where name = "%s"' % dataset_name
         new_dataset = ms.ExecuQuery(query)
     except:
         print('没有查询到datasetname为%s的dataset' % dataset_name)
     else:
         new_dataset = new_dataset[0]["id"]
         # print(text, new_dataset)
         # 根据datasetname查询到dataset ID, 并和返回的text中包含的ID进行对比
         self.assertEqual(text, new_dataset,
                          '返回的dataset id和使用该dataset的 name查询出的id不相等')