Skip to content

Commit

Permalink
remove codemod id to use wrapper id
Browse files Browse the repository at this point in the history
  • Loading branch information
clavedeluna committed Sep 28, 2023
1 parent fff0792 commit 4baac18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
20 changes: 16 additions & 4 deletions integration_tests/base_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# pylint: disable=no-member
# pylint: disable=no-member, protected-access, attribute-defined-outside-init
import git
import json
import os
import pathlib
import subprocess

from codemodder import __VERSION__
from codemodder import registry


SAMPLES_DIR = "tests/samples"
Expand Down Expand Up @@ -51,22 +52,33 @@ class BaseIntegrationTest(DependencyTestMixin, CleanRepoMixin):
_lines = []
num_changed_files = 1

@classmethod
def setup_class(cls):
cls.codemod_registry = registry.load_registered_codemods()

def setup_method(self):
self.codemod_wrapper = [
cmod
for cmod in self.codemod_registry._codemods
if cmod.codemod == self.codemod
][0]

def _assert_run_fields(self, run, output_path):
assert run["vendor"] == "pixee"
assert run["tool"] == "codemodder-python"
assert run["version"] == __VERSION__
assert run["elapsed"] != ""
assert (
run["commandLine"]
== f"codemodder {SAMPLES_DIR} --output {output_path} --codemod-include={self.codemod.name()}"
== f"codemodder {SAMPLES_DIR} --output {output_path} --codemod-include={self.codemod_wrapper.name}"
)
assert run["directory"] == os.path.abspath(SAMPLES_DIR)
assert run["sarifs"] == []

def _assert_results_fields(self, results, output_path):
assert len(results) == 1
result = results[0]
assert result["codemod"] == self.codemod.id()
assert result["codemod"] == self.codemod_wrapper.id
assert len(result["changeset"]) == self.num_changed_files

# A codemod may change multiple files. For now we will
Expand Down Expand Up @@ -123,7 +135,7 @@ def test_file_rewritten(self):
SAMPLES_DIR,
"--output",
self.output_path,
f"--codemod-include={self.codemod.name()}",
f"--codemod-include={self.codemod_wrapper.name}",
]

self.check_code_before()
Expand Down
5 changes: 0 additions & 5 deletions src/codemodder/codemods/base_codemod.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ def name(cls):
# pylint: disable=no-member
return cls.METADATA.NAME

@classmethod
def id(cls):
# pylint: disable=no-member
return f"pixee:python/{cls.name()}"

@property
def should_transform(self):
return True
Expand Down

0 comments on commit 4baac18

Please sign in to comment.