From 16368ea954f33d7734412bf813b6ddda3f67dfb5 Mon Sep 17 00:00:00 2001
From: moritz <email@moritz-huebner.de>
Date: Tue, 27 Mar 2018 15:43:44 +1100
Subject: [PATCH] Moritz Huebner: Added some tests for source.py

---
 .gitignore                  |   3 +-
 peyote/tests/source_test.py | 115 ++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+), 1 deletion(-)
 create mode 100644 peyote/tests/source_test.py

diff --git a/.gitignore b/.gitignore
index 0082314a7..c3c772a68 100644
--- a/.gitignore
+++ b/.gitignore
@@ -105,4 +105,5 @@ venv.bak/
 
 # Idea
 /.idea
-*.idea
\ No newline at end of file
+*.idea
+*.idea*
\ No newline at end of file
diff --git a/peyote/tests/source_test.py b/peyote/tests/source_test.py
new file mode 100644
index 000000000..907e5dfea
--- /dev/null
+++ b/peyote/tests/source_test.py
@@ -0,0 +1,115 @@
+import unittest
+from source import *
+
+
+class TestSourceInstantiation(unittest.TestCase):
+    def setUp(self):
+        self.source = Source("test_name")
+
+    def tearDown(self):
+        del self.source
+
+    def test_name(self):
+        self.assertEqual(self.source.name, "test_name")
+
+
+class TestGlitchInstantiation(unittest.TestCase):
+
+    def setUp(self):
+        self.source = Glitch("test_name")
+
+    def tearDown(self):
+        del self.source
+
+    def test_name(self):
+        self.assertEqual(self.source.name, "test_name")
+
+
+class TestAstrophysicalInstantiation(unittest.TestCase):
+
+    def setUp(self):
+        name = "test_name"
+        right_ascension, declination, luminosity_distance = 1, 2, 3
+        self.source = AstrophysicalSource(name, right_ascension, declination, luminosity_distance)
+
+    def tearDown(self):
+        del self.source
+
+    def test_name(self):
+        self.assertEqual(self.source.name, "test_name")
+
+    def test_right_ascension(self):
+        self.assertEqual(self.source.right_ascension, 1)
+
+    def test_declination(self):
+        self.assertEqual(self.source.declination, 2)
+
+    def test_luminosity_distance(self):
+        self.assertEqual(self.source.luminosity_distance, 3)
+
+
+class TestCompactBinaryCoalescence(unittest.TestCase):
+
+    def setUp(self):
+        name = "test_name"
+        right_ascension = 1
+        declination = 2
+        luminosity_distance = 3
+        mass_1 = 4
+        mass_2 = 5
+        spin_1 = [6, 7, 8]
+        spin_2 = [9, 10, 11]
+        coalescence_time = 12
+        inclination_angle = 13
+        waveform_phase = 14
+        polarisation_angle = 15
+        eccentricity = 16
+        self.source = CompactBinaryCoalescence(name, right_ascension, declination, luminosity_distance, mass_1, mass_2,
+                                               spin_1, spin_2, coalescence_time, inclination_angle, waveform_phase,
+                                               polarisation_angle, eccentricity)
+
+    def tearDown(self):
+        del self.source
+
+    def test_name(self):
+        self.assertEqual(self.source.name, "test_name")
+
+    def test_right_ascension(self):
+        self.assertEqual(self.source.right_ascension, 1)
+
+    def test_declination(self):
+        self.assertEqual(self.source.declination, 2)
+
+    def test_luminosity_distance(self):
+        self.assertEqual(self.source.luminosity_distance, 3)
+
+    def test_mass_1(self):
+        self.assertEqual(self.source.mass_1, 4)
+
+    def test_mass_2(self):
+        self.assertEqual(self.source.mass_2, 5)
+
+    def test_spin_1(self):
+        self.assertEqual(self.source.spin_1, [6, 7, 8])
+
+    def test_spin_2(self):
+        self.assertEqual(self.source.spin_2, [9, 10, 11])
+
+    def test_coalescence_time(self):
+        self.assertEqual(self.source.coalescence_time, 12)
+
+    def test_inclination_angle(self):
+        self.assertEqual(self.source.inclination_angle, 13)
+
+    def test_waveform_phase(self):
+        self.assertEqual(self.source.waveform_phase, 14)
+
+    def test_polarisation_angle(self):
+        self.assertEqual(self.source.polarisation_angle, 15)
+
+    def test_eccentricity(self):
+        self.assertEqual(self.source.eccentricity, 16)
+
+
+if __name__ == '__main__':
+    unittest.main()
-- 
GitLab