-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from davidomarf/new
Implement `ginpar new` to create new sketches with boilerplate code
- Loading branch information
Showing
4 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- var: DIMENSIONS | ||
attrs: | ||
type: dimensions | ||
value: | ||
- 2048 | ||
- 2048 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* You don't need to initialize your variables in here. However, if you decide | ||
* to do it, you **must** use `var` instead of `let` or `const`. | ||
*/ | ||
|
||
var DIMENSIONS = [400, 2048] | ||
|
||
/** | ||
* Standard function of p5js | ||
*/ | ||
function setup() { | ||
createCanvas(DIMENSIONS[0], DIMENSIONS[1]).parent("artwork-container"); | ||
|
||
// Call draw() only once | ||
noLoop(); | ||
} | ||
|
||
/** | ||
* Standard function of p5js | ||
*/ | ||
function draw() { | ||
// Set a background color | ||
background(225); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,41 @@ | ||
import os | ||
|
||
from click.testing import CliRunner | ||
from ginpar import cli | ||
|
||
def test_new(): | ||
runner = CliRunner() | ||
result = runner.invoke(cli, ["new", 'hey']) | ||
assert result.exit_code == 0 | ||
assert "You're in new" in result.output | ||
"""New works properly on the default scenario. | ||
Default scenario is when the directory of the new sketch doesn't | ||
exist in the source_path.. | ||
""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
## Initialize a new project and cd it | ||
runner.invoke(cli, ["init", "-q"]) | ||
os.chdir("my-site") | ||
|
||
result = runner.invoke(cli, ["new", "test"]) | ||
|
||
data_path = os.path.join("sketches", "test", "data.yaml") | ||
sketch_path = os.path.join("sketches", "test", "sketch.js") | ||
assert result.exit_code == 0 | ||
assert os.path.isfile(data_path) | ||
assert os.path.isfile(sketch_path) | ||
|
||
|
||
def test_new_existent(): | ||
"""New works properly when the sketch already exists | ||
""" | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
## Initialize a new project and cd it | ||
runner.invoke(cli, ["init", "-q"]) | ||
os.chdir("my-site") | ||
|
||
## Create test | ||
runner.invoke(cli, ["new", "test"]) | ||
|
||
result = runner.invoke(cli, ["new", "test"]) | ||
assert result.exit_code == 1 | ||
|