Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinVignal committed Feb 13, 2020
1 parent f84d716 commit 4ba3c60
Show file tree
Hide file tree
Showing 3 changed files with 361 additions and 31 deletions.
31 changes: 0 additions & 31 deletions tests/test.py

This file was deleted.

161 changes: 161 additions & 0 deletions tests/test_add.py
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()
200 changes: 200 additions & 0 deletions tests/test_div.py
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()


0 comments on commit 4ba3c60

Please sign in to comment.