Logo Netdevops

Making work – easy

Some time ago we got an idea of creating tons of awesome website templates.

Just some design fun and creation madness. Sounds like fun, does it? Sure!

But how to test all the websites without hours of time spent to add random texts and stuff to them? Here’s where programming comes to help!

Creating a mock text generator using tools in Python and Script

At first we had to find a nice fake data generator that we could use along with Python without any issues. Our pick of choice was “faker”.

Faker is an easy Python package that helps to generate mock data, like:

  • email
  • name
  • surname
  • address
  • text
  • sentences
  • phone number
  • and so on

Here’s where we made a list of the data that we need in our websites.

We had to think what our possible clients would like to add to their websites.

All the contact info and extra features.

Just a little thinking.

 

 

Then we had to create a script that would change all the data in our test websites. And check if all the fake-data inputs are correct.

Creating scripts was something new to me. And I am still learning how to make them perfectly

Our test text is made in simple .txt file. And we wanted to change the test_text every time we try any website. Just to check if everything with it is ok. Here’s where problems started.
Task became a bit complicated, but in order to make it a bit easier I decided to define all the variables seperately, and then just combine them into one function. In order to do that I created similar definitions that included text, and faker usage.


title = ("WEBSITE_TITLE:", '"', fake.sentence(), '"' )

And then combined them into one function called test_text.

The function needed to be converted into the .txt file and saved.

For this I used an easy function:


print test_text was my little testing help. That had to be deleted from working program.

Then what I was left to do was to change this file into the test_text file.

The program works well, and I am really happy with it. Now our working process became way easier and quicker.

Thank you programming!

Lexie

 

Leave a Comment

Your email address will not be published. Required fields are marked *