@patch('polyaxon_sdk.ProjectsV1Api.create_version')
@patch('polyaxon_sdk.ProjectsV1Api.patch_version')
@patch('polyaxon_sdk.ProjectsV1Api.get_version')
def test_create_artifact(self, get_version, patch_version, create_version):
    self.runner.invoke(artifacts, ['register'])
    assert (create_version.call_count == 0)
    assert (patch_version.call_count == 0)
    assert (get_version.call_count == 0)
    get_version.return_value = None
    self.runner.invoke(artifacts, ['register', '--project=owner/foo'])
    assert (get_version.call_count == 1)
    assert (patch_version.call_count == 0)
    assert (create_version.call_count == 1)
    get_version.return_value = MagicMock(kind=V1ProjectVersionKind.ARTIFACT)
    self.runner.invoke(artifacts, ['register', '--project=owner/foo'])
    assert (get_version.call_count == 2)
    assert (patch_version.call_count == 0)
    assert (create_version.call_count == 1)
    self.runner.invoke(artifacts, ['register', '--project=owner/foo', '--force'])
    assert (get_version.call_count == 3)
    assert (patch_version.call_count == 1)
    assert (create_version.call_count == 1)
@patch('polyaxon_sdk.ProjectsV1Api.create_version')
@patch('polyaxon_sdk.ProjectsV1Api.patch_version')
@patch('polyaxon_sdk.ProjectsV1Api.get_version')
def test_create_artifact(self, get_version, patch_version, create_version):
    self.runner.invoke(artifacts, ['register'])
    assert (create_version.call_count == 0)
    assert (patch_version.call_count == 0)
    assert (get_version.call_count == 0)
    get_version.return_value = None
    self.runner.invoke(artifacts, ['register', '--project=owner/foo'])
    assert (get_version.call_count == 1)
    assert (patch_version.call_count == 0)
    assert (create_version.call_count == 1)
    get_version.return_value = MagicMock(kind=V1ProjectVersionKind.ARTIFACT)
    self.runner.invoke(artifacts, ['register', '--project=owner/foo'])
    assert (get_version.call_count == 2)
    assert (patch_version.call_count == 0)
    assert (create_version.call_count == 1)
    self.runner.invoke(artifacts, ['register', '--project=owner/foo', '--force'])
    assert (get_version.call_count == 3)
    assert (patch_version.call_count == 1)
    assert (create_version.call_count == 1)