Skip to content

Commit

Permalink
update template to use new_rocker_extension as the placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
blooop committed Sep 18, 2024
1 parent c3f7fc7 commit 7f9974c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ build-backend = "hatchling.build"
include= ["template_rocker"]

[project.entry-points."rocker.extensions"]
pixi = "template_rocker.pixi:PixiExtension"
rocker_extension = "template_rocker.rocker_extension:NewRockerExtension"

# Environments
[tool.pixi.environments]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from rocker.extensions import RockerExtension


class PixiExtension(RockerExtension):
class NewRockerExtension(RockerExtension):
@staticmethod
def get_name():
return "pixi"

def __init__(self):
self.name = PixiExtension.get_name()
self.name = NewRockerExtension.get_name()

def get_snippet(self, cliargs):
return pkgutil.get_data("template_rocker", "templates/curl_snippet.Dockerfile").decode(
Expand All @@ -26,7 +26,7 @@ def register_arguments(parser, defaults=None):
if defaults is None:
defaults = {}
parser.add_argument(
f"--{PixiExtension.get_name()}",
f"--{NewRockerExtension.get_name()}",
action="store_true",
default=defaults.get("pixi"),
help="add pixi dependency manager to your environment",
Expand Down
14 changes: 7 additions & 7 deletions test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@
import argparse
import pytest
from unittest.mock import patch
from template_rocker.pixi import PixiExtension
from template_rocker.new_rocker_extension import NewRockerExtension


class TestPixiExtension:

# Instantiating PixiExtension and verifying the name attribute is set correctly
def test_name_attribute_initialization(self):
extension = PixiExtension()
assert extension.name == "pixi"
extension = NewRockerExtension()
assert extension.name == "new_rocker_extension"

def test_register_arguments(self):
parser = argparse.ArgumentParser()
PixiExtension.register_arguments(parser)
NewRockerExtension.register_arguments(parser)
args = parser.parse_args([])
assert "pixi" in vars(args)

# Handling missing template files in get_snippet method
def test_get_snippet_missing_template(self):

extension = PixiExtension()
extension = NewRockerExtension()
with patch("pkgutil.get_data", return_value=None):
with pytest.raises(AttributeError):
extension.get_snippet({})

# Retrieving the default snippet using get_snippet method
def test_retrieve_default_snippet(self):

extension = PixiExtension()
extension = NewRockerExtension()
snippet = extension.get_snippet(None)

assert snippet is not None

# Retrieving the user-specific snippet using get_user_snippet method
def test_retrieve_user_specific_snippet(self):

extension = PixiExtension()
extension = NewRockerExtension()
snippet = extension.get_user_snippet(None)

assert snippet is not None

0 comments on commit 7f9974c

Please sign in to comment.