summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-07-01 16:14:41 +0300
committerLars Wirzenius <liw@liw.fi>2017-07-01 23:43:09 +0300
commitf24893c1833e4fcb6aedc9dd5945223d756a31d2 (patch)
tree1c65be14cad7095aa62a5b93d26ac6c146624715
parentf70d6c0442f8f2f01a8195f439fddc6c0831a905 (diff)
downloadick2-f24893c1833e4fcb6aedc9dd5945223d756a31d2.tar.gz
Add: ick2lib.Project class to hold data about a project
-rwxr-xr-xcheck2
-rw-r--r--ick2lib/__init__.py19
-rw-r--r--ick2lib/project.py50
-rw-r--r--ick2lib/project_tests.py66
-rw-r--r--without-tests3
5 files changed, 140 insertions, 0 deletions
diff --git a/check b/check
index f4c6167..f8992f4 100755
--- a/check
+++ b/check
@@ -2,6 +2,8 @@
set -eu
+python -m CoverageTestRunner --ignore-missing-from=without-tests ick2lib
+
yarn yarns/*.yarn \
--shell python2 \
--shell-arg '' \
diff --git a/ick2lib/__init__.py b/ick2lib/__init__.py
index 03a5053..1426276 100644
--- a/ick2lib/__init__.py
+++ b/ick2lib/__init__.py
@@ -1 +1,20 @@
+# Copyright 2017 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
from .version import __version__, __version_info__
+from .project import Project
diff --git a/ick2lib/project.py b/ick2lib/project.py
new file mode 100644
index 0000000..edea34d
--- /dev/null
+++ b/ick2lib/project.py
@@ -0,0 +1,50 @@
+# Copyright 2017 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+class Project(object):
+
+ def __init__(self, name):
+ self.name = name
+ self.current_log = ''
+ self.previous_log = ''
+ self.build_steps = []
+
+ def get_current_log(self):
+ return self.current_log
+
+ def get_previous_log(self):
+ return self.previous_log
+
+ def append_to_current_log(self, text):
+ self.current_log += text
+
+ def finish_current_log(self):
+ self.previous_log = self.current_log
+ self.current_log = ''
+
+ def get_build_steps(self):
+ return self.build_steps
+
+ def add_build_step(self, shell_text):
+ self.build_steps.append(shell_text)
+
+ def get_current_build_step(self):
+ return self.build_steps[0]
+
+ def finish_current_build_step(self):
+ self.build_steps.pop(0)
diff --git a/ick2lib/project_tests.py b/ick2lib/project_tests.py
new file mode 100644
index 0000000..71f615b
--- /dev/null
+++ b/ick2lib/project_tests.py
@@ -0,0 +1,66 @@
+# Copyright 2017 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+import unittest
+
+import ick2lib
+
+
+class ProjectTests(unittest.TestCase):
+
+ def test_has_name(self):
+ p = ick2lib.Project('foo')
+ self.assertEqual(p.name, 'foo')
+
+ def test_has_current_log_initially_empty(self):
+ p = ick2lib.Project('foo')
+ self.assertEqual(p.get_current_log(), '')
+
+ def test_appends_to_current_log(self):
+ p = ick2lib.Project('foo')
+ p.append_to_current_log('output')
+ self.assertEqual(p.get_current_log(), 'output')
+
+ def test_finished_current_log(self):
+ p = ick2lib.Project('foo')
+ p.append_to_current_log('output')
+ p.finish_current_log()
+ self.assertEqual(p.get_current_log(), '')
+ self.assertEqual(p.get_previous_log(), 'output')
+
+ def test_has_previous_log_initially_empty(self):
+ p = ick2lib.Project('foo')
+ self.assertEqual(p.get_previous_log(), '')
+
+ def test_has_no_build_steps_initially(self):
+ p = ick2lib.Project('foo')
+ self.assertEqual(p.get_build_steps(), [])
+
+ def test_adds_build_steps(self):
+ p = ick2lib.Project('foo')
+ p.add_build_step('echo')
+ self.assertEqual(p.get_build_steps(), ['echo'])
+
+ def test_tracks_current_build_step(self):
+ p = ick2lib.Project('foo')
+ p.add_build_step('step1')
+ p.add_build_step('step2')
+ self.assertEqual(p.get_current_build_step(), 'step1')
+ self.assertEqual(p.get_current_build_step(), 'step1')
+ p.finish_current_build_step()
+ self.assertEqual(p.get_current_build_step(), 'step2')
diff --git a/without-tests b/without-tests
new file mode 100644
index 0000000..7afaae3
--- /dev/null
+++ b/without-tests
@@ -0,0 +1,3 @@
+ick2lib/__init__.py
+ick2lib/version.py
+