Skip to content

Commit

Permalink
Merge pull request #74 from usnistgov/fix/unit
Browse files Browse the repository at this point in the history
Get Angular unit tests working again
  • Loading branch information
RayPlante authored May 13, 2019
2 parents d774590 + 692e9aa commit 22713e8
Show file tree
Hide file tree
Showing 32 changed files with 11,737 additions and 368 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ before_install:
script:
- echo && echo '#####' BUILDING AND RUNNING PYTHON TESTS && echo
- bash ./testall python
- echo && echo '#####' BUILDING '(only)' ANGULAR && echo
- echo && echo '#####' BUILDING ANGULAR && echo
- bash ./makedist angular
- echo && echo '#####' RUNNING ANGULAR TESTS && echo
- bash ./testall angular
155 changes: 149 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,66 @@ This repository provides the implementation of the NIST Publishing
Data Repository (PDR) platform, the technology that provides the NIST
Data Publishing Repository (DPR).

The software provided in this repository has two main parts:
1. The Landing Page Service -- this converts JSON metadata
descriptions into viewable HTML presentations. It is written
in Typescript using the Angular web application framework.
2. Publishing services -- this set of services, written in Python,
provides web services that support the publishing process,
including providing pre-publication metadata and preserving
datasets.

## Contents

```
docker/ --> Docker containers for running tests
java/ --> Java source code (none at this time)
python --> Python source code for the metadata and preservation
services
angular --> Angular (Typescript) source code for the landing page
service
scripts --> Tools for running the services and running all tests
oar-build --> general oar build system support (do not customize)
docker/ --> Docker containers for building and running tests
```

## Prerequisites

### Landing page service

As a Javascript/Typescript application, this product is built and run using
`node` and `npm`. Both become available by installing,

* node 8.9.0 or higher

All prerequisite Javascript modules needed are provided via the `npm`
build tool. See `angular/package.json` for a listing of primary
dependencies and `angular/package-lock.json` for a complete listing of
all dependencies.

### Publishing services

The publishing services are built and run using Python (supporting
versions 2.7.11 through 2.7.13).

The oar-metadata package is a prerequisite which is configured as git
sub-module of this package. This means after you clone the git
sub-module of this package. This means after you clone the oar-pdr git
repository, you should use `git submodule` to pull in the oar-metadata
package into it:

```
git submodule update --init
```

See oar-metadata/README.md for a list of its prerequisites.

In addition or oar-metadata, this package has the following
third-party packages as prerequisites:
In addition to oar-metadata and its prerequisites, this package requires
the following third-party packages:

* multibag v0.4 or later
* multibag-py v0.4 or later
* bagit v1.6.X
* fs v2.X.X

### Acquiring prerequisites via Docker

As an alternative to explicitly installing prerequisites to run
the tests, the `docker` directory contains scripts for building a
Docker container with these installed. Running the `docker/run.sh`
Expand All @@ -42,6 +72,119 @@ container, and put the user in a bash shell in the container. From
there, one can run the tests or use the `jq` and `validate` tools to
interact with metadata files.

# Building and Testing the software

This repository provides two specific software products:
* `pdr-lps` -- the Landing Page Service
* `pdr-publish` -- the publishing services

## Simple Building with `makedist`

As a standard OAR repository, the software products can be built by simply via
the `makedist` script, assuming the prerequisites are installed:

```
scripts/makedist
```

The built products will be written into the `dist` subdirectory
(created by the `makedist`); each will be written into a zip-formatted
file with a name formed from the product name and a version string.

The individual products can be built separately by specifying the
product name as arguments, e.g:

```
scripts/makedist pdr-lps
scripts/makedist pdr-publish
```

Additional options are available; use the `-h` option to view the
details:

```
scripts/makedist -h
```

### Simple Testing with `testall`

Assuming the prerequisites are installed, the `testall` script can be
used to execute all unit and integration tests:

```
scripts/testall
```

Like with `makedist`, you can run the tests for the different products
separately by listing the desired product names as arguments to
`testall`. Running `testall -h` will explain available command-line
options.

### Building and Testing Using Native Tools

The `makedist` and `testall` scripts are simply wrappers around the
native build tools for the products--namely, `npm` and `python`. You
can use these tools directly to build and test. Consult the
`README.md` files in the [angular](angular) and [python](python)
directories for more details.

### Building and Testing Using Docker

Like all standard OAR repositories, this repository supports the use
of Docker to build the software and run its tests. (This method is
used at NIST in production operations.) The advantage of the Docker
method is that it is not necessary to first install the
prerequisites; this are installed automatically into Docker
containers.

To build the software via a docker container, use the
`makedist.docker` script:

```
scripts/makedist.docker
```

Similarly, `testall.docker` runs the tests in a container:

```
scripts/testall.docker
```

Like their non-docker counterparts, these scripts accept product names
as arguments.

## Running the services

Consult the `README.md` files in the [angular](angular) and [python](python)
directories for details on how to launch the services provided by the
software products.

## License and Disclaimer

This software was developed by employees and contractors of the
National Institute of Standards and Technology (NIST), an agency of
the Federal Government and is being made available as a public
service. Pursuant to title 17 United States Code Section 105, works of
NIST employees are not subject to copyright protection in the United
States. This software may be subject to foreign copyright.
Permission in the United States and in foreign countries, to the
extent that NIST may hold copyright, to use, copy, modify, create
derivative works, and distribute this software and its documentation
without fee is hereby granted on a non-exclusive basis, provided that
this notice and disclaimer of warranty appears in all copies.

THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND,
EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, ANY WARRANTY THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, AND FREEDOM FROM INFRINGEMENT, AND ANY WARRANTY THAT THE
DOCUMENTATION WILL CONFORM TO THE SOFTWARE, OR ANY WARRANTY THAT THE
SOFTWARE WILL BE ERROR FREE. IN NO EVENT SHALL NIST BE LIABLE FOR ANY
DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL OR
CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, OR IN ANY WAY
CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY,
CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY
PERSONS OR PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS
SUSTAINED FROM, OR AROSE OUT OF THE RESULTS OF, OR USE OF, THE
SOFTWARE OR SERVICES PROVIDED HEREUNDER.

88 changes: 70 additions & 18 deletions angular/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
# Angular application for landing page service
Angular 5.2.4+ built from scratch, using the angular-cli.
# PDR Landing Page Service

This directory provides the `pdr-lps` software product, an
[Angular](https://angular.io) application providing HTML landing page
views of datasets in the PDR.

### Prerequisites
This software is built on the Angular framework using Angular CLI and
Angular Universal (the latter providing server-side rendering) and
implemented primarily in Typescript. It is currently built on Angular
6.

- [node](https://nodejs.org/en/download/) version 8.9.4 or higher.
- [Get VS Code](https://code.visualstudio.com/download).
- [Angular CLI](https://github.com/angular/angular-cli) version 1.6.8.
## Prerequisites

- [node](https://nodejs.org/en/download/) version 8.9.4 or higher.
(10.9 is recommended). This provides the `npm` build tool.

### Building the app from scratch
All other required modules can be installed automatically via the
`npm` tool (by typing `npm install` in this directory.

You may be interested these related links:
- [Get VS Code](https://code.visualstudio.com/download) (an IDE)
- [Angular CLI](https://github.com/angular/angular-cli) version 1.6.8.

## Building the app from scratch

### Quick start
### Downloading this repository

```bash
# clone the repo
Expand All @@ -24,32 +34,74 @@ cd angular

```

## Build
(Note that the [oar-metadata](https://github.com/usnistgove/oar-metadata)
submodule is not needed for building and running the Angular code.)

### Building the application

The `npm` tool is used to build, test, and run the Angular application.
To install the Typescript compiler and all required Javascript modules, type:

```bash
npm install
```

npm run build:universal
This only needs to be done once, unless dependencies (recorded in the
`package.json` file) change.

npm run serve:universal
To build the application, type

```bash
npm run build:ssr
```

### Running the tests

To run the unit tests and the integration tests (also refered to as _e2e
tests_), type, respectively:

# navigate with your browser to http://localhost:4200/
```bash
npm test
npm e2e
```

_Note: e2e tests are currently disabled._

_Editor's Note: add info about running/debugging tests interactively._

### Running the service

_Editor's note: Need some instruction on configuring the service._

This application can run with browser-only operation (i.e. _without_
server-side rendering), via the following command:

```bash
npm serve
```
## Running unit tests

npm run test
This will serve the application via a local web server; one can use a browser
to interact with it by accessing URLs based at `http://localhost:4000`.

## Running end-to-end tests
To run the application with server-side rendering type:

npm run e2e-test
```bash
npm run serve:universal
```

This will run `node` as a web server, serving the application via URLs based
at http://localhost:4200/.

## Further help
## Further information

### Libraries
- [bootstrap](https://github.com/twbs/bootstrap) - The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
- [ng-bootstrap](https://ng-bootstrap.github.io) - Angular powered Bootstrap
- [font-awesome 5.x](https://github.com/FortAwesome/Font-Awesome) - Get vector icons and social logos on your website with Font Awesome, the web’s most popular icon set and toolkit.

## Code scaffolding
## Developing

### Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class/module`.

Loading

0 comments on commit 22713e8

Please sign in to comment.