-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f84d716
commit 4ba3c60
Showing
3 changed files
with
361 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
import unittest | ||
from EpicPath import EpicPath as EP | ||
from pathlib import Path | ||
|
||
|
||
class Add(unittest.TestCase): | ||
""" | ||
Tests the library EpicPath | ||
""" | ||
|
||
# -------------------------------------------------------------------------------- | ||
# __add__(self, other) | ||
# -------------------------------------------------------------------------------- | ||
|
||
def test__add__string(self): | ||
""" | ||
Test the addition | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'cde') | ||
|
||
p_added = p + 'de' | ||
self.assertEqual(p_added, p_truth) | ||
|
||
def test__add__path(self): | ||
""" | ||
test EP + Path | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'cde') | ||
|
||
p_added = p + Path('de') | ||
self.assertEqual(p_added, p_truth) | ||
|
||
def test__add__ep(self): | ||
""" | ||
EP + EP | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'cde') | ||
|
||
p_added = p + EP('de') | ||
self.assertEqual(p_added, p_truth) | ||
|
||
# -------------------------------------------------------------------------------- | ||
# __radd__(self, other) | ||
# -------------------------------------------------------------------------------- | ||
|
||
def test__radd__string(self): | ||
""" | ||
Test the addition | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('yza', 'b', 'c') | ||
|
||
p_added = 'yz' + p | ||
self.assertEqual(p_added, p_truth) | ||
|
||
def test__radd__path(self): | ||
""" | ||
test EP + Path | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('yza', 'b', 'c') | ||
|
||
p_added = Path('yz') + p | ||
self.assertEqual(p_added, p_truth) | ||
|
||
def test__radd__ep(self): | ||
""" | ||
EP + EP | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('yza', 'b', 'c') | ||
|
||
p_added = EP('yz') + p | ||
self.assertEqual(p_added, p_truth) | ||
|
||
# -------------------------------------------------------------------------------- | ||
# __iadd__(self, other) | ||
# -------------------------------------------------------------------------------- | ||
|
||
def test__iadd__string(self): | ||
""" | ||
Test the iaddition | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'cde') | ||
|
||
p += 'de' | ||
self.assertEqual(p, p_truth) | ||
|
||
def test__iadd__path(self): | ||
""" | ||
test EP + Path | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'cde') | ||
|
||
p += Path('de') | ||
self.assertEqual(p, p_truth) | ||
|
||
def test__iadd__ep(self): | ||
""" | ||
EP + EP | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'cde') | ||
|
||
p += EP('de') | ||
self.assertEqual(p, p_truth) | ||
|
||
# -------------------------------------------------------------------------------- | ||
# add(self, other) | ||
# -------------------------------------------------------------------------------- | ||
|
||
def test_add_string(self): | ||
""" | ||
Test the iaddition | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'cde') | ||
|
||
p.add('de') | ||
self.assertEqual(p, p_truth) | ||
|
||
def test_add_path(self): | ||
""" | ||
test EP + Path | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'cde') | ||
|
||
p.add(Path('de')) | ||
self.assertEqual(p, p_truth) | ||
|
||
def test_add_ep(self): | ||
""" | ||
EP + EP | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'cde') | ||
|
||
p.add(EP('de')) | ||
self.assertEqual(p, p_truth) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
import unittest | ||
from EpicPath import EpicPath as EP | ||
from pathlib import Path | ||
|
||
|
||
class Div(unittest.TestCase): | ||
""" | ||
Tests the library EpicPath | ||
""" | ||
|
||
# -------------------------------------------------------------------------------- | ||
# __truediv__(self, other) | ||
# -------------------------------------------------------------------------------- | ||
|
||
def test__truediv__string(self): | ||
""" | ||
Test the truedivition | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'de') | ||
|
||
p_truedived = p / 'de' | ||
self.assertEqual(p_truedived, p_truth) | ||
|
||
def test__truediv__path(self): | ||
""" | ||
test EP / Path | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'd', 'e') | ||
|
||
p_truedived = p / Path('d', 'e') | ||
self.assertEqual(p_truedived, p_truth) | ||
|
||
def test__truediv__ep(self): | ||
""" | ||
EP / EP | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'd', 'e') | ||
|
||
p_truedived = p / EP('d', 'e') | ||
self.assertEqual(p_truedived, p_truth) | ||
|
||
# -------------------------------------------------------------------------------- | ||
# __rtruediv__(self, other) | ||
# -------------------------------------------------------------------------------- | ||
|
||
def test__rtruediv__string(self): | ||
""" | ||
Test the truedivition | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('yz', 'a', 'b', 'c') | ||
|
||
p_truedived = 'yz' / p | ||
self.assertEqual(p_truedived, p_truth) | ||
|
||
def test__rtruediv__path(self): | ||
""" | ||
test EP / Path | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('y', 'z', 'a', 'b', 'c') | ||
|
||
p_truedived = Path('y', 'z') // p | ||
self.assertEqual(p_truedived, p_truth) | ||
|
||
def test__rtruediv__ep(self): | ||
""" | ||
EP / EP | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('y', 'z', 'a', 'b', 'c') | ||
|
||
p_truedived = EP('y', 'z') / p | ||
self.assertEqual(p_truedived, p_truth) | ||
|
||
# -------------------------------------------------------------------------------- | ||
# __itruediv__(self, other) | ||
# -------------------------------------------------------------------------------- | ||
|
||
def test__itruediv__string(self): | ||
""" | ||
Test the itruedivition | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'de') | ||
|
||
p /= 'de' | ||
self.assertEqual(p, p_truth) | ||
|
||
def test__itruediv__path(self): | ||
""" | ||
test EP / Path | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'd', 'e') | ||
|
||
p /= Path('d', 'e') | ||
self.assertEqual(p, p_truth) | ||
|
||
def test__itruediv__ep(self): | ||
""" | ||
EP / EP | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'd', 'e') | ||
|
||
p /= EP('d', 'e') | ||
self.assertEqual(p, p_truth) | ||
|
||
# -------------------------------------------------------------------------------- | ||
# append(self, other) | ||
# -------------------------------------------------------------------------------- | ||
|
||
def test_append_string(self): | ||
""" | ||
Test the itruedivition | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'de') | ||
|
||
p.append('de') | ||
self.assertEqual(p, p_truth) | ||
|
||
def test_append_path(self): | ||
""" | ||
test EP / Path | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'd', 'e') | ||
|
||
p.append(Path('d', 'e')) | ||
self.assertEqual(p, p_truth) | ||
|
||
def test_append_ep(self): | ||
""" | ||
EP / EP | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'd', 'e') | ||
|
||
p.append(EP('d', 'e')) | ||
self.assertEqual(p, p_truth) | ||
|
||
# -------------------------------------------------------------------------------- | ||
# extend(self, other) | ||
# -------------------------------------------------------------------------------- | ||
|
||
def test_extend_string(self): | ||
""" | ||
Test the itruedivition | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'd', 'e') | ||
|
||
p.extend(['d', 'e']) | ||
self.assertEqual(p, p_truth) | ||
|
||
def test_extend_path(self): | ||
""" | ||
test EP / Path | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'd', 'e', 'f', 'g') | ||
|
||
p.extend(Path('d', 'e'), Path('f', 'g')) | ||
self.assertEqual(p, p_truth) | ||
|
||
def test_extend_ep(self): | ||
""" | ||
EP / EP | ||
:return: | ||
""" | ||
p = EP('a', 'b', 'c') | ||
p_truth = EP('a', 'b', 'c', 'd', 'e', 'f', 'g') | ||
|
||
p.extend([EP('d', 'e'), EP('f')], EP('g')) | ||
self.assertEqual(p, p_truth) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
||
|