summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-01-01 02:26:12 +0200
committerLars Wirzenius <liw@liw.fi>2010-01-01 02:26:12 +0200
commitb465d8874012e8d7e075e6f8801f245415630d71 (patch)
tree0e491fa4c52850e3f3cdef3ac23bab99315b6be3
parent01c25cc823a459196524cd7202c7c3c567ccddd8 (diff)
downloadsummain-b465d8874012e8d7e075e6f8801f245415630d71.tar.gz
Wrote stub of first class, and first tests for it. Tests do not yet pass.
-rw-r--r--summainlib.py30
-rw-r--r--summainlib_tests.py31
2 files changed, 61 insertions, 0 deletions
diff --git a/summainlib.py b/summainlib.py
new file mode 100644
index 0000000..241f6e9
--- /dev/null
+++ b/summainlib.py
@@ -0,0 +1,30 @@
+# Copyright (C) 2019 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/>.
+
+
+class FilesystemObject(object):
+
+ '''An object in the file system.
+
+ Responsible for gathering information and formatting it for
+ reporting.
+
+ '''
+
+ def __init__(self, filename):
+ self.values = dict()
+
+ def __getitem__(self, key):
+ return self.values.get(key, '')
diff --git a/summainlib_tests.py b/summainlib_tests.py
new file mode 100644
index 0000000..15d843d
--- /dev/null
+++ b/summainlib_tests.py
@@ -0,0 +1,31 @@
+# Copyright (C) 2019 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/>.
+
+
+import unittest
+
+import summainlib
+
+
+class FilesystemObjectTests(unittest.TestCase):
+
+ def new(self, name):
+ return summainlib.FilesystemObject(name)
+
+ def test_formats_simple_name_identically(self):
+ self.assertEqual(self.new('foo')['Name'], 'foo')
+
+ def test_formats_space_correctly(self):
+ self.assertEqual(self.new('foo bar')['Name'], 'foo%20bar')