Repository: h1alexbel/samples-filter

Issue:
input.py:36-39: Prepare files in /pipeline directory. We...
The puzzle `19-a9982129` from #19 has to be resolved: 

https://github.com/h1alexbel/samples-filter/blob/10d01f5605ec49ca3d7986a779a2524a16df3575/objects/input.py#L36-L39

The puzzle was created by @rultor on 17-Apr-24. 

Estimate: 25 minutes,  role: DEV. 

If you have any technical questions, don't ask me, submit new tickets instead. The task will be \"done\" when the problem is fixed and the text of the puzzle is _removed_ from the source code. Here is more about [PDD](http://www.yegor256.com/2009/03/04/pdd.html) and [about me](http://www.yegor256.com/2017/04/05/pdd-in-action.html). 


Discussion:

Patch:
diff --git a/.rultor.yml b/.rultor.yml
index 3098633..342bfaf 100644
--- a/.rultor.yml
+++ b/.rultor.yml
@@ -24,6 +24,9 @@ architect:
   - h1alexbel
 assets:
   pypi.txt: h1alexbel/home#assets/pypi.txt
+install: |
+  python3 -m pip install --upgrade pip
+  pip install twine
 merge:
   script: |
     make install test check
@@ -31,12 +34,7 @@ release:
   sensitive:
     - pypi.txt
   script: |
-    [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9_]+)?$ ]] || exit -1
-    sed -i "s/0\.0\.0/${tag}/g" version.txt
-    git commit -am "${tag}"
-    export TWINE_USERNAME=h1alexbel
-    export TWINE_PASSWORD=$(cat ../pypi.txt)
-    make install release
+    make release
 deploy:
   script: |
     echo "There is no such thing as #deploy"
diff --git a/Makefile b/Makefile
index ee30bc9..2888d51 100644
--- a/Makefile
+++ b/Makefile
@@ -39,13 +39,18 @@ install:
 test:
 	export PYTHONPATH=.
 	pip install .
-	python3 -m pytest tests
+	pytest tests
 
 # Check the quality of code.
 check:
-	python3 -m pylint '*.py'
+	pylint '*.py'
 
 # Release package to PyPI.
 release:
+	[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9_]+)?$ ]] || exit -1
+	sed -i "s/0\.0\.0/${tag}/g" version.txt
+	git commit -am "${tag}"
+	export TWINE_USERNAME=h1alexbel
+	export TWINE_PASSWORD=$(cat ../pypi.txt)
 	python3 setup.py sdist bdist_wheel
 	python3 -m twine upload dist/*
diff --git a/objects/input.py b/objects/input.py
index 41d36f8..2040d95 100644
--- a/objects/input.py
+++ b/objects/input.py
@@ -33,10 +33,6 @@ class Input:
         self.name = name
 
     def copy(self):
-        # @todo #19:25min Prepare files in /pipeline directory.
-        #  We should create them before running actual processing.
-        #  For now we need to manually create files.
-        #  Don't forget to remove this puzzle.
         with open(self.name, "r") as input, open(self.DESTINATION, "w", newline="") as pipe:
             reader = csv.DictReader(input)
             writer = csv.DictWriter(
diff --git a/objects/pre_filter.py b/objects/pre_filter.py
index 4d6ef47..3bfa258 100644
--- a/objects/pre_filter.py
+++ b/objects/pre_filter.py
@@ -23,10 +23,15 @@
 """
 Prepares outputs before running filters.
 """
+import os.path
+
+
 class PreFilter:
     def __init__(self, out):
         self.out = out
 
     def prepare(self):
+        if not os.path.exists("pipeline"):
+            os.makedirs("pipeline")
         with open(self.out, "w") as file:
             file.write("")


Test patch:
diff --git a/tests/test_pre_filter.py b/tests/test_pre_filter.py
new file mode 100644
index 0000000..864d4ee
--- /dev/null
+++ b/tests/test_pre_filter.py
@@ -0,0 +1,42 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2024 Aliaksei Bialiauski
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""
+Test case for PreFilter.
+"""
+import os
+import unittest
+from objects.pre_filter import PreFilter
+
+
+class TestPreFilter(unittest.TestCase):
+    def setUp(self):
+        self.out = "test_output.csv"
+        self.pre = PreFilter(self.out)
+
+    def tearDown(self):
+        os.rmdir("pipeline")
+        os.remove(self.out)
+
+    def test_creates_pipeline_dir(self):
+        self.pre.prepare()
+        self.assertTrue(os.path.exists("pipeline"))