Skip to content

Commit

Permalink
Fix Projection response type, and update tests to use attr; (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmschmidt authored Aug 26, 2024
1 parent 5c0d7ac commit 0325907
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ type TagStatus = {
is_complete: boolean;
};

export class AtlasProjection extends BaseAtlasClass<ProjectGetInfo> {
export class AtlasProjection extends BaseAtlasClass<
components['schemas']['ProjectionResponse']
> {
/**
* A projection is a map in Atlas; it represents a snapshot 2d view of a dataset
* at a point in time. Every projection belongs to a Dataset.
Expand Down
20 changes: 15 additions & 5 deletions tests/project.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { test } from 'uvu';
import * as arrow from 'apache-arrow';
import * as assert from 'uvu/assert';
import { AtlasDataset } from '../dist/project.js';
import { make_test_table } from './arrow.test.js';
Expand All @@ -10,12 +9,14 @@ import { AtlasOrganization } from '../dist/organization.js';
test('Full project flow', async () => {
// get user
console.log('getting user');
const user = new AtlasUser({ useEnvToken: true });
const user = await new AtlasUser({
useEnvToken: true,
}).withLoadedAttributes();

console.log('THIS TEST IS RUNNING ON: ', user.apiLocation);
// get organization for user
console.log('getting organization');
const user_info = await user.info();
const user_info = user.attr;
let organization_id = null;
if (user_info.default_organization === undefined) {
organization_id = user_info.organizations[0].organization_id;
Expand All @@ -38,12 +39,21 @@ test('Full project flow', async () => {
});
// fetch project from user and project id
console.log('fetching project');
const project2 = new AtlasDataset(project.id, user);
const project2 = await new AtlasDataset(
project.id,
user
).withLoadedAttributes();
console.log(project2);
assert.is(project2.id, project.id);
// upload arrow table to project
console.log('uploading arrow');
const tb = make_test_table({ length: 50, modality: 'text' });
await project.uploadArrow(tb);

await project.uploadArrow(tb).catch((err) => {
console.log(err);
throw err;
});

// create index on project
console.log('creating index');
await project.createIndex({
Expand Down
23 changes: 12 additions & 11 deletions tests/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import { AtlasOrganization } from '../dist/organization.js';
// TODO - should have a dedicated test account here

test('AtlasOrganization test', async () => {
const user = new AtlasUser({ useEnvToken: true });
const user = await new AtlasUser({
useEnvToken: true,
}).withLoadedAttributes();

const info = await user.info().catch((err) => {
console.error(err);
throw err;
});
const info = user.attr;

const organization = new AtlasOrganization(
info.organizations[0].organization_id,
Expand All @@ -23,19 +22,21 @@ test('AtlasOrganization test', async () => {
test('AtlasUser from env variables', async () => {
// This is using the ATLAS_API_KEY env variable
// If this isn't found it will break
const user = new AtlasUser({ useEnvToken: true });
const info = await user.info();
assert.type(info, 'object');
const user = await new AtlasUser({
useEnvToken: true,
}).withLoadedAttributes();
assert.type(user.attr, 'object');
});

test('AtlasUser from api key', async () => {
const key = process.env.ATLAS_API_KEY;
if (key === undefined) {
throw new Error('ATLAS_API_KEY not set');
}
const user = new AtlasUser({ apiKey: key });
const info = await user.info();
assert.type(info, 'object');
const user = await new AtlasUser({
useEnvToken: true,
}).withLoadedAttributes();
assert.type(user.attr, 'object');
});

// TODO - tests for bearer token login
Expand Down

0 comments on commit 0325907

Please sign in to comment.