Unit Testing in Python - A Quick Overview ?

This article covers the concept of Unit Testing in Python. Testing in Python is a huge topic and can come with a lot of complexity, but it doesn't need to be hard. You can get started creating simple tests for your application in a few easy steps and then build on it from there.

Here, You'll learn about the tools available to write and execute tests, check your application's performance, and even look for security issues.

pytest supports execution of unittest test cases. The real advantage of pytest comes by writing pytest test cases. pytest test cases are a series of functions in a Python file starting with the name test_.

pytest has some other great features:

1. Support for the built-in assert statement instead of using special self.assert*() methods

2. Support for filtering for test cases

3. Ability to rerun from the last failing test

4. An ecosystem of hundreds of plugins to extend the functionality

Running Your Tests From Visual Studio Code

If you're using the Microsoft Visual Studio Code IDE, support for unittest, nose, and pytest execution is built into the Python plugin.

If you have the Python plugin installed, you can set up the configuration of your tests by opening the Command Palette with Ctrl+Shift+P and typing "Python test". 

How to Use unittest and Flask

Flask requires that the app be imported and then set in test mode. You can instantiate a test client and use the test client to make requests to any routes in your application.

All of the test client instantiation is done in the setUp method of your test case. In the following example, my_app is the name of the application. Don’t worry if you don’t know what setUp does. You’ll learn about that in the More Advanced Testing Scenarios section.

The code within your test file should look like this:

import my_app
import unittest

class MyTestCase(unittest.TestCase):
    def setUp(self):
        my_app.app.testing = True
        self.app = my_app.app.test_client()
    def test_home(self):
        result = self.app.get('/')
        # Make your assertions

You can then execute the test cases using the python -m unittest discover command.

Install and Use Kaffeine in Ubuntu 20.04 - Step by Step Process ?

This article covers how to install Kaffeine on Ubuntu 20.04 system. Kaffeine is the media player that is used for playing different videos and audios in various formats. Not only this but users run files from external devices like DVDs and CDs. 

Kaffeine provides the additional functionality of playing live digital television.

Install kaffeine by entering the following commands in the terminal:

$ sudo apt update
$ sudo apt install kaffeine

Change User Password in Ubuntu Linux - Step by Step Process ?

This article covers how you can change user password in Linux either graphically or using the command line. Both Linux and UNIX-like operating systems use the passwd command to change user password. 

This applies to any Linux distribution, including Alpine, Arch, Ubuntu, Debian, RHEL, Fedora, Oracle CentOS, SUSE/OpenSUSE and other popular Linux distros.

The passwd is used to update a user's authentication token (password) stored in /etc/shadow file. 

To Set User Password in Linux:

Type following passwd command to change your own password:

$ passwd

To see all user account try grep command or cat command as follows:

$ cat /etc/passwd
$ grep '^userNameHere' /etc/passwd
$ grep '^linuxapt' /etc/passwd

Install PyCharm on Ubuntu 20.04 - Step by Step Process ?

This article covers how to install PyCharm on your Ubuntu 20.04 system. 

PyCharm is a cross-platform IDE that provides consistent experience on the Windows, macOS, and Linux operating systems. Also, you can also remove it any time from your Ubuntu 20.04 system by following the steps outlined in this guide. 

Main features of PyCharm IDE:

1. Syntax highlighting

2. Auto-Indentation and code formatting

3. Code completion

4. Line and block commenting

5. On-the-fly error highlighting

6. Code snippets

7. Code folding

8. Easy code navigation and search

9. Code analysis

10. Configurable language injections

11. Python refactoring

12. Documentation

To Install PyCharm in Ubuntu and other Linux using Snap:

1. Use the snap command to install the PyCharm Community Edition:

$ sudo snap install pycharm-community --classic

2. To remove PyCharm, you may use this command:

$ sudo snap remove pycharm-community

Install OpenOffice on Ubuntu 20.04 - Step by Step Process ?

This article covers how to perform the installation of the latest version of OpenOffice on the Ubuntu 20.04 system. Once installed users can easily use this application suite to make use of the different sub-modules.

Apache OpenOffice is a free and open-source office productivity software suite similar to LibreOffice and Microsoft Office suite.

Main features of Apache OpenOffice:

1. Writer a word processor you can use for anything from writing a quick letter to producing an entire book.

2. Calc a powerful spreadsheet with all the tools you need to calculate, analyze, and present your data in numerical reports or sizzling graphics.

3. Impress the fastest, most powerful way to create effective multimedia presentations.

4. Draw lets you produce everything from simple diagrams to dynamic 3D illustrations.

5. Base lets you manipulate databases seamlessly. Create and modify tables, forms, queries, and reports, all from within Apache OpenOffice.

6. Math lets you create mathematical equations with a graphic user interface or by directly typing your formulas into the equation editor.

To Uninstall LibreOffice on Ubuntu:

1. Uninstall LibreOffice on Ubuntu by running commands below in your terminal.

$ sudo apt-get remove --purge libreoffice*

This will remove LibreOffice and its dependencies. 

2. Next is to clear out the local repository of LibreOffice packages.

$ sudo apt clean

3. Clear all LibreOffice dependencies that are orphaned – no longer required.

$ sudo apt-get autoremove

Install MongoDB on CentOS 8 - Step by Step Process ?

This article covers MongoDB installation on CentOS 8 system.

Instead, it uses JSON-like documents with dynamic schemas, meaning that, unlike relational databases, MongoDB does not require a predefined schema before you add data to a database. 

You can alter the schema at any time and as often as is necessary without having to set up a new database with an updated schema.

How to Start the MongoDB Service and Test the Database on Ubuntu?

1. Run the following systemctl command to start the MongoDB service:

# sudo systemctl start mongod

2. Then check the service's status:

# sudo systemctl status mongod

This command will return output like the following, indicating that the service is up and running

3. After confirming that the service is running as expected, enable the MongoDB service to start up at boot:

# sudo systemctl enable mongod

How to Managing the MongoDB Service on Ubuntu?

1. The systemctl status command checks the status of the MongoDB service:

# sudo systemctl status mongod

2. You can stop the service anytime by typing:

# sudo systemctl stop mongod

3. To start the service when it’s stopped, run:

# sudo systemctl start mongod

4. You can also restart the server when it’s already running:

# sudo systemctl restart mongod

5. If you ever wish to disable this automatic startup, type:

# sudo systemctl disable mongod

6. Then to re-enable it to start up at boot, run the enable command again:

# sudo systemctl enable mongod