Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test for DashDaq.jl + Readme #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.5.0"

[deps]
Dash = "1b08a953-4be3-4667-9a23-3db579824955"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Dash = "0.1.3"
Expand Down
109 changes: 39 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,100 +1,69 @@
# dash_daq
# DashDaq.jl

DAQ components for Dash.
Data Acquistion (DAQ) components for Dash.

Docs: https://dash.plotly.com/dash-daq
[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg
[docs-dev-url]: https://dash-julia.plotly.com/dash_daq
[![][docs-dev-img]][docs-dev-url]

## Installation

`pip install dash_daq`

(Or for Python 3, `pip3 install dash_daq`)

## Getting started for contributors

```sh
# Clone this repository
git clone https://github.com/plotly/dash-daq.git

# Install dependencies
$ yarn

# Watch source for changes and build to `lib/`
$ yarn start
```julia
using Pkg
Pkg.add("DashDaq")
```
## Installation in development mode

## Documentation
Component API documentation can be found at https://dash.plotly.com/dash-daq

## Development

### Demo server

You can start up a demo development server to see a demo of the rendered
components:

```sh
$ yarn demo
$ open http://localhost:9000
```julia
(v1.6) pkg> dev DashDaq
```
## Install specific version

You have to maintain the list of components in `demo/Demo.react.js`.

### Code quality and tests

#### To run lint and unit tests:

```sh
$ yarn test
```julia
using Pkg
Pkg.add(name="DashDaq", version="0.5.0")
```
## Test

### Testing your components in Dash
You can run unit test for `DashDaq.jl` as:

1. Build development bundle to `lib/` and watch for changes

# Once this is started, you can just leave it running.
$ yarn start
```julia
using Pkg
Pkg.test("DashDaq")
```

2. Install module locally (after every change)
## Issues
Report issues related to `DashDaq.jl` at [https://github.com/plotly/DashDaq.jl/issues](https://github.com/plotly/DashDaq.jl/issues)

# Generate metadata, and build the JavaScript bundle
$ yarn install-local

# Now you're done. For subsequent changes, if you've got `yarn start`
# running in a separate process, it's enough to just do:
$ python setup.py install
## Documentation
Component API documentation can be found at https://dash-julia.plotly.com/dash_daq

3. Run the Dash demo

$ python demo.py
### Basic Example

A switch component that toggles between on and off can be implemented using `DashDaq.jl` as:

## Installing python package locally
```julia
using Dash, DashDaq

Before publishing to PyPi, you can test installing the module locally:
app = dash()

```sh
# Install in `site-packages` on your machine
$ yarn run install-local
app.layout = daq_booleanswitch(
id="my-daq-booleanswitch",
on=true
)
run_server(app, "0.0.0.0", debug=true)
```

## Uninstalling python package locally
## Uninstall `DashDaq.jl`

```sh
$ yarn run uninstall-local
```julia
using Pkg
Pkg.rm("DashDaq")
```


## Producing a new release as a tarball

```sh
vim dash_daq/version.py # and increase it to X.X.X
rm -rf node_modules dist build lib
yarn install
yarn build-tarball
ls dist/dash_daq-X.X.X.tar.gz # this is your tarball
```

## Demo applications
* Dash Daq HP Multimeter - [http://dash-gallery.plotly.host/dash-daq-hp-multimeter](http://dash-gallery.plotly.host/dash-daq-hp-multimeter)
* Dash Daq IV Tracer - [http://dash-gallery.plotly.host/dash-daq-iv-tracer](http://dash-gallery.plotly.host/dash-daq-iv-tracer)
Expand Down
201 changes: 201 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
using Test, DashDaq


@testset "Boolean Switch" begin
bs = daq_booleanswitch(
id="my-daq-booleanswitch",
on=true
)
@test getfield(bs, :name) == "daq_booleanswitch"
@test bs isa DashDaq.DashBase.Component
@test bs.id == "my-daq-booleanswitch"
@test bs.on == true
end
@testset "Color Picker" begin
colp = daq_colorpicker(
id="my-daq-colorpicker",
label="colorPicker"
)
@test getfield(colp, :name) == "daq_colorpicker"
@test colp isa DashDaq.DashBase.Component
@test colp.id == "my-daq-colorpicker"
@test colp.label == "colorPicker"
end
@testset "Gauge" begin
gauge = daq_gauge(
id="my-daq-gauge",
min=0,
max=10,
value=6
)
@test getfield(gauge, :name) == "daq_gauge"
@test gauge isa DashDaq.DashBase.Component
@test gauge.id == "my-daq-gauge"
@test gauge.min == 0
@test gauge.max == 10
@test gauge.value == 6
end
@testset "Graduated Bar" begin
gb = daq_graduatedbar(
id="my-daq-graduatedbar",
value=4
)
@test getfield(gb, :name) == "daq_graduatedbar"
@test gb isa DashDaq.DashBase.Component
@test gb.id == "my-daq-graduatedbar"
@test gb.value == 4
end
@testset "Indicator" begin
ind = daq_indicator(
id="my-daq-indicator",
value=true,
color="#00cc96"
)
@test getfield(ind, :name) == "daq_indicator"
@test ind isa DashDaq.DashBase.Component
@test ind.id == "my-daq-indicator"
@test ind.value == true
@test ind.color == "#00cc96"
end
@testset "Joystick" begin
js = daq_joystick(
id="my-daq-joystick"
)
@test getfield(js, :name) == "daq_joystick"
@test js isa DashDaq.DashBase.Component
@test js.id == "my-daq-joystick"
end
@testset "Knob" begin
knob = daq_knob(
id="my-daq-knob",
min=0,
max=10,
value=8
)
@test getfield(knob, :name) == "daq_knob"
@test knob isa DashDaq.DashBase.Component
@test knob.id == "my-daq-knob"
@test knob.min == 0
@test knob.max == 10
@test knob.value == 8
end
@testset "LEDDisplay" begin
led = daq_leddisplay(
id="my-daq-leddisplay",
value="3.14159"
)
@test getfield(led, :name) == "daq_leddisplay"
@test led isa DashDaq.DashBase.Component
@test led.id == "my-daq-leddisplay"
@test led.value == "3.14159"
end
@testset "Numeric Input" begin
ni = daq_numericinput(
id="my-daq-numericinput",
min=0,
max=10,
value=5
)
@test getfield(ni, :name) == "daq_numericinput"
@test ni isa DashDaq.DashBase.Component
@test ni.id == "my-daq-numericinput"
@test ni.min == 0
@test ni.max == 10
@test ni.value == 5
end
@testset "Power Button" begin
pb = daq_powerbutton(
id="my-daq-powerbutton",
on=true
)
@test getfield(pb, :name) == "daq_powerbutton"
@test pb isa DashDaq.DashBase.Component
@test pb.id == "my-daq-powerbutton"
@test pb.on == true
end
@testset "Precision Input" begin
prei = daq_precisioninput(
id="my-daq-precisioninput",
precision=4,
value=299792458
)
@test getfield(prei, :name) == "daq_precisioninput"
@test prei isa DashDaq.DashBase.Component
@test prei.id == "my-daq-precisioninput"
@test prei.precision == 4
@test prei.value == 299792458
end
@testset "Slider" begin
sli = daq_slider(
id="my-daq-slider",
value=17,
min=0,
max=100,
targets=Dict("25" => Dict("label" => "TARGET"))
)
@test getfield(sli, :name) == "daq_slider"
@test sli isa DashDaq.DashBase.Component
@test sli.id == "my-daq-slider"
@test sli.value == 17
@test sli.min == 0
@test sli.max == 100
@test sli.targets == Dict("25" => Dict("label" => "TARGET"))
end
@testset "Stop" begin
stp = daq_stopbutton(
id="my-daq-stopbutton"
)
@test getfield(stp, :name) == "daq_stopbutton"
@test stp isa DashDaq.DashBase.Component
@test stp.id == "my-daq-stopbutton"
end
@testset "Tank" begin
tank = daq_tank(
id="my-daq-tank",
min=0,
max=10,
value=5
)
@test getfield(tank, :name) == "daq_tank"
@test tank isa DashDaq.DashBase.Component
@test tank.id == "my-daq-tank"
@test tank.min == 0
@test tank.max == 10
@test tank.value == 5
end
@testset "Thermometer" begin
tm = daq_thermometer(
id="my-daq-thermometer",
min=95,
max=105,
value=98.6
)
@test getfield(tm, :name) == "daq_thermometer"
@test tm isa DashDaq.DashBase.Component
@test tm.id == "my-daq-thermometer"
@test tm.min == 95
@test tm.max == 105
@test tm.value == 98.6
end
@testset "Toggle Switch" begin
ts = daq_toggleswitch(
id="my-daq-toggleswitch"
)
@test getfield(ts, :name) == "daq_toggleswitch"
@test ts isa DashDaq.DashBase.Component
@test ts.id == "my-daq-toggleswitch"
end
@testset "Dark Theme Provider" begin
theme = Dict(
"dark" => false,
"detail" => "#007439",
"primary" => "#00EA64",
"secondary" => "#6E6E6E"
)
dtp = daq_darkthemeprovider(
theme=theme, children=daq_knob(value=6)
)
@test getfield(dtp, :name) == "daq_darkthemeprovider"
@test dtp isa DashDaq.DashBase.Component
@test dtp.theme == theme
end