Search This Blog

Code snippets and memory joggers

Saturday, January 21, 2017

Test-Driven Development for the Web, with Python, Selenium, Django, JavaScript - Environment

previous - Installation

The tutorial tells you to use:
> mkvirtualenv --python=python3 superlists

however list produced the error
 The executable /home/keith/python3 (from --python=/home/keith/python3) does not exist

Debian seems to have python3 on the PATH
> which python3
produced
/usr/bin/python3

Maybe the virtualenvwrapper package is not picking this up correctly.

> mkvirtualenv --python=/usr/bin/python3 superlists
worked for me.

django and selenium both installed as expected into this virtual environment (ve)


Test-Driven Development for the Web, with Python, Selenium, Django, JavaScript - Installation

 previous - Motivation and using the tutorial Test-Driven Development with Python

What I'll be using

I'm assuming I'll make mistakes. To ensure that I keep concerns separate and I don't end up trashing my work environment I created a virtual machine (vm) using Virtualbox which is install with the amd64 version of Debian GNU\Linux OS in this case the latest stable release at the time or writing is 8.7 (Jessie). However I installed a "base, with the Gnome desktop" vm a few months ago with 8.5 which I've cloned and updated.

Python3

 v3.4.2-2 was installed.


Using the Debian repositories:

virtualenvwrapper 

v4.3.1-2

git

using git-all - v1:2;1;4-2.1deb8u2


The tutorial suggests not using an IDE as such but rather use a text editor.

Gedit

 v3.14.0-3 is pre-install

vim-nox

v2:7.4.488-7+deb8u1
This package contains a version of vim compiled with support for scripting with Lua, Perl, Python, Ruby, and Tcl but no GUI.

I'll report any additional plugins or configuration changes as I go but for now I'll be using the editors as is.

Test-Driven Development for the Web, with Python, Selenium, Django, JavaScript - Motivation



This is the first in a series of posts that describe me putting some concerted effort into the process of learning about the Django framework and applying some coding best practice.

Test-Driven Development

Over recent months I have been developing my code with a mind to making it Unit Test friendly.
I have spotted that the biggest issue with Unit Testing, for me, is that the code I have already written does not lend itself well to Unit Tests. A couple of the issues are the use closely coupled objects and methods that do more than one thing at a time.
Closely Coupled objects mean that mocking function is a time consuming and difficult process.
Methods that do more than one thing dissipate the the effectiveness of testing, requiring more effort to determine the actual issue encountered.
All this extra effort means that creation of the tests are less likely to be done wit a deadline looming.

The Web

In my work, the code I write, provides processes that take client or supplier data and transform it with business rules into data that our database based web applications can use. I have almost nothing to do with the development of those web applications which are written buy three other developers in our team using C# in a windows environment.
Everything I do for the company is happening in the background and I feel in general is unappreciated by the majority of my colleagues. The human race, on the whole, is a very visually orientated species, myself included. I'd like to be able to provide a useful "full-stack" product, mostly to satisfy this human trait in myself.

Selenium

Heck! I have never heard of it nor do I know, at this point, what it is or what it is for. I guess I'll find out with this tutorial.

Django

I have been thinking about developing my knowledge of Django for about a few years now.
I've dipped my toe into the water a couple of times but found other things to do. I have worked through the Django tutorial but have only made one attempt to produce anything other.
I found that there were some blockers to resolving some of the issues that came up. Changes made to the database were clunky to implement, I hope this has now been resolved with the current version.
Then, as I said, the rest of life took over.
Django seems now to becoming quite a mature product with a lot of contribution that enables a developer to produce product quickly. Not only that but when looking at the job postings experienced developers seem to be payed 2-3 times what I'm getting paid now!

Python3

I have also been developing using Python 2.7, I would like to produce something that works with Python3. The last time I assessed Python3 it lacked various support of widely used libraries. This was some 7 years ago though,


All this in mind has lead me to the tutorial "Test-Driven Development with Python"
To quote the site "TDD for the Web, with Python, Selenium, Django, JavaScript and pals..."

next - Installation

About Me

I love to travel and meet new people, motorbikes, moving my body through dance, martial arts and yoga. I'm a lifelong learner interested in how things work, and the way people think and make their decisions. My choice of superpower would be to speak with someone and understand them completely, including their intention and for me to be able to communicate my intention to them clearly in their own language. As an Amazon Associate, I may earn from links to qualifying purchases.