Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ On success, `ntk init` logs the new theme ID and name, and persists the theme ID
To sync files between your local directory and the store, use `ntk push` to upload and `ntk pull` to download. Both upload or download the whole theme by default, and both accept file paths as positional arguments to limit the operation to specific files.

> [!NOTE]
> File paths are relative to the theme root. `ntk push` only uploads files inside the theme directories (`assets`, `checkout`, `configs`, `layouts`, `locales`, `partials`, `sass`, `templates`) with valid theme file extensions — a path outside of them is skipped silently, not reported as an error.
> File paths are relative to the theme root. `ntk push` only uploads files inside the theme directories (`assets`, `configs`, `layouts`, `locales`, `partials`, `sass`, `templates`) with valid theme file extensions — a path outside of them is skipped silently, not reported as an error. `ntk pull` still downloads the `checkout` directory, but `ntk push` skips it: the store does not accept uploads to it.

| Example | Command |
| ------- | ------- |
Expand Down
1 change: 0 additions & 1 deletion ntk/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"assets/**/*.webm",
"assets/**/*.mp3",
"assets/**/*.pdf",
"checkout/**/*.html",
"configs/**/*.json",
"layouts/**/*.html",
"partials/**/*.html",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

__version__ = '1.2.0'
__version__ = '1.3.0'

tests_require = [
"flake8",
Expand Down
16 changes: 16 additions & 0 deletions tests/test_command.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import tempfile
import unittest
from unittest.mock import call, MagicMock, mock_open, patch

Expand Down Expand Up @@ -410,6 +411,21 @@ def test_get_accept_files_filters_invalid_extensions_from_provided_filenames(
])
self.assertEqual(result, [valid_file])

def test_get_accept_files_skips_checkout_directory(self):
"""The store API rejects uploads to checkout/ (#37), so push never selects it."""
cwd = os.getcwd()
with tempfile.TemporaryDirectory() as theme_dir:
os.chdir(theme_dir)
try:
os.makedirs('checkout')
os.makedirs('templates')
open('checkout/checkout.html', 'w').close()
open('templates/index.html', 'w').close()
self.assertEqual(self.command._get_accept_files([]), [os.path.abspath('templates/index.html')])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: _get_accept_files runs an unmocked glob.glob over the real filesystem. The assertion _get_accept_files([]) == [abspath('templates/index.html')] only holds because the surrounding TemporaryDirectory is empty besides checkout/ and templates/.

If anyone ever adds another file under e.g. assets/, configs/, layouts/, partials/, locales/, or sass/ inside the tempdir, or runs this test in a non-empty CWD without the os.chdir (e.g. due to a setUp change), the test will fail with a confusing diff. More importantly, the test does not actually demonstrate that checkout/ is the only thing being filtered — it would also pass if GLOB_PATTERN excluded templates/. Recommend patching ntk.command.glob.glob (as done in nearby tests) and asserting checkout/checkout.html is excluded explicitly.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

self.assertEqual(self.command._get_accept_files(['checkout/checkout.html']), [])
finally:
os.chdir(cwd)

@patch("ntk.command.Command._get_accept_files", autospec=True)
def test_push_command_with_filenames_should_upload_only_specified_files(
self, mock_get_accept_files
Expand Down
Loading