def test_run_error(): client = utils.client.create(**CONFIG["toolbox_test_instance"]) project = Project.from_json(client, resource_json={ "name": "fake", "type": "NOT_REAL" }) with pytest.raises(KeyError): workflow.jobs.run([project])
def create(self, creation_spec): """ Create a Project in Tamr :param creation_spec: Project creation specification should be formatted as specified in the `Public Docs for Creating a Project <https://docs.tamr.com/reference#create-a-project>`_. :type creation_spec: dict[str, str] :returns: The created Project :rtype: :class:`~tamr_unify_client.project.resource.Project` """ data = self.client.post(self.api_path, json=creation_spec).successful().json() return Project.from_json(self.client, data)
def test_get_versions(self): def create_callback(request, snoop): snoop["payload"] = request.body return 200, {}, "\n".join( json.dumps(c) for c in self._versions_json) p = Project.from_json(self.tamr, self._project_json).as_mastering() post_url = f"http://localhost:9100/api/versioned/v1/{p.api_path}/publishedClusterVersions" snoop = {} responses.add_callback(responses.POST, post_url, partial(create_callback, snoop=snoop)) clusters = list(p.published_cluster_versions(self._cluster_ids)) expected_clusters = [PublishedCluster(c) for c in self._versions_json] self.assertEqual(snoop["payload"], "\n".join([json.dumps(i) for i in self._cluster_ids])) self.assertEqual(len(clusters), len(expected_clusters)) for actual, expected in zip(clusters, expected_clusters): self.assertEqual(actual.__repr__(), expected.__repr__()) self.assertEqual(len(actual.versions), len(expected.versions))