Exemplo n.º 1
0
    def test_us16(self):
        '''
        All male members of a family should have the same last name
        '''

        file = open('user_story_geds/us16.ged')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_16(indi, fam), False)

        file = open('user_story_geds/us11.ged')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_16(indi, fam), True)

        file = open('user_story_geds/us22.ged')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_16(indi, fam), True)

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_16(indi, fam), True)

        file = open('user_story_geds/us39.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_16(indi, fam), True)
Exemplo n.º 2
0
    def test_us13(self):
        '''
        Birth dates of siblings should be more than 8 months apart or less than 2 days apart
        '''

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_13(indi, fam), True)

        file = open('user_story_geds/us11.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_13(indi, fam), True)

        file = open('user_story_geds/us22.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_13(indi, fam), True)

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_13(indi, fam), True)

        file = open('user_story_geds/us07.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_13(indi, fam), True)
Exemplo n.º 3
0
    def test_us14(self):
        file = open('user_story_geds/us14.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertFalse(user_story_14(indi, fam))

        file = open('user_story_geds/us39.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_14(indi, fam), None)

        file = open('user_story_geds/us01.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_14(indi, fam), None)

        file = open('user_story_geds/us22.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_14(indi, fam), None)

        file = open('user_story_geds/us02.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_14(indi, fam), None)
Exemplo n.º 4
0
    def test_us23(self):
        """
        No more than one individual with the same name and birth date should appear in a GEDCOM file
        """

        file = open('user_story_geds/us23.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertFalse(user_story_23(indi))

        file = open('user_story_geds/us07.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_23(indi))

        file = open('user_story_geds/us11.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_23(indi))

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_23(indi))

        file = open('user_story_geds/us01.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_23(indi))
Exemplo n.º 5
0
    def test_us12(self):
        '''
        Mother should be less than 60 years older than her children and father should be less than 80 years older than his children
        '''

        file = open('user_story_geds/us39.ged')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_12(indi, fam), True)

        file = open('user_story_geds/us11.ged')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_12(indi, fam), True)

        file = open('user_story_geds/us22.ged')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_12(indi, fam), True)

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_12(indi, fam), True)

        file = open('user_story_geds/bigged.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_12(indi, fam), True)
Exemplo n.º 6
0
    def test_us25(self):
        """
        No more than one child with the same name and birth date should appear in a family
        """

        file = open('user_story_geds/us23.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_25(indi, fam))

        file = open('user_story_geds/us07.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_25(indi, fam))

        file = open('user_story_geds/us11.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_25(indi, fam))

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_25(indi, fam))

        file = open('user_story_geds/us34.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_25(indi, fam))
Exemplo n.º 7
0
def create_db_if_not_exist():
    if not path.exists(DATABASE):
        conn = sqlite3.connect(DATABASE)
        cursor = conn.cursor()
        create_tables(cursor)
        conn.commit()
        cursor.close()
        conn.close()
Exemplo n.º 8
0
    def test_us39(self):
        """
        List all families with anniversaries in the next 30 days
        """
        file = open('user_story_geds/us39.ged')
        indi, fam = create_tables(file)
        file.close()

        result = user_story_39(indi, fam)
        self.assertIn("@US39_F1@", result)
        self.assertNotIn("@US38_F2@", result)
        self.assertNotIn("@US38_F3@", result)

        file = open('user_story_geds/us13.ged')
        indi, fam = create_tables(file)
        file.close()

        result = user_story_39(indi, fam)
        self.assertIn("@US13_F2@", result)
        self.assertNotIn("@US13_F1@", result)
Exemplo n.º 9
0
    def test_us18(self):
        """
        Siblings should not marry
        """

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_18(indi, "@I01@", "@I06@"), False)
        self.assertEqual(user_story_18(indi, "@I03@", "@I07@"), False)
        self.assertEqual(user_story_18(indi, "@I02@", "@I12@"), False)
        self.assertEqual(user_story_18(indi, "@I02@", "@I03@"), True)
        self.assertEqual(user_story_18(indi, "@I08@", "@I09@"), True)
Exemplo n.º 10
0
    def test_us10(self):
        '''
        Marriage should be at least 14 years after birth of both spouses (parents must be at least 14 years old)
        '''

        file = open('user_story_geds/us10.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_10(indi, "@US10_F01@", fam), True)
        self.assertEqual(user_story_10(indi, "@US10_F02@", fam), False)
        self.assertEqual(user_story_10(indi, "@US10_F03@", fam), False)
        self.assertEqual(user_story_10(indi, "@US10_F04@", fam), True)
        self.assertEqual(user_story_10(indi, "@US10_F05@", fam), True)
Exemplo n.º 11
0
    def test_us4(self):
        """
        Divorce date should not be before marriage date
        """

        file = open('user_story_geds/us4.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_4(fam, "@US04_F1@"), False)
        self.assertEqual(user_story_4(fam, "@US04_F2@"), True)
        self.assertEqual(user_story_4(fam, "@US04_F3@"), True)
        self.assertEqual(user_story_4(fam, "@US04_F4@"), False)
        self.assertEqual(user_story_4(fam, "@US04_F5@"), True)
Exemplo n.º 12
0
    def test_us21_b(self):
        """
        Correct gender for wife
        """

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_21_b(indi, "@I02@", "David"), False)
        self.assertEqual(user_story_21_b(indi, "@I01@", "Nicole"), True)
        self.assertEqual(user_story_21_b(indi, "@I04@", "Kevin"), False)
        self.assertEqual(user_story_21_b(indi, "@I03@", "Ann"), True)
        self.assertEqual(user_story_21_b(indi, "@I07@", "Michayla"), True)
Exemplo n.º 13
0
    def test_us21_a(self):
        """
        Correct gender for husband
        """

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_21_a(indi, "@I02@", "John"), True)
        self.assertEqual(user_story_21_a(indi, "@I01@", "Jane"), False)
        self.assertEqual(user_story_21_a(indi, "@I04@", "Simon"), True)
        self.assertEqual(user_story_21_a(indi, "@I03@", "Caroline"), False)
        self.assertEqual(user_story_21_a(indi, "@I07@", "David"), False)
Exemplo n.º 14
0
    def test_us38(self):
        """
        List all living people with birthdays in the next 30 days
        """
        file = open('user_story_geds/us38.ged')
        indi, fam = create_tables(file)
        file.close()

        result = user_story_38(indi)
        self.assertIn("@US38_I1@", result)
        self.assertIn("@US38_I3@", result)
        self.assertIn("@US38_I4@", result)
        self.assertNotIn("@US38_I2@", result)
        self.assertNotIn("@US38_I5@", result)
Exemplo n.º 15
0
    def test_us22(self):
        """
        No duplicate id tags in file
        """

        file = open('user_story_geds/us22.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertTrue(user_story_22(indi, "TAG1"))
        self.assertTrue(user_story_22(indi, "TAG2"))
        self.assertTrue(user_story_22(indi, "TAG3"))
        self.assertFalse(user_story_22(indi, "@US22_I1@"))
        self.assertFalse(user_story_22(indi, "@US22_I2@"))
Exemplo n.º 16
0
    def test_us36(self):
        """
        List all people born in the past 30 days
        """
        file = open('user_story_geds/us36.ged')
        indi, fam = create_tables(file)
        file.close()

        result = user_story_36(indi)
        self.assertIn("@US36_I2@", result)
        self.assertIn("@US36_I6@", result)
        self.assertNotIn("@US36_I3", result)
        self.assertNotIn("@US36_I5@", result)
        self.assertNotIn("@US36_I20@", result)
Exemplo n.º 17
0
    def test_us3(self):
        """
        A person's birthday must be before death date
        """

        file = open('user_story_geds/us3.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_3(indi, "@US03_I1@"), False)
        self.assertEqual(user_story_3(indi, "@US03_I2@"), True)
        self.assertEqual(user_story_3(indi, "@US03_I3@"), True)
        self.assertEqual(user_story_3(indi, "@US03_I4@"), False)
        self.assertEqual(user_story_3(indi, "@US03_I5@"), False)
Exemplo n.º 18
0
    def test_us30(self):
        '''
        List all living married people in a GEDCOM file
        '''
        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        result = user_story_30(indi, fam)

        self.assertIn("@I04@", result)
        self.assertIn("@I05@", result)
        self.assertIn("@I09@", result)
        self.assertIn("@I10@", result)
        self.assertNotIn("@I08@", result)
Exemplo n.º 19
0
    def test_us29(self):
        """
        List deceased
        """
        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        result = user_story_29(indi)

        self.assertIn("@I01@", result)
        self.assertIn("@I08@", result)
        self.assertNotIn("@I10@", result)
        self.assertNotIn("@I09@", result)
        self.assertNotIn("@I05@", result)
Exemplo n.º 20
0
    def test_us42(self):
        """
        Reject illegitimate dates
        """

        file = open('user_story_geds/us39.ged')
        indi, fam = create_tables(file)
        file.close()

        file = open('user_story_geds/us42.ged')
        indi, fam = create_tables(file)
        file.close()

        file = open('user_story_geds/us3.ged')
        indi, fam = create_tables(file)
        file.close()

        file = open('user_story_geds/us01.ged')
        indi, fam = create_tables(file)
        file.close()

        file = open('user_story_geds/us02.ged')
        indi, fam = create_tables(file)
        file.close()
Exemplo n.º 21
0
    def test_us33(self):
        """
        A child with deceased parents must be less than 18 years old to be considered an orphan
        """

        file = open('user_story_geds/us33.ged')
        indi, fam = create_tables(file)
        file.close()

        result = user_story_33(indi, fam)

        self.assertIn("@US33_I01@", result)
        self.assertNotIn("@US33_I21@", result)
        self.assertNotIn("@US33_I16@", result)
        self.assertNotIn("@US33_I08@", result)
        self.assertNotIn("@US33_I11@", result)
Exemplo n.º 22
0
    def test_us34(self):
        '''
        List all couples who were married when the older spouse was more than twice as old as the younger spouse
        '''
        file = open('user_story_geds/us34.ged')
        indi, fam = create_tables(file)
        file.close()

        result = user_story_34(indi, fam)

        self.assertNotIn("@US34_I03@", result)
        self.assertNotIn("@US34_I04@", result)
        self.assertNotIn("@US34_I07@", result)
        self.assertNotIn("@US34_I10@", result)
        self.assertIn("@US34_I01@", result)
        self.assertIn("@US34_I02@", result)
        self.assertIn("@US34_I05@", result)
        self.assertIn("@US34_I06@", result)
Exemplo n.º 23
0
    def test_us11(self):
        '''
        Marriage should not occur during marriage to another spouse
        '''

        file = open('user_story_geds/us11.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(user_story_11(indi, fam, "@US11_I01@", "@US11_I02@"),
                         False)
        self.assertEqual(user_story_11(indi, fam, "@US11_I02@", "@US11_I03@"),
                         False)
        self.assertEqual(user_story_11(indi, fam, "@US11_I03@", "@US11_I04@"),
                         True)
        self.assertEqual(user_story_11(indi, fam, "@US11_I04@", "@US11_I07@"),
                         True)
        self.assertEqual(user_story_11(indi, fam, "@US11_I05@", "@US11_I07@"),
                         False)
Exemplo n.º 24
0
    def test_us2(self):
        """
        Birth should occur before marriage
        """

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(
            user_story_2(indi, datetime.datetime(1950, 8, 16), "@I02@",
                         "@I03@"), False)
        self.assertEqual(
            user_story_2(indi, datetime.datetime(1990, 4, 11), "@I02@",
                         "@I03@"), True)
        self.assertEqual(
            user_story_2(indi, datetime.datetime(1950, 3, 23), "@I04@",
                         "@I05@"), True)
        self.assertEqual(
            user_story_2(indi, datetime.datetime(1990, 9, 14), "@I04@",
                         "@I05@"), True)
        self.assertEqual(
            user_story_2(indi, datetime.datetime(1930, 1, 1), "@I04@",
                         "@I05@"), False)
Exemplo n.º 25
0
    def test_us5(self):
        """
        A person cannot get married after their death
        """

        file = open('NicoleFamily.ged', 'r')
        indi, fam = create_tables(file)
        file.close()

        self.assertEqual(
            user_story_5(datetime.datetime(1980, 8, 16), "@I08@", "@I09@",
                         indi), False)
        self.assertEqual(
            user_story_5(datetime.datetime(1955, 10, 3), "@I08@", "@I09@",
                         indi), True)
        self.assertEqual(
            user_story_5(datetime.datetime(1965, 2, 27), "@I08@", "@I09@",
                         indi), True)
        self.assertEqual(
            user_story_5(datetime.datetime(2100, 7, 20), "@I01@", "@I03@",
                         indi), False)
        self.assertEqual(
            user_story_5(datetime.datetime(2010, 7, 20), "@I01@", "@I03@",
                         indi), True)
Exemplo n.º 26
0
login_manager.init_app(app=app)
# Int Gravatar
gravatar = Gravatar(app,
                    size=100,
                    rating='g',
                    default='retro',
                    force_default=False,
                    force_lower=False,
                    use_ssl=False,
                    base_url=None)
# CONNECT TO DB
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
# Create tables
User, NotConfirmedAccount, BlogPost, Comment = create_tables(
    db, UserMixin=UserMixin)

db.create_all()

# Admin user account
db_admin_emails = User.query.filter_by(is_admin=True).all()
admin_emails_len = len(db_admin_emails)

admin_emails = json.loads(os.environ.get('ADMIN_EMAILS'))
admin_names = json.loads(os.environ.get('ADMIN_NAMES'))
admin_passwords = json.loads(os.environ.get('PASSWORDS'))


def add_admin_to_db():
    if len(admin_names) > 0:
        while True:
Exemplo n.º 27
0
def create_tables():
    c = get_db().cursor()
    tables.create_tables(c)
    return "cool"                 
Exemplo n.º 28
0
        file = open('user_story_geds/us39.ged')
        indi, fam = create_tables(file)
        file.close()

        file = open('user_story_geds/us42.ged')
        indi, fam = create_tables(file)
        file.close()

        file = open('user_story_geds/us3.ged')
        indi, fam = create_tables(file)
        file.close()

        file = open('user_story_geds/us01.ged')
        indi, fam = create_tables(file)
        file.close()

        file = open('user_story_geds/us02.ged')
        indi, fam = create_tables(file)
        file.close()


if __name__ == '__main__':
    print('Running unit tests')
    file = open('user_story_geds/bigged.ged', 'r')
    indi, fam = create_tables(file)
    create_indi(indi)
    create_fam(fam)
    file.close()

    unittest.main(exit=False, verbosity=2)