示例#1
0
    def test_project_id_equals_none(self):
        """Test for project id which does not exists."""
        delete_project.delete_project([None])

        fb_db = auth.firebaseDB()
        ref = fb_db.reference("v2/results")
        self.assertIsNotNone(ref.get(shallow=True))
        ref = fb_db.reference("v2/tasks")
        self.assertIsNotNone(ref.get(shallow=True))
        ref = fb_db.reference("v2/groups")
        self.assertIsNotNone(ref.get(shallow=True))
        ref = fb_db.reference("v2/projects")
        self.assertIsNotNone(ref.get(shallow=True))

        pg_db = auth.postgresDB()
        sql_query = "SELECT * FROM tasks WHERE project_id = '{}'".format(
            self.project_id)
        result = pg_db.retr_query(sql_query)
        self.assertNotEqual(result, [])
        sql_query = "SELECT * FROM groups WHERE project_id = '{}'".format(
            self.project_id)
        result = pg_db.retr_query(sql_query)
        self.assertNotEqual(result, [])
        sql_query = "SELECT * FROM projects WHERE project_id = '{}'".format(
            self.project_id)
        result = pg_db.retr_query(sql_query)
        self.assertNotEqual(result, [])
        sql_query = "SELECT * FROM results WHERE project_id = '{}'".format(
            self.project_id)
        result = pg_db.retr_query(sql_query)
        self.assertNotEqual(result, [])
示例#2
0
    def test_project_id_equals_none(self):
        """Test for project id which does not exists."""
        delete_project.delete_project([None])

        time.sleep(5)  # Wait for Firebase Functions to complete

        fb_db = auth.firebaseDB()
        ref = fb_db.reference("v2/results")
        self.assertIsNotNone(ref.get(shallow=True))
        ref = fb_db.reference("v2/tasks")
        self.assertIsNotNone(ref.get(shallow=True))
        ref = fb_db.reference("v2/groups")
        self.assertIsNotNone(ref.get(shallow=True))
        ref = fb_db.reference("v2/groupsUsers")
        self.assertIsNotNone(ref.get(shallow=True))
        ref = fb_db.reference("v2/projects")
        self.assertIsNotNone(ref.get(shallow=True))

        pg_db = auth.postgresDB()
        sql_query = f"SELECT * FROM tasks WHERE project_id = '{self.project_id}'"
        result = pg_db.retr_query(sql_query)
        self.assertNotEqual(result, [])
        sql_query = f"SELECT * FROM groups WHERE project_id = '{self.project_id}'"
        result = pg_db.retr_query(sql_query)
        self.assertNotEqual(result, [])
        sql_query = f"SELECT * FROM projects WHERE project_id = '{self.project_id}'"
        result = pg_db.retr_query(sql_query)
        self.assertNotEqual(result, [])
        sql_query = f"SELECT * FROM results WHERE project_id = '{self.project_id}'"
        result = pg_db.retr_query(sql_query)
        self.assertNotEqual(result, [])
示例#3
0
    def test_deletion(self):
        """Test if tasks, groups, project and results are deleted."""
        delete_project.delete_project([self.project_id])

        fb_db = auth.firebaseDB()
        ref = fb_db.reference("v2/results/{0}".format(self.project_id))
        self.assertIsNone(ref.get())
        ref = fb_db.reference("v2/tasks/{0}".format(self.project_id))
        self.assertIsNone(ref.get())
        ref = fb_db.reference("v2/groups/{0}".format(self.project_id))
        self.assertIsNone(ref.get())
        ref = fb_db.reference("v2/projects/{0}".format(self.project_id))
        self.assertIsNone(ref.get())

        pg_db = auth.postgresDB()
        sql_query = "SELECT * FROM tasks WHERE project_id = '{}'".format(
            self.project_id)
        result = pg_db.retr_query(sql_query)
        self.assertEqual(result, [])
        sql_query = "SELECT * FROM groups WHERE project_id = '{}'".format(
            self.project_id)
        result = pg_db.retr_query(sql_query)
        self.assertEqual(result, [])
        sql_query = "SELECT * FROM projects WHERE project_id = '{}'".format(
            self.project_id)
        result = pg_db.retr_query(sql_query)
        self.assertEqual(result, [])
        sql_query = "SELECT * FROM results WHERE project_id = '{}'".format(
            self.project_id)
        result = pg_db.retr_query(sql_query)
        self.assertEqual(result, [])
示例#4
0
    def test_deletion(self):
        """Test if tasks, groups, project and results are deleted."""
        delete_project.delete_project([self.project_id])

        time.sleep(1)  # Wait for Firebase Functions to complete

        fb_db = auth.firebaseDB()
        ref = fb_db.reference(f"v2/results/{self.project_id}")
        self.assertIsNone(ref.get())
        ref = fb_db.reference(f"v2/tasks/{self.project_id}")
        self.assertIsNone(ref.get())
        ref = fb_db.reference(f"v2/groups/{self.project_id}")
        self.assertIsNone(ref.get())
        ref = fb_db.reference(f"v2/groupsUsers/{self.project_id}")
        self.assertIsNone(ref.get())
        ref = fb_db.reference(f"v2/projects/{self.project_id}")
        self.assertIsNone(ref.get())

        pg_db = auth.postgresDB()
        sql_query = f"SELECT * FROM tasks WHERE project_id = '{self.project_id}'"
        result = pg_db.retr_query(sql_query)

        self.assertEqual(result, [])
        sql_query = f"SELECT * FROM groups WHERE project_id = '{self.project_id}'"
        result = pg_db.retr_query(sql_query)
        self.assertEqual(result, [])
        sql_query = f"SELECT * FROM projects WHERE project_id = '{self.project_id}'"
        result = pg_db.retr_query(sql_query)
        self.assertEqual(result, [])
        sql_query = "SELECT * FROM results WHERE project_id = '{}'".format(
            self.project_id)
        result = pg_db.retr_query(sql_query)
        self.assertEqual(result, [])
def run_delete_project(project_id, project_ids):
    """Delete tasks, groups, project and results."""
    if not project_ids and not project_id:
        click.echo("Missing argument")
        return None
    elif not project_ids:
        project_ids = [project_id]

    click.echo("Projects and all associated data including results " +
               "with following project ids will be deleted permantly:")
    for project_id in project_ids:
        click.echo(project_id)
    click.echo()
    click.echo("Continue with deletion? [y/n] ", nl=False)
    click.echo()
    c = click.getchar()

    if c == "y":
        click.echo("Start deletion")
        if delete_project.delete_project(project_ids):
            click.echo("Finished deletions")
    elif c == "n":
        click.echo("Abort!")
    else:
        click.echo("Invalid input")